зеркало из https://github.com/mozilla/pjs.git
- added method to enable access to pluglets and
changed the way java dom registers itself
This commit is contained in:
Родитель
ab49c7f3e8
Коммит
aae07fabe7
|
@ -1,133 +0,0 @@
|
|||
/*
|
||||
The contents of this file are subject to the Mozilla Public
|
||||
License Version 1.1 (the "License"); you may not use this file
|
||||
except in compliance with the License. You may obtain a copy of
|
||||
the License at http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS
|
||||
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
implied. See the License for the specific language governing
|
||||
rights and limitations under the License.
|
||||
|
||||
The Original Code is mozilla.org code.
|
||||
|
||||
The Initial Developer of the Original Code is Sun Microsystems,
|
||||
Inc. Portions created by Sun are
|
||||
Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
*/
|
||||
|
||||
package org.mozilla.dom;
|
||||
|
||||
import java.util.Vector;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
public class DOMAccessorImpl implements DOMAccessor, DocumentLoadListener {
|
||||
|
||||
private static DOMAccessor instance = null;
|
||||
private Vector documentLoadListeners = new Vector();
|
||||
|
||||
public static native void register();
|
||||
public static native void unregister();
|
||||
|
||||
static {
|
||||
System.loadLibrary("javadomjni");
|
||||
}
|
||||
|
||||
public static synchronized DOMAccessor getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new DOMAccessorImpl();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public synchronized void
|
||||
addDocumentLoadListener(DocumentLoadListener listener) {
|
||||
|
||||
if (documentLoadListeners.size() == 0) {
|
||||
register();
|
||||
}
|
||||
documentLoadListeners.addElement(listener);
|
||||
}
|
||||
|
||||
public synchronized void
|
||||
removeDocumentLoadListener(DocumentLoadListener listener) {
|
||||
|
||||
documentLoadListeners.removeElement(listener);
|
||||
if (documentLoadListeners.size() == 0) {
|
||||
unregister();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void
|
||||
startURLLoad(String url, String contentType, Document doc) {
|
||||
|
||||
for (Enumeration e = documentLoadListeners.elements();
|
||||
e.hasMoreElements();) {
|
||||
DocumentLoadListener listener =
|
||||
(DocumentLoadListener) e.nextElement();
|
||||
listener.startURLLoad(url, contentType, doc);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void
|
||||
endURLLoad(String url, int status, Document doc) {
|
||||
|
||||
for (Enumeration e = documentLoadListeners.elements();
|
||||
e.hasMoreElements();) {
|
||||
DocumentLoadListener listener =
|
||||
(DocumentLoadListener) e.nextElement();
|
||||
listener.endURLLoad(url, status, doc);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void
|
||||
progressURLLoad(String url, int progress, int progressMax,
|
||||
Document doc) {
|
||||
|
||||
for (Enumeration e = documentLoadListeners.elements();
|
||||
e.hasMoreElements();) {
|
||||
DocumentLoadListener listener =
|
||||
(DocumentLoadListener) e.nextElement();
|
||||
listener.progressURLLoad(url, progress, progressMax, doc);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void
|
||||
statusURLLoad(String url, String message, Document doc) {
|
||||
|
||||
for (Enumeration e = documentLoadListeners.elements();
|
||||
e.hasMoreElements();) {
|
||||
DocumentLoadListener listener =
|
||||
(DocumentLoadListener) e.nextElement();
|
||||
listener.statusURLLoad(url, message, doc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public synchronized void
|
||||
startDocumentLoad(String url) {
|
||||
|
||||
for (Enumeration e = documentLoadListeners.elements();
|
||||
e.hasMoreElements();) {
|
||||
DocumentLoadListener listener =
|
||||
(DocumentLoadListener) e.nextElement();
|
||||
listener.startDocumentLoad(url);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void
|
||||
endDocumentLoad(String url, int status, Document doc) {
|
||||
|
||||
for (Enumeration e = documentLoadListeners.elements();
|
||||
e.hasMoreElements();) {
|
||||
DocumentLoadListener listener =
|
||||
(DocumentLoadListener) e.nextElement();
|
||||
listener.endDocumentLoad(url, status, doc);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,96 +0,0 @@
|
|||
/*
|
||||
The contents of this file are subject to the Mozilla Public
|
||||
License Version 1.1 (the "License"); you may not use this file
|
||||
except in compliance with the License. You may obtain a copy of
|
||||
the License at http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS
|
||||
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
implied. See the License for the specific language governing
|
||||
rights and limitations under the License.
|
||||
|
||||
The Original Code is mozilla.org code.
|
||||
|
||||
The Initial Developer of the Original Code is Sun Microsystems,
|
||||
Inc. Portions created by Sun are
|
||||
Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
*/
|
||||
|
||||
package org.mozilla.dom;
|
||||
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.CDATASection;
|
||||
import org.w3c.dom.Comment;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.DocumentFragment;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.EntityReference;
|
||||
import org.w3c.dom.ProcessingInstruction;
|
||||
import org.w3c.dom.Text;
|
||||
import org.w3c.dom.DocumentType;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.w3c.dom.DOMImplementation;
|
||||
import org.w3c.dom.events.DocumentEvent;
|
||||
import org.w3c.dom.events.Event;
|
||||
import org.w3c.dom.DOMException;
|
||||
|
||||
public class DocumentImpl extends NodeImpl implements Document, DocumentEvent {
|
||||
|
||||
// instantiated from JNI only
|
||||
private DocumentImpl() {}
|
||||
public DocumentImpl(long p) {
|
||||
super(p);
|
||||
}
|
||||
|
||||
public native Attr createAttribute(String name);
|
||||
public native CDATASection createCDATASection(String data);
|
||||
public native Comment createComment(String data);
|
||||
public native DocumentFragment createDocumentFragment();
|
||||
public native Element createElement(String tagName);
|
||||
public native EntityReference createEntityReference(String name);
|
||||
public native ProcessingInstruction
|
||||
createProcessingInstruction(String target,
|
||||
String data);
|
||||
public native Text createTextNode(String data);
|
||||
|
||||
public native DocumentType getDoctype();
|
||||
public native Element getDocumentElement();
|
||||
public native NodeList getElementsByTagName(String tagName);
|
||||
public native DOMImplementation getImplementation();
|
||||
|
||||
private static native void initialize();
|
||||
|
||||
public Event createEvent(String type) throws DOMException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
static {
|
||||
initialize();
|
||||
}
|
||||
|
||||
public Node importNode(Node importedNode, boolean deep) throws DOMException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Element createElementNS(String namespaceURI, String qualifiedName)
|
||||
throws DOMException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Attr createAttributeNS(String namespaceURI, String qualifiedName)
|
||||
throws DOMException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public NodeList getElementsByTagNameNS(String namespaceURI, String localName) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Element getElementById(String elementId) {
|
||||
throw new UnsupportedOperationException();
|
||||
};
|
||||
}
|
|
@ -1,4 +1,3 @@
|
|||
#include "org_mozilla_dom_DOMAccessorImpl.h"
|
||||
|
||||
#include "prlog.h"
|
||||
#include "javaDOMGlobals.h"
|
||||
|
@ -8,6 +7,7 @@
|
|||
#include "nsCURILoader.h"
|
||||
|
||||
#include "nsIJavaDOM.h"
|
||||
#include "org_mozilla_dom_DOMAccessorImpl.h"
|
||||
|
||||
static NS_DEFINE_IID(kDocLoaderServiceCID, NS_DOCUMENTLOADER_SERVICE_CID);
|
||||
static NS_DEFINE_IID(kJavaDOMCID, NS_JAVADOM_CID);
|
||||
|
@ -18,26 +18,29 @@ static NS_DEFINE_IID(kJavaDOMCID, NS_JAVADOM_CID);
|
|||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_dom_DOMAccessorImpl_register
|
||||
(JNIEnv *, jclass jthis)
|
||||
(JNIEnv *env, jclass jthis)
|
||||
{
|
||||
if (!JavaDOMGlobals::log) {
|
||||
JavaDOMGlobals::Initialize(env);
|
||||
}
|
||||
nsresult rv = NS_OK;
|
||||
NS_WITH_SERVICE(nsIDocumentLoader, docLoaderService, kDocLoaderServiceCID, &rv);
|
||||
if (NS_FAILED(rv) || !docLoaderService) {
|
||||
fprintf(stderr,
|
||||
"DOMAccessor::register: GetService(JavaDOM) failed: %x\n",
|
||||
rv);
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
|
||||
("DOMAccessor::register: GetService(JavaDOM) failed: %x\n",
|
||||
rv));
|
||||
} else {
|
||||
NS_WITH_SERVICE(nsIDocumentLoaderObserver, javaDOM, kJavaDOMCID, &rv);
|
||||
if (NS_FAILED(rv) || !javaDOM) {
|
||||
fprintf(stderr,
|
||||
"DOMAccessor::register: GetService(JavaDOM) failed: %x\n",
|
||||
rv);
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
|
||||
("DOMAccessor::register: GetService(JavaDOM) failed: %x\n",
|
||||
rv));
|
||||
} else {
|
||||
rv = docLoaderService->AddObserver((nsIDocumentLoaderObserver*)javaDOM);
|
||||
if (NS_FAILED(rv)) {
|
||||
fprintf(stderr,
|
||||
"DOMAccessor::register: AddObserver(JavaDOM) failed x\n",
|
||||
rv);
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
|
||||
("DOMAccessor::register: AddObserver(JavaDOM) failed x\n",
|
||||
rv));
|
||||
}
|
||||
}
|
||||
nsServiceManager::ReleaseService(kDocLoaderServiceCID, docLoaderService);
|
||||
|
@ -78,3 +81,18 @@ JNIEXPORT void JNICALL Java_org_mozilla_dom_DOMAccessorImpl_unregister
|
|||
nsServiceManager::ReleaseService(kDocLoaderServiceCID, docLoaderService);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_dom_DOMAccessorImpl
|
||||
* Method: createElement
|
||||
* Signature: (J)Lorg/w3c/dom/Element;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DOMAccessorImpl_getElementByHandle
|
||||
(JNIEnv *env, jclass jthis, jlong p)
|
||||
{
|
||||
if (!JavaDOMGlobals::log) {
|
||||
JavaDOMGlobals::Initialize(env);
|
||||
}
|
||||
nsIDOMNode *node = (nsIDOMNode*)p;
|
||||
return JavaDOMGlobals::CreateNodeSubtype(env, node);
|
||||
}
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class org_mozilla_dom_DOMAccessorImpl */
|
||||
|
||||
#ifndef _Included_org_mozilla_dom_DOMAccessorImpl
|
||||
#define _Included_org_mozilla_dom_DOMAccessorImpl
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
* Class: org_mozilla_dom_DOMAccessorImpl
|
||||
* Method: register
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_dom_DOMAccessorImpl_register
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_dom_DOMAccessorImpl
|
||||
* Method: unregister
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_dom_DOMAccessorImpl_unregister
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
|
@ -35,21 +35,6 @@
|
|||
#include "javaDOMGlobals.h"
|
||||
#include "org_mozilla_dom_DocumentImpl.h"
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_dom_DocumentImpl
|
||||
* Method: initialize
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_dom_DocumentImpl_initialize
|
||||
(JNIEnv *env, jclass)
|
||||
{
|
||||
if (!JavaDOMGlobals::log) {
|
||||
JavaDOMGlobals::Initialize(env);
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_DEBUG,
|
||||
("Document.initialize\n"));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_dom_DocumentImpl
|
||||
* Method: createAttribute
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/* Inaccessible static: javaDOMlisteners */
|
||||
/*
|
||||
* Class: org_mozilla_dom_DocumentImpl
|
||||
* Method: createAttribute
|
||||
|
@ -71,7 +72,6 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_createProcessingInst
|
|||
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_createTextNode
|
||||
(JNIEnv *, jobject, jstring);
|
||||
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_dom_DocumentImpl
|
||||
* Method: getDoctype
|
||||
|
@ -104,14 +104,6 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_getElementsByTagName
|
|||
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_getImplementation
|
||||
(JNIEnv *, jobject);
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_dom_DocumentImpl
|
||||
* Method: initialize
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_dom_DocumentImpl_initialize
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -21,8 +21,13 @@
|
|||
|
||||
DEPTH=..\..
|
||||
IGNORE_MANIFEST=1
|
||||
DIRS = jni
|
||||
|
||||
JAVAHOME=$(JDKHOME)
|
||||
DEFINES=-D_IMPL_NS_WEB -DWIN32_LEAN_AND_MEAN
|
||||
!ifdef JAVA_DOM_OJI_ENABLE
|
||||
DEFINES+= -DJAVA_DOM_OJI_ENABLE
|
||||
!endif
|
||||
MODULE=javadom
|
||||
IS_COMPONENT=1
|
||||
LIBRARY_NAME=libjavadom
|
||||
|
|
|
@ -504,6 +504,12 @@ JNIEnv* nsJavaDOMImpl::GetJNIEnv() {
|
|||
|
||||
#ifndef JAVA_DOM_OJI_ENABLE
|
||||
void nsJavaDOMImpl::StartJVM(void) {
|
||||
jsize jvmCount;
|
||||
JNI_GetCreatedJavaVMs(&jvm, 1, &jvmCount);
|
||||
if (jvmCount) {
|
||||
return;
|
||||
}
|
||||
|
||||
JNIEnv *env = NULL;
|
||||
JDK1_1InitArgs vm_args;
|
||||
JNI_GetDefaultJavaVMInitArgs(&vm_args);
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
BW_TESTDIR=/opt/mozilla/java/dom/tests/src
|
||||
BW_TESTDIR=T:
|
||||
BW_TESTFILE=BWTestClass.lst
|
||||
BW_LOGDIR=/opt/mozilla/java/dom/tests/src/log
|
||||
BW_LOGDIR=T:\\log
|
||||
BW_LOGFILE=BWTest.log
|
||||
BW_THREADMODE=S
|
||||
BW_HTMLTEST=file:
|
||||
BW_XMLTEST=file:
|
||||
|
|
|
@ -1 +1,4 @@
|
|||
org.mozilla.dom.test.ElementImpl_getAttribute_String_0
|
||||
org.mozilla.dom.test.ElementImpl_setAttributeNode_Attr_1
|
||||
#org.mozilla.dom.test.AttrImpl_getName
|
||||
#org.mozilla.dom.test.AttrImpl_setValue_String_0
|
||||
#org.mozilla.dom.test.AttrImpl_setValue_String_1
|
||||
|
|
|
@ -1,66 +1,40 @@
|
|||
/*
|
||||
The contents of this file are subject to the Mozilla Public
|
||||
License Version 1.1 (the "License"); you may not use this file
|
||||
except in compliance with the License. You may obtain a copy of
|
||||
the License at http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS
|
||||
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
implied. See the License for the specific language governing
|
||||
rights and limitations under the License.
|
||||
|
||||
The Original Code is mozilla.org code.
|
||||
|
||||
The Initial Developer of the Original Code is Sun Microsystems,
|
||||
Inc. Portions created by Sun are
|
||||
Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
*/
|
||||
/**
|
||||
****************************************************************************
|
||||
*
|
||||
* @author Raju Pallath
|
||||
* @version 1.0
|
||||
*
|
||||
* this class loads all the Test cases and executes them and returns the
|
||||
* pass/fail status.
|
||||
* The Factory class loads this class and executes all Test Cases
|
||||
* listed in a file whose path is set by env. variable BW_TESTDIR
|
||||
* and filename by itself is set in BW_TESTFILE
|
||||
* This class loops thru' each file entry and tries to execute each test
|
||||
* case.
|
||||
*
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
package org.mozilla.dom.test;
|
||||
|
||||
import java.lang.*;
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.applet.Applet;
|
||||
import org.w3c.dom.Document;
|
||||
import org.mozilla.dom.DOMAccessorImpl;
|
||||
import org.mozilla.dom.DocumentLoadListener;
|
||||
import org.mozilla.dom.test.*;
|
||||
import org.w3c.dom.DOMException;
|
||||
|
||||
public class TestLoader extends Applet implements DocumentLoadListener
|
||||
public class TestLoader
|
||||
{
|
||||
|
||||
private Object targetObj;
|
||||
private int returnType = 0;
|
||||
private int returnType;
|
||||
private static String TESTFILE = "BWTestClass.lst";
|
||||
private static String PROPERTYFILE = "BWProperties";
|
||||
private static String PROPERTYFILE = "T:\\BWProperties";
|
||||
private static String LOGFILE = "BWTest.log";
|
||||
private static String LOGHTML = "BWTest.html";
|
||||
private static String LOGTXT = "BWTest.txt";
|
||||
private static String SEP = "\\";
|
||||
public static Properties propTable = new Properties();
|
||||
private final boolean debug = true;
|
||||
private static String FILE_SEP = "/";
|
||||
|
||||
/**
|
||||
************************************************************************
|
||||
* Default constructor
|
||||
*
|
||||
************************************************************************
|
||||
*/
|
||||
public TestLoader()
|
||||
{
|
||||
System.out.println("########################## Createing default TestLoader ...\n");
|
||||
try {
|
||||
throw new Exception();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
FILE_SEP = System.getProperty("file.separator");
|
||||
}
|
||||
|
||||
/**
|
||||
************************************************************************
|
||||
|
@ -74,31 +48,10 @@ public class TestLoader extends Applet implements DocumentLoadListener
|
|||
*/
|
||||
public TestLoader(Object obj, int areturnType)
|
||||
{
|
||||
System.out.println("########################## Createing TestLoader ...");
|
||||
targetObj = obj;
|
||||
returnType = areturnType;
|
||||
FILE_SEP = System.getProperty("file.separator");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
************************************************************************
|
||||
*
|
||||
* Sets the Testing Target
|
||||
*
|
||||
* @param target Target to be tested
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
************************************************************************
|
||||
*
|
||||
*/
|
||||
void setTarget(Object target)
|
||||
{
|
||||
targetObj = target;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
************************************************************************
|
||||
|
@ -111,6 +64,7 @@ public class TestLoader extends Applet implements DocumentLoadListener
|
|||
*/
|
||||
public Object loadTest()
|
||||
{
|
||||
System.out.println("<-=-=-= TESTLOADER =-=-=->");
|
||||
if (targetObj == null) {
|
||||
System.out.println("Target Object " + targetObj.toString() + " is null....");
|
||||
return null;
|
||||
|
@ -118,32 +72,7 @@ public class TestLoader extends Applet implements DocumentLoadListener
|
|||
|
||||
// Read Property File
|
||||
TestLoader.readPropertyFile();
|
||||
|
||||
// Check Property Names, to see if provided with correct file
|
||||
// separators.
|
||||
// For Windows platform FILE_SEP is \ but it has to be escaped with
|
||||
// another \ , so a property value would look like c:\\mozilla\\java
|
||||
// instead of c:\mozilla\java
|
||||
//
|
||||
String CHECK_SEP = "/";
|
||||
|
||||
if ( FILE_SEP.compareTo("/") == 0) CHECK_SEP = "\\";
|
||||
Enumeration em = propTable.propertyNames();
|
||||
if (em == null) return null;
|
||||
|
||||
while (em.hasMoreElements())
|
||||
{
|
||||
String name = (String)(em.nextElement());
|
||||
String val = propTable.getProperty(name);
|
||||
if (val == null) continue;
|
||||
|
||||
int idx = val.indexOf(CHECK_SEP);
|
||||
if (idx != -1) {
|
||||
System.out.println("********** ERROR: File Separator for Property " + name + " is incorrect in file " + PROPERTYFILE);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
propTable.list(System.out);
|
||||
|
||||
String testDir = ".";
|
||||
String testFile = TESTFILE;
|
||||
|
@ -156,18 +85,16 @@ public class TestLoader extends Applet implements DocumentLoadListener
|
|||
testFile = propTable.getProperty("BW_TESTFILE");
|
||||
if (testFile == null) testFile = TESTFILE;
|
||||
|
||||
String fname = testDir + FILE_SEP + testFile;
|
||||
String fname = testDir + SEP + testFile;
|
||||
FileInputStream in = null;
|
||||
|
||||
try {
|
||||
in = new FileInputStream(fname);
|
||||
} catch (SecurityException e) {
|
||||
System.out.println ("Security Exception:Could not create stream for file " + fname);
|
||||
System.exit(-1);
|
||||
return null;
|
||||
} catch (FileNotFoundException e) {
|
||||
System.out.println ("Could not create stream for file " + fname);
|
||||
System.exit(-1);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -218,7 +145,6 @@ public class TestLoader extends Applet implements DocumentLoadListener
|
|||
|
||||
Class c=null;
|
||||
try {
|
||||
System.out.println("############### Class name: "+s);
|
||||
c = Class.forName(s);
|
||||
} catch (ClassNotFoundException e) {
|
||||
System.out.println ("Could not find class " + s);
|
||||
|
@ -232,47 +158,37 @@ public class TestLoader extends Applet implements DocumentLoadListener
|
|||
System.out.println ("Could not instantiate class " + s);
|
||||
continue;
|
||||
}
|
||||
|
||||
// If single thread execution
|
||||
if (threadMode.compareTo("S") == 0)
|
||||
{
|
||||
try {
|
||||
System.out.println("################ Starting test ...");
|
||||
if (((BWBaseTest)classObj).execute(targetObj)) {
|
||||
txtPrint(s, "PASSED");
|
||||
System.out.println("################ passed");
|
||||
} else {
|
||||
txtPrint(s, "FAILED");
|
||||
System.out.println("################ failed");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("################ failed with exception: "+e);
|
||||
txtPrint(s, "FAILED: "+e);
|
||||
}
|
||||
|
||||
// if any return type expected, then it is returned.
|
||||
// This is just a provision kept for latter use
|
||||
//
|
||||
//if (returnType == 1)
|
||||
//{
|
||||
// return (((BWBaseTest)classObj).returnObject());
|
||||
//}
|
||||
} else {
|
||||
BWTestThread t = new BWTestThread(s);
|
||||
try {
|
||||
System.out.println("############## Starting test ...");
|
||||
if (t != null)
|
||||
{
|
||||
t.setTestObject(classObj, targetObj);
|
||||
t.start();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
txtPrint(s, "FAILED: "+e);
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("-- running test: " + s);
|
||||
|
||||
// If single thread execution
|
||||
if (threadMode.compareTo("S") == 0)
|
||||
{
|
||||
if (((BWBaseTest)classObj).execute(targetObj)) {
|
||||
txtPrint(s, "PASSED");
|
||||
System.out.println(" PASSED");
|
||||
} else {
|
||||
txtPrint(s, "FAILED");
|
||||
System.out.println(" FAILED");
|
||||
}
|
||||
|
||||
// if any return type expected, then it is returned.
|
||||
// This is just a provision kept for latter use
|
||||
//
|
||||
//if (returnType == 1)
|
||||
//{
|
||||
// return (((BWBaseTest)classObj).returnObject());
|
||||
//}
|
||||
} else {
|
||||
BWTestThread t = new BWTestThread(s);
|
||||
if (t != null)
|
||||
{
|
||||
t.setTestObject(classObj, targetObj);
|
||||
t.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
//txtPrint("Parent Thread Done", "PASSED");
|
||||
|
||||
System.out.println("<-=-=-= END TESTLOADER =-=-=->");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -296,7 +212,7 @@ public class TestLoader extends Applet implements DocumentLoadListener
|
|||
// Get Input Stream from Property file
|
||||
FileInputStream fin=null;
|
||||
try {
|
||||
fin = new FileInputStream("./" + PROPERTYFILE);
|
||||
fin = new FileInputStream(PROPERTYFILE);
|
||||
} catch (Exception e) {
|
||||
System.out.println ("Security Exception:Could not create stream for file " + PROPERTYFILE);
|
||||
return;
|
||||
|
@ -317,7 +233,6 @@ public class TestLoader extends Applet implements DocumentLoadListener
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -352,6 +267,7 @@ public class TestLoader extends Applet implements DocumentLoadListener
|
|||
*/
|
||||
public static void logPrint(String msg)
|
||||
{
|
||||
|
||||
if (msg == null) return;
|
||||
|
||||
String logDir = propTable.getProperty("BW_LOGDIR");
|
||||
|
@ -360,7 +276,8 @@ public class TestLoader extends Applet implements DocumentLoadListener
|
|||
String logFile = propTable.getProperty("BW_LOGFILE");
|
||||
if (logFile == null) logFile = LOGFILE;
|
||||
|
||||
String fname = logDir + FILE_SEP + logFile;
|
||||
|
||||
String fname = logDir + SEP + logFile;
|
||||
|
||||
// Get Output Stream from Log file
|
||||
RandomAccessFile raf=null;
|
||||
|
@ -405,7 +322,7 @@ public class TestLoader extends Applet implements DocumentLoadListener
|
|||
|
||||
|
||||
|
||||
String fname = logDir + FILE_SEP + logFile;
|
||||
String fname = logDir + SEP + logFile;
|
||||
|
||||
File f=null;
|
||||
try {
|
||||
|
@ -491,7 +408,7 @@ public class TestLoader extends Applet implements DocumentLoadListener
|
|||
String logFile = LOGHTML;
|
||||
|
||||
|
||||
String fname = logDir + FILE_SEP + logFile;
|
||||
String fname = logDir + SEP + logFile;
|
||||
|
||||
// Get Output Stream from Log file
|
||||
RandomAccessFile raf=null;
|
||||
|
@ -548,7 +465,7 @@ public class TestLoader extends Applet implements DocumentLoadListener
|
|||
String logFile = LOGHTML;
|
||||
|
||||
|
||||
String fname = logDir + FILE_SEP + logFile;
|
||||
String fname = logDir + SEP + logFile;
|
||||
|
||||
// Get Output Stream from Log file
|
||||
RandomAccessFile raf=null;
|
||||
|
@ -605,7 +522,7 @@ public class TestLoader extends Applet implements DocumentLoadListener
|
|||
String logFile = TestLoader.LOGTXT;
|
||||
|
||||
|
||||
String fname = logDir + FILE_SEP + logFile;
|
||||
String fname = logDir + SEP + logFile;
|
||||
|
||||
// Get Output Stream from Log file
|
||||
RandomAccessFile raf=null;
|
||||
|
@ -634,82 +551,4 @@ public class TestLoader extends Applet implements DocumentLoadListener
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*Implementing DocumentLoadListener interface*/
|
||||
public void endDocumentLoad(String url, int status, Document doc)
|
||||
{
|
||||
System.out.println("################### Got Document: "+url);
|
||||
if ((!(url.endsWith(".html"))) && (!(url.endsWith(".xml")))) {
|
||||
System.out.println("################### Document is not HTML/XML ... "+url);
|
||||
return;
|
||||
}
|
||||
|
||||
if (url.endsWith(".html"))
|
||||
{
|
||||
if (url.indexOf("test.html") == -1) {
|
||||
System.out.println("TestCases Tuned to run with test.html...");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (url.endsWith(".xml"))
|
||||
{
|
||||
if (url.indexOf("test.xml") == -1) {
|
||||
System.out.println("TestCases Tuned to run with test.xml...");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Object obj = (Object) doc;
|
||||
|
||||
setTarget(obj);
|
||||
System.out.println("################## Loading test ... ");
|
||||
try {
|
||||
Object retobj = loadTest();
|
||||
System.out.println("################## test exited normally ... ");
|
||||
} catch (Exception e) {
|
||||
System.out.println("################## test exited abnormally: \n" + e);
|
||||
}
|
||||
|
||||
doc = null;
|
||||
|
||||
};
|
||||
public void startURLLoad(String url, String contentType, Document doc) {};
|
||||
public void endURLLoad(String url, int status, Document doc) {};
|
||||
public void progressURLLoad(String url, int progress, int progressMax, Document doc) {};
|
||||
public void statusURLLoad(String url, String message, Document doc) {};
|
||||
public void startDocumentLoad(String url) {};
|
||||
|
||||
/*Overiding some Applet's methods */
|
||||
public void init()
|
||||
{
|
||||
System.err.println("################## Regestring DocumentLoadListener !");
|
||||
DOMAccessorImpl.getInstance().addDocumentLoadListener((DocumentLoadListener)this);
|
||||
|
||||
String testURL = propTable.getProperty("BW_HTMLTEST");
|
||||
if (testURL == null) {
|
||||
System.err.println("################# WARNING: BW_HTMLTEST property is not set ! Using file: protocol by default !");
|
||||
testURL="file:";
|
||||
}
|
||||
|
||||
if (getParameter("test_type").equals("XML")) {
|
||||
testURL = propTable.getProperty("BW_XMLTEST");
|
||||
if (testURL == null)
|
||||
testURL="file:";
|
||||
testURL+="/test.xml";
|
||||
} else if (getParameter("test_type").equals("HTML")) {
|
||||
testURL+="/test.html";
|
||||
} else {
|
||||
System.err.println("################ WARNING: Unrecognized test type (valid are HTML/XML):"+getParameter("test_type")+"\nLoading test.html by default.");
|
||||
testURL+="/test.html";
|
||||
}
|
||||
|
||||
System.err.println("################## Loading "+testURL);
|
||||
try {
|
||||
getAppletContext().showDocument(new URL(testURL));
|
||||
} catch (Exception e) {
|
||||
System.err.println("############ Can't show test document: \nException: " + e.fillInStackTrace());
|
||||
}
|
||||
}
|
||||
|
||||
}//end of class
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче