зеркало из https://github.com/mozilla/gecko-dev.git
Replaced old TestLoader with new TestLoader
This commit is contained in:
Родитель
b9a6025e36
Коммит
5247e0092c
|
@ -1,4 +1,7 @@
|
||||||
BW_TESTDIR=T:
|
BW_TESTDIR=/opt/mozilla/java/dom/tests/src
|
||||||
BW_TESTFILE=BWTestClass.lst
|
BW_TESTFILE=BWTestClass.lst
|
||||||
BW_LOGDIR=T:\\log
|
BW_LOGDIR=/opt/mozilla/java/dom/tests/src/log
|
||||||
BW_LOGFILE=BWTest.log
|
BW_LOGFILE=BWTest.log
|
||||||
|
BW_THREADMODE=S
|
||||||
|
BW_HTMLTEST=file:
|
||||||
|
BW_XMLTEST=file:
|
||||||
|
|
|
@ -1,40 +1,66 @@
|
||||||
/**
|
/*
|
||||||
****************************************************************************
|
The contents of this file are subject to the Mozilla Public
|
||||||
*
|
License Version 1.1 (the "License"); you may not use this file
|
||||||
* @author Raju Pallath
|
except in compliance with the License. You may obtain a copy of
|
||||||
* @version 1.0
|
the License at http://www.mozilla.org/MPL/
|
||||||
*
|
|
||||||
* this class loads all the Test cases and executes them and returns the
|
Software distributed under the License is distributed on an "AS
|
||||||
* pass/fail status.
|
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||||
* The Factory class loads this class and executes all Test Cases
|
implied. See the License for the specific language governing
|
||||||
* listed in a file whose path is set by env. variable BW_TESTDIR
|
rights and limitations under the License.
|
||||||
* and filename by itself is set in BW_TESTFILE
|
|
||||||
* This class loops thru' each file entry and tries to execute each test
|
The Original Code is mozilla.org code.
|
||||||
* case.
|
|
||||||
*
|
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.test;
|
package org.mozilla.dom.test;
|
||||||
|
|
||||||
import java.lang.*;
|
import java.lang.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.io.*;
|
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.mozilla.dom.test.*;
|
||||||
import org.w3c.dom.DOMException;
|
|
||||||
|
|
||||||
public class TestLoader
|
public class TestLoader extends Applet implements DocumentLoadListener
|
||||||
{
|
{
|
||||||
|
|
||||||
private Object targetObj;
|
private Object targetObj;
|
||||||
private int returnType;
|
private int returnType = 0;
|
||||||
private static String TESTFILE = "BWTestClass.lst";
|
private static String TESTFILE = "BWTestClass.lst";
|
||||||
private static String PROPERTYFILE = "T:\\BWProperties";
|
private static String PROPERTYFILE = "BWProperties";
|
||||||
private static String LOGFILE = "BWTest.log";
|
private static String LOGFILE = "BWTest.log";
|
||||||
private static String LOGHTML = "BWTest.html";
|
private static String LOGHTML = "BWTest.html";
|
||||||
private static String LOGTXT = "BWTest.txt";
|
private static String LOGTXT = "BWTest.txt";
|
||||||
private static String SEP = "\\";
|
|
||||||
public static Properties propTable = new Properties();
|
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");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
************************************************************************
|
************************************************************************
|
||||||
|
@ -48,10 +74,31 @@ public class TestLoader
|
||||||
*/
|
*/
|
||||||
public TestLoader(Object obj, int areturnType)
|
public TestLoader(Object obj, int areturnType)
|
||||||
{
|
{
|
||||||
|
System.out.println("########################## Createing TestLoader ...");
|
||||||
targetObj = obj;
|
targetObj = obj;
|
||||||
returnType = areturnType;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
************************************************************************
|
************************************************************************
|
||||||
|
@ -64,7 +111,6 @@ public class TestLoader
|
||||||
*/
|
*/
|
||||||
public Object loadTest()
|
public Object loadTest()
|
||||||
{
|
{
|
||||||
System.out.println("<-=-=-= TESTLOADER =-=-=->");
|
|
||||||
if (targetObj == null) {
|
if (targetObj == null) {
|
||||||
System.out.println("Target Object " + targetObj.toString() + " is null....");
|
System.out.println("Target Object " + targetObj.toString() + " is null....");
|
||||||
return null;
|
return null;
|
||||||
|
@ -72,7 +118,32 @@ public class TestLoader
|
||||||
|
|
||||||
// Read Property File
|
// Read Property File
|
||||||
TestLoader.readPropertyFile();
|
TestLoader.readPropertyFile();
|
||||||
propTable.list(System.out);
|
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
String testDir = ".";
|
String testDir = ".";
|
||||||
String testFile = TESTFILE;
|
String testFile = TESTFILE;
|
||||||
|
@ -85,16 +156,18 @@ public class TestLoader
|
||||||
testFile = propTable.getProperty("BW_TESTFILE");
|
testFile = propTable.getProperty("BW_TESTFILE");
|
||||||
if (testFile == null) testFile = TESTFILE;
|
if (testFile == null) testFile = TESTFILE;
|
||||||
|
|
||||||
String fname = testDir + SEP + testFile;
|
String fname = testDir + FILE_SEP + testFile;
|
||||||
FileInputStream in = null;
|
FileInputStream in = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
in = new FileInputStream(fname);
|
in = new FileInputStream(fname);
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
System.out.println ("Security Exception:Could not create stream for file " + fname);
|
System.out.println ("Security Exception:Could not create stream for file " + fname);
|
||||||
|
System.exit(-1);
|
||||||
return null;
|
return null;
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
System.out.println ("Could not create stream for file " + fname);
|
System.out.println ("Could not create stream for file " + fname);
|
||||||
|
System.exit(-1);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,6 +218,7 @@ public class TestLoader
|
||||||
|
|
||||||
Class c=null;
|
Class c=null;
|
||||||
try {
|
try {
|
||||||
|
System.out.println("############### Class name: "+s);
|
||||||
c = Class.forName(s);
|
c = Class.forName(s);
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
System.out.println ("Could not find class " + s);
|
System.out.println ("Could not find class " + s);
|
||||||
|
@ -158,37 +232,47 @@ public class TestLoader
|
||||||
System.out.println ("Could not instantiate class " + s);
|
System.out.println ("Could not instantiate class " + s);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
System.out.println("-- running test: " + s);
|
|
||||||
|
// If single thread execution
|
||||||
// If single thread execution
|
if (threadMode.compareTo("S") == 0)
|
||||||
if (threadMode.compareTo("S") == 0)
|
{
|
||||||
{
|
try {
|
||||||
if (((BWBaseTest)classObj).execute(targetObj)) {
|
System.out.println("################ Starting test ...");
|
||||||
txtPrint(s, "PASSED");
|
if (((BWBaseTest)classObj).execute(targetObj)) {
|
||||||
System.out.println(" PASSED");
|
txtPrint(s, "PASSED");
|
||||||
} else {
|
System.out.println("################ passed");
|
||||||
txtPrint(s, "FAILED");
|
} else {
|
||||||
System.out.println(" FAILED");
|
txtPrint(s, "FAILED");
|
||||||
}
|
System.out.println("################ failed");
|
||||||
|
}
|
||||||
// if any return type expected, then it is returned.
|
} catch (Exception e) {
|
||||||
// This is just a provision kept for latter use
|
System.out.println("################ failed with exception: "+e);
|
||||||
//
|
txtPrint(s, "FAILED: "+e);
|
||||||
//if (returnType == 1)
|
}
|
||||||
//{
|
|
||||||
// return (((BWBaseTest)classObj).returnObject());
|
// if any return type expected, then it is returned.
|
||||||
//}
|
// This is just a provision kept for latter use
|
||||||
} else {
|
//
|
||||||
BWTestThread t = new BWTestThread(s);
|
//if (returnType == 1)
|
||||||
if (t != null)
|
//{
|
||||||
{
|
// return (((BWBaseTest)classObj).returnObject());
|
||||||
t.setTestObject(classObj, targetObj);
|
//}
|
||||||
t.start();
|
} 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
//txtPrint("Parent Thread Done", "PASSED");
|
||||||
System.out.println("<-=-=-= END TESTLOADER =-=-=->");
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,7 +296,7 @@ public class TestLoader
|
||||||
// Get Input Stream from Property file
|
// Get Input Stream from Property file
|
||||||
FileInputStream fin=null;
|
FileInputStream fin=null;
|
||||||
try {
|
try {
|
||||||
fin = new FileInputStream(PROPERTYFILE);
|
fin = new FileInputStream("./" + PROPERTYFILE);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println ("Security Exception:Could not create stream for file " + PROPERTYFILE);
|
System.out.println ("Security Exception:Could not create stream for file " + PROPERTYFILE);
|
||||||
return;
|
return;
|
||||||
|
@ -233,6 +317,7 @@ public class TestLoader
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -267,7 +352,6 @@ public class TestLoader
|
||||||
*/
|
*/
|
||||||
public static void logPrint(String msg)
|
public static void logPrint(String msg)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (msg == null) return;
|
if (msg == null) return;
|
||||||
|
|
||||||
String logDir = propTable.getProperty("BW_LOGDIR");
|
String logDir = propTable.getProperty("BW_LOGDIR");
|
||||||
|
@ -276,8 +360,7 @@ public class TestLoader
|
||||||
String logFile = propTable.getProperty("BW_LOGFILE");
|
String logFile = propTable.getProperty("BW_LOGFILE");
|
||||||
if (logFile == null) logFile = LOGFILE;
|
if (logFile == null) logFile = LOGFILE;
|
||||||
|
|
||||||
|
String fname = logDir + FILE_SEP + logFile;
|
||||||
String fname = logDir + SEP + logFile;
|
|
||||||
|
|
||||||
// Get Output Stream from Log file
|
// Get Output Stream from Log file
|
||||||
RandomAccessFile raf=null;
|
RandomAccessFile raf=null;
|
||||||
|
@ -322,7 +405,7 @@ public class TestLoader
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
String fname = logDir + SEP + logFile;
|
String fname = logDir + FILE_SEP + logFile;
|
||||||
|
|
||||||
File f=null;
|
File f=null;
|
||||||
try {
|
try {
|
||||||
|
@ -408,7 +491,7 @@ public class TestLoader
|
||||||
String logFile = LOGHTML;
|
String logFile = LOGHTML;
|
||||||
|
|
||||||
|
|
||||||
String fname = logDir + SEP + logFile;
|
String fname = logDir + FILE_SEP + logFile;
|
||||||
|
|
||||||
// Get Output Stream from Log file
|
// Get Output Stream from Log file
|
||||||
RandomAccessFile raf=null;
|
RandomAccessFile raf=null;
|
||||||
|
@ -465,7 +548,7 @@ public class TestLoader
|
||||||
String logFile = LOGHTML;
|
String logFile = LOGHTML;
|
||||||
|
|
||||||
|
|
||||||
String fname = logDir + SEP + logFile;
|
String fname = logDir + FILE_SEP + logFile;
|
||||||
|
|
||||||
// Get Output Stream from Log file
|
// Get Output Stream from Log file
|
||||||
RandomAccessFile raf=null;
|
RandomAccessFile raf=null;
|
||||||
|
@ -522,7 +605,7 @@ public class TestLoader
|
||||||
String logFile = TestLoader.LOGTXT;
|
String logFile = TestLoader.LOGTXT;
|
||||||
|
|
||||||
|
|
||||||
String fname = logDir + SEP + logFile;
|
String fname = logDir + FILE_SEP + logFile;
|
||||||
|
|
||||||
// Get Output Stream from Log file
|
// Get Output Stream from Log file
|
||||||
RandomAccessFile raf=null;
|
RandomAccessFile raf=null;
|
||||||
|
@ -551,4 +634,82 @@ public class TestLoader
|
||||||
return;
|
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
|
||||||
|
|
Загрузка…
Ссылка в новой задаче