curcuru 01/03/16 09:00:19
Modified: test/java/src/org/apache/qetest/xsl StylesheetTestlet.java
StylesheetTestletDriver.java
Log:
Update to use new TransformWrapper implementations; update logging
Revision Changes Path
1.2 +79 -64
xml-xalan/test/java/src/org/apache/qetest/xsl/StylesheetTestlet.java
Index: StylesheetTestlet.java
===================================================================
RCS file:
/home/cvs/xml-xalan/test/java/src/org/apache/qetest/xsl/StylesheetTestlet.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- StylesheetTestlet.java 2001/02/23 21:04:45 1.1
+++ StylesheetTestlet.java 2001/03/16 17:00:18 1.2
@@ -67,7 +67,8 @@
import org.apache.qetest.Logger;
import org.apache.qetest.QetestUtils;
import org.apache.qetest.TestletImpl;
-import org.apache.qetest.xslwrapper.ProcessorWrapper;
+import org.apache.qetest.xslwrapper.TransformWrapper;
+import org.apache.qetest.xslwrapper.TransformWrapperFactory;
import java.io.File;
import java.io.FileNotFoundException;
@@ -78,8 +79,17 @@
/**
* Testlet for conformance testing of xsl stylesheet files.
*
+ * This class provides the testing algorithim used for verifying
+ * Xalan's conformance to the XSLT spec. It works in conjunction
+ * with StylesheetTestletDriver, which supplies the logic for
+ * choosing the testfiles to iterate over, and with
+ * TransformWrapper, which provides an XSL processor- and
+ * method-independent way to process files (i.e. different
+ * flavors of TransformWrapper may be different products, as well
+ * as different processing models, like SAX, DOM or Streams).
+ *
* @author [EMAIL PROTECTED]
- * @version $Id: StylesheetTestlet.java,v 1.1 2001/02/23 21:04:45 curcuru
Exp $
+ * @version $Id: StylesheetTestlet.java,v 1.2 2001/03/16 17:00:18 curcuru
Exp $
*/
public class StylesheetTestlet extends TestletImpl
{
@@ -114,43 +124,57 @@
}
catch (ClassCastException e)
{
- logger.checkErr("Datalet provided is not a StylesheetDatalet;
cannot continue");
+ logger.checkErr("Datalet provided is not a StylesheetDatalet;
cannot continue with " + d);
return;
}
-
+
+ logger.logMsg(Logger.STATUSMSG, "About to test: "
+ + (null == datalet.inputName
+ ? datalet.xmlName
+ : datalet.inputName));
//@todo validate our Datalet - ensure it has valid
// and/or existing files available.
+
+ // Cleanup outName only if asked to - delete the file on disk
+ // Optimization: this takes extra time and often is not
+ // needed, so only do this if the option is set
+ if
("true".equalsIgnoreCase(datalet.options.getProperty("deleteOutFile")))
+ {
+ try
+ {
+ boolean btmp = (new File(datalet.outputName)).delete();
+ logger.logMsg(Logger.TRACEMSG, "Deleting OutFile of::" +
datalet.outputName
+ + " status: " + btmp);
+ }
+ catch (SecurityException se)
+ {
+ logger.logMsg(Logger.WARNINGMSG, "Deleting OutFile of::" +
datalet.outputName
+ + " threw: " + se.toString());
+ // But continue anyways...
+ }
+ }
- // Cleanup outputName - delete the file on disk
- // Ensure other files or previous test runs don't
- // interfere with our results
+ // Create a new TransformWrapper of appropriate flavor
+ // null arg is unused liaison for TransformWrapper
+ //@todo allow user to pass in pre-created
+ // TransformWrapper so we don't have lots of objects
+ // created and destroyed for every file
+ TransformWrapper transformWrapper = null;
try
{
- File outFile = new File(datalet.outputName);
- boolean btmp = outFile.delete();
+ transformWrapper =
TransformWrapperFactory.newWrapper(datalet.flavor);
+ transformWrapper.newProcessor(null);
}
- catch (SecurityException se)
+ catch (Throwable t)
{
- logger.logMsg(Logger.WARNINGMSG, "Deleting OutFile of:" +
datalet.outputName
- + " threw: " + se.toString());
- // But continue anyways...
+ logThrowable(t, getDescription() + " newWrapper/newProcessor
threw");
+ logger.checkErr(getDescription() + " newWrapper/newProcessor
threw: " + t.toString());
+ return;
}
// Test our supplied input file, and compare with gold
try
{
- // Create a new ProcessorWrapper of appropriate flavor
- // null arg is unused liaison for ProcessorWrapper
- //@todo allow user to pass in pre-created
- // ProcessorWrapper so we don't have lots of objects
- // created and destroyed for every file
- ProcessorWrapper processorWrapper =
ProcessorWrapper.getWrapper(datalet.flavor);
- if (null == processorWrapper.createNewProcessor(null))
- {
- logger.checkErr("ERROR: could not create processorWrapper,
aborting.");
- return;
- }
-
// Store local copies of XSL, XML references for
// potential change to URLs
String inputName = datalet.inputName;
@@ -163,7 +187,7 @@
xmlName = QetestUtils.filenameToURL(xmlName);
}
- //@todo do we really want to log all of this out here?
+ //@todo Should we log a custom logElement here instead?
logger.logMsg(Logger.TRACEMSG, "executing with: inputName=" +
inputName
+ " xmlName=" + xmlName + " outputName=" +
datalet.outputName
+ " goldName=" + datalet.goldName + " flavor=" +
datalet.flavor);
@@ -171,53 +195,32 @@
// Simply have the wrapper do all the transforming
// or processing for us - we handle either normal .xsl
// stylesheet tests or just .xml embedded tests
- long retVal = ProcessorWrapper.ERROR;
+ long retVal = 0L;
if (null == datalet.inputName)
{
// presume it's an embedded test
- retVal = processorWrapper.processEmbeddedToFile(xmlName,
datalet.outputName);
+ long [] times = transformWrapper.transformEmbedded(xmlName,
datalet.outputName);
+ retVal = times[TransformWrapper.IDX_OVERALL];
}
else
{
// presume it's a normal stylesheet test
- retVal = processorWrapper.processToFile(xmlName, inputName,
datalet.outputName);
+ long[] times = transformWrapper.transform(xmlName,
inputName, datalet.outputName);
+ retVal = times[TransformWrapper.IDX_OVERALL];
}
-
- if (ProcessorWrapper.ERROR == retVal)
- {
- //@todo Should validate potential expectedExceptions here
- logger.checkFail(getDescription() + " " +
datalet.getDescription()
- + "unexpected processToFile problem");
-
- return;
- }
- //@todo report out timing data for overall use?
- }
- catch (FileNotFoundException fnfe)
- {
- logger.checkFail(getDescription() + " " +
datalet.getDescription()
- + " threw: " + fnfe.toString());
- // Don't bother logging the stacktrace here; not worth it
- return;
- }
- catch (Throwable t)
- {
- logger.checkFail(getDescription() + " " +
datalet.getDescription()
- + " threw: " + t.toString());
- logThrowable(t, getDescription() + " " +
datalet.getDescription());
- return;
- }
- // If we get here, attempt to validate the contents of
- // the last outputFile created
- //@todo allow passing in of preexisting checkService
- CheckService fileChecker = new XHTFileCheckService();
- if (Logger.PASS_RESULT
- != fileChecker.check(logger,
- new File(datalet.outputName),
- new File(datalet.goldName),
- getDescription() + " " +
datalet.getDescription())
- )
+ // If we get here, attempt to validate the contents of
+ // the last outputFile created
+ CheckService fileChecker =
(CheckService)datalet.options.get("fileCheckerImpl");
+ // Supply default value
+ if (null == fileChecker)
+ fileChecker = new XHTFileCheckService();
+ if (Logger.PASS_RESULT
+ != fileChecker.check(logger,
+ new File(datalet.outputName),
+ new File(datalet.goldName),
+ getDescription() + " " +
datalet.getDescription())
+ )
{
// Log a custom element with all the file refs first
// Closely related to viewResults.xsl select='fileref"
@@ -234,6 +237,18 @@
logger.logArbitrary(Logger.STATUSMSG, (new
File(datalet.inputName)).getName()
+ " failure reason: " +
fileChecker.getExtendedInfo());
}
+ }
+ // Note that this class can only validate positive test
+ // cases - we don't handle ExpectedExceptions
+ catch (Throwable t)
+ {
+ // Put the logThrowable first, so it appears before
+ // the Fail record, and gets color-coded
+ logThrowable(t, getDescription() + " " +
datalet.getDescription());
+ logger.checkFail(getDescription() + " " +
datalet.getDescription()
+ + " threw: " + t.toString());
+ return;
+ }
}
1.4 +17 -11
xml-xalan/test/java/src/org/apache/qetest/xsl/StylesheetTestletDriver.java
Index: StylesheetTestletDriver.java
===================================================================
RCS file:
/home/cvs/xml-xalan/test/java/src/org/apache/qetest/xsl/StylesheetTestletDriver.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- StylesheetTestletDriver.java 2001/03/13 00:47:16 1.3
+++ StylesheetTestletDriver.java 2001/03/16 17:00:18 1.4
@@ -64,7 +64,7 @@
// Support for test reporting and harness classes
import org.apache.qetest.*;
-import org.apache.qetest.xslwrapper.ProcessorWrapper;
+import org.apache.qetest.xslwrapper.TransformWrapperFactory;
// java classes
import java.io.BufferedReader;
@@ -92,7 +92,7 @@
* would be a good model for a completely generic TestletDriver.
*
* @author [EMAIL PROTECTED]
- * @version $Id: StylesheetTestletDriver.java,v 1.3 2001/03/13 00:47:16
curcuru Exp $
+ * @version $Id: StylesheetTestletDriver.java,v 1.4 2001/03/16 17:00:18
curcuru Exp $
*/
public class StylesheetTestletDriver extends XSLProcessorTestBase
{
@@ -184,10 +184,11 @@
{
// Copy any of our parameters from testProps to
// our local convenience variables
- testlet = testProps.getProperty(OPT_TESTLET);
- dirFilter = testProps.getProperty(OPT_DIRFILTER);
- fileFilter = testProps.getProperty(OPT_FILEFILTER);
- fileList = testProps.getProperty(OPT_FILELIST);
+ testlet = testProps.getProperty(OPT_TESTLET, testlet);
+ dirFilter = testProps.getProperty(OPT_DIRFILTER, dirFilter);
+ fileFilter = testProps.getProperty(OPT_FILEFILTER, fileFilter);
+ fileList = testProps.getProperty(OPT_FILELIST, fileList);
+ flavor = testProps.getProperty(OPT_FLAVOR, flavor);
// Grab a unique runid for logging out with our tests
// Used in results reporting stylesheets to differentiate
@@ -213,13 +214,10 @@
*/
public boolean runTestCases(Properties p)
{
-
-
// First log out any other runtime information, like the
// actual flavor of ProcessorWrapper, etc.
try
{
- Hashtable runtimeProps = new Hashtable(4);
// Note that each of these calls actually force the
// creation of an actual object of each type: this is
// required since we may default the types or our call
@@ -227,8 +225,9 @@
// different classname than the user actually specified
// Care should be taken that the construction of objects
// here does not affect our testing later on
- runtimeProps.put("actual.ProcessorWrapper",
-
ProcessorWrapper.getWrapper(flavor).getDescription());
+ // Just grab all the info from the TransformWrapper...
+ Properties runtimeProps =
TransformWrapperFactory.newWrapper(flavor).getProcessorInfo();
+ // ... and add a few extra things ourselves
runtimeProps.put("actual.testlet", getTestlet());
runtimeProps.put("actual.dirFilter", getDirFilter());
runtimeProps.put("actual.fileFilter", getFileFilter());
@@ -568,12 +567,19 @@
{
// Hmmm - I'm not sure what we should do here
reporter.logWarningMsg("Unexpected test file found,
skipping: " + file);
+ continue;
}
d.setDescription(file);
+ d.flavor = flavor;
// Also copy over our own testProps as it's
// options: this allows for future expansion
// of values in the datalet
d.options = new Properties(testProps);
+ // Optimization: put in a copy of our fileChecker, so
+ // that each testlet doesn't have to create it's own
+ // fileCheckers should not store state, so this
+ // shouldn't affect the testing at all
+ d.options.put("fileCheckerImpl", fileChecker);
v.addElement(d);
}
return v;
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]