curcuru 01/12/10 13:18:59
Modified: test/java/src/org/apache/qetest/xsl StylesheetTestlet.java
Added: test/java/src/org/apache/qetest/xsl CmdlineTestlet.java
MSXSLTestlet.java XalanCTestlet.java
Log:
Simplify StylesheetTestlet to use worker methods to do most of the work;
New subclasses to test various command-line based processors (XalanC/MSXSL)
Revision Changes Path
1.7 +73 -36
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.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- StylesheetTestlet.java 2001/11/02 20:47:30 1.6
+++ StylesheetTestlet.java 2001/12/10 21:18:58 1.7
@@ -65,6 +65,7 @@
import org.apache.qetest.CheckService;
import org.apache.qetest.Datalet;
import org.apache.qetest.Logger;
+import org.apache.qetest.QetestFactory;
import org.apache.qetest.QetestUtils;
import org.apache.qetest.TestletImpl;
import org.apache.qetest.xslwrapper.TransformWrapper;
@@ -79,7 +80,7 @@
/**
* Testlet for conformance testing of xsl stylesheet files.
*
- * This class provides the testing algorithim used for verifying
+ * This class provides the default 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
@@ -88,8 +89,11 @@
* flavors of TransformWrapper may be different products, as well
* as different processing models, like SAX, DOM or Streams).
*
+ * This class is broken up into common worker methods to make
+ * subclassing easier for alternate testing algoritims.
+ *
* @author [EMAIL PROTECTED]
- * @version $Id: StylesheetTestlet.java,v 1.6 2001/11/02 20:47:30 curcuru
Exp $
+ * @version $Id: StylesheetTestlet.java,v 1.7 2001/12/10 21:18:58 curcuru
Exp $
*/
public class StylesheetTestlet extends TestletImpl
{
@@ -117,6 +121,7 @@
*/
public void execute(Datalet d)
{
+ // Ensure we have the correct kind of datalet
StylesheetDatalet datalet = null;
try
{
@@ -127,6 +132,35 @@
logger.checkErr("Datalet provided is not a StylesheetDatalet;
cannot continue with " + d);
return;
}
+
+ // Perform any other general setup needed
+ testletInit(datalet);
+ try
+ {
+ // Get a TransformWrapper of the appropriate flavor
+ TransformWrapper transformWrapper = getTransformWrapper(datalet);
+ // Transform our supplied input file...
+ testDatalet(datalet, transformWrapper);
+ transformWrapper = null;
+ // ...and compare with gold data
+ checkDatalet(datalet);
+ }
+ // Handle any exceptions from the testing
+ catch (Throwable t)
+ {
+ handleException(datalet, t);
+ return;
+ }
+ }
+
+
+ /**
+ * Worker method to perform any pre-processing needed.
+ *
+ * @param datalet to test with
+ */
+ protected void testletInit(StylesheetDatalet datalet)
+ {
//@todo validate our Datalet - ensure it has valid
// and/or existing files available.
@@ -145,15 +179,19 @@
{
logger.logMsg(Logger.WARNINGMSG, "Deleting OutFile of::" +
datalet.outputName
+ " threw: " + se.toString());
- // But continue anyways...
}
}
+ }
- // 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
+
+ /**
+ * Worker method to get a TransformWrapper.
+ *
+ * @param datalet to test with
+ * @return TransformWrapper to use with this datalet
+ */
+ protected TransformWrapper getTransformWrapper(StylesheetDatalet datalet)
+ {
TransformWrapper transformWrapper = null;
try
{
@@ -169,28 +207,16 @@
{
logger.logThrowable(Logger.ERRORMSG, t, getDescription() + "
newWrapper/newProcessor threw");
logger.checkErr(getDescription() + " newWrapper/newProcessor
threw: " + t.toString());
- return;
- }
-
- // Transform our supplied input file, and compare with gold
- try
- {
- testDatalet(datalet, transformWrapper);
- }
- // Handle any exceptions from the testing
- catch (Throwable t)
- {
- handleException(datalet, t);
- return;
+ return null;
}
- }
+ return transformWrapper;
+ }
/**
* Worker method to actually perform the transform.
*
- * Logs out applicable info; attempts to perform transformation;
- * and if sucessful, validates output file.
+ * Logs out applicable info; attempts to perform transformation.
*
* @param datalet to test with
* @param transformWrapper to have perform the transform
@@ -220,18 +246,31 @@
long[] times = transformWrapper.transform(datalet.xmlName,
datalet.inputName, datalet.outputName);
retVal = times[TransformWrapper.IDX_OVERALL];
}
+ }
+
- // If we get here, attempt to validate the contents of
- // the last outputFile created
+ /**
+ * Worker method to validate output file with gold.
+ *
+ * Logs out applicable info while validating output file.
+ *
+ * @param datalet to test with
+ * @throws allows any underlying exception to be thrown
+ */
+ protected void checkDatalet(StylesheetDatalet datalet)
+ throws Exception
+ {
+ // See if the datalet already has a fileChecker to use...
CheckService fileChecker =
(CheckService)datalet.options.get("fileCheckerImpl");
- // Supply default value
+ // ...if not, construct a default one with attributes
if (null == fileChecker)
- fileChecker = new XHTFileCheckService();
- // Apply any testing options to the fileChecker
- // Note: for the overall conformance test case, this is
- // a bit inefficient, but we don't necessarily know if
- // the checkService has already been setup or not
- fileChecker.applyAttributes(datalet.options);
+ {
+ fileChecker = QetestFactory.newCheckService(logger,
QetestFactory.TYPE_FILES);
+ // Apply any testing options to the fileChecker
+ fileChecker.applyAttributes(datalet.options);
+ }
+
+ // Validate the file
if (Logger.PASS_RESULT
!= fileChecker.check(logger,
new File(datalet.outputName),
@@ -250,8 +289,6 @@
attrs.put("outputName", datalet.outputName);
attrs.put("goldName", datalet.goldName);
logger.logElement(Logger.STATUSMSG, "fileref", attrs,
"Conformance test file references");
- // No longer need to log failure reason, this kind
- // of functionality should be kept in checkServices
}
}
@@ -270,7 +307,7 @@
// Put the logThrowable first, so it appears before
// the Fail record, and gets color-coded
logger.logThrowable(Logger.ERRORMSG, t, getDescription() + " " +
datalet.getDescription());
- logger.checkFail(getDescription() + " " + datalet.getDescription()
+ logger.checkErr(getDescription() + " " + datalet.getDescription()
+ " threw: " + t.toString());
}
} // end of class StylesheetTestlet
1.1
xml-xalan/test/java/src/org/apache/qetest/xsl/CmdlineTestlet.java
Index: CmdlineTestlet.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 2000, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
*
* CmdlineTestlet.java
*
*/
package org.apache.qetest.xsl;
import org.apache.qetest.CheckService;
import org.apache.qetest.Datalet;
import org.apache.qetest.Logger;
import org.apache.qetest.QetestFactory;
import org.apache.qetest.QetestUtils;
import org.apache.qetest.TestletImpl;
import org.apache.qetest.ThreadedStreamReader;
import org.apache.qetest.xslwrapper.TransformWrapper;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Hashtable;
/**
* Testlet for conformance testing of xsl stylesheet files using
* a command line interface instead of a TransformWrapper.
*
* This class provides a default algorithim for testing XSLT
* processsors from the command line. Subclasses define the
* exact command line args, etc. used for different products.
*
* @author [EMAIL PROTECTED]
* @version $Id: CmdlineTestlet.java,v 1.1 2001/12/10 21:18:58 curcuru Exp $
*/
public class CmdlineTestlet extends StylesheetTestlet
{
// Initialize our classname for TestletImpl's main() method
static { thisClassName = "org.apache.qetest.xsl.CmdlineTestlet"; }
// Initialize our defaultDatalet
{ defaultDatalet = (Datalet)new StylesheetDatalet(); }
/**
* Accesor method for a brief description of this test.
*
* @return String describing what this CmdlineTestlet does.
*/
public String getDescription()
{
return "CmdlineTestlet";
}
/**
* Parameter: Actual name of external program to call.
*/
public static final String OPT_PROGNAME = "progName";
/**
* Default Actual name of external program to call.
* @return TestXSLT, the Xalan-C command line.
*/
public String getDefaultProgName()
{
return "TestXSLT";
}
/**
* Path to external program to call; default is none.
*/
public static final String OPT_PROGPATH = "progPath";
/**
* Worker method to actually perform the transform;
* overriden to use command line processing.
*
* Logs out applicable info; attempts to perform transformation.
*
* @param datalet to test with
* @param transformWrapper to have perform the transform
* @throws allows any underlying exception to be thrown
*/
protected void testDatalet(StylesheetDatalet datalet, TransformWrapper
transformWrapper)
throws Exception
{
String[] defaultArgs = new String[0]; // Currently unused
String[] args = getProgramArguments(datalet, defaultArgs);
StringBuffer argBuf = new StringBuffer();
for (int i = 0; i < args.length; i++)
{
argBuf.append(args[i]);
}
//@todo Should we log a custom logElement here instead?
logger.logMsg(Logger.TRACEMSG, "cmdline executing with: " +
argBuf.toString());
// Declare variables ahead of time to minimize latency
long startTime = 0;
long overallTime = 0;
// Use our worker method to execute the process, which
// runs the test via the command line
startTime = System.currentTimeMillis();
execProcess(args, null);
overallTime = System.currentTimeMillis() - startTime;
}
/**
* Worker method to get list of arguments specific to this program.
*
* <p>Must be overridden for different processors, obviously.
* This implementation returns the args for Xalan-C TestXSLT</p>
*
* @param program path\name of program to Runtime.exec()
* @param defaultArgs any additional arguments to pass
* @return String array of arguments suitable to pass to
* Runtime.exec()
*/
public String[] getProgramArguments(StylesheetDatalet datalet, String[]
defaultArgs)
{
final int NUMARGS = 7;
String[] args = new String[defaultArgs.length + NUMARGS];
String progName = datalet.options.getProperty(OPT_PROGNAME,
getDefaultProgName());
String progPath = datalet.options.getProperty(OPT_PROGPATH);
if ((null != progPath) && (progPath.length() > 0))
{
args[0] = progPath + File.separator + progName;
}
else
{
// Pesume the program is on the PATH already...
args[0] = progName;
}
// Default args for Xalan-C TestXSLT
args[1] = "-in";
args[2] = datalet.xmlName;
args[3] = "-xsl";
args[4] = datalet.inputName;
args[5] = "-out";
args[6] = datalet.outputName;
if (defaultArgs.length > 0)
System.arraycopy(defaultArgs, 0, args, NUMARGS,
defaultArgs.length);
return args;
}
/**
* Worker method to shell out an external process.
*
* <p>Does a simple capturing of the out and err streams from
* the process and logs them out. Inherits the same environment
* that the current JVM is in.</p>
*
* @param cmdline actual command line to run, including program name
* @param environment passed as-is to Process.run
* @return return value from program
* @exception Exception may be thrown by Runtime.exec
*/
public void execProcess(String[] cmdline, String[] environment)
throws Exception
{
if ((cmdline == null) || (cmdline.length < 1))
{
logger.checkFail("execProcess called with null/blank arguments!");
return;
}
int bufSize = 2048; // Arbitrary bufSize seems to work well
ThreadedStreamReader outReader = new ThreadedStreamReader();
ThreadedStreamReader errReader = new ThreadedStreamReader();
Runtime r = Runtime.getRuntime();
java.lang.Process proc = null; // Fully declare to not conflict with
org.apache.xalan.xslt.Process
// Actually begin executing the program
logger.logMsg(Logger.TRACEMSG, "execProcess starting " + cmdline[0]);
proc = r.exec(cmdline, environment);
// Immediately begin capturing any output therefrom
outReader.setInputStream(
new BufferedReader(
new InputStreamReader(proc.getInputStream()), bufSize));
errReader.setInputStream(
new BufferedReader(
new InputStreamReader(proc.getErrorStream()), bufSize));
// Start two threads off on reading the System.out and System.err
from proc
outReader.start();
errReader.start();
int processReturnVal = -2; // HACK the default
try
{
// Wait for the process to exit normally
processReturnVal = proc.waitFor();
}
catch (InterruptedException ie1)
{
logger.logThrowable(Logger.ERRORMSG, ie1,
"execProcess proc.waitFor() threw");
}
// Now that we're done, presumably the Readers are also done
StringBuffer sysOut = null;
StringBuffer sysErr = null;
try
{
outReader.join();
sysOut = outReader.getBuffer();
}
catch (InterruptedException ie2)
{
logger.logThrowable(Logger.ERRORMSG, ie2, "Joining outReader
threw");
}
try
{
errReader.join();
sysErr = errReader.getBuffer();
}
catch (InterruptedException ie3)
{
logger.logThrowable(Logger.ERRORMSG, ie3, "Joining errReader
threw");
}
checkOutputStreams(cmdline, sysOut, sysErr, processReturnVal);
}
/**
* Worker method to evaluate the System.out/.err streams of
* a particular processor.
*
* @param cmdline that was used for execProcess
* @param outBuf buffer from execProcess' System.out
* @param errBuf buffer from execProcess' System.err
* @param processReturnVal from execProcess
*/
protected void checkOutputStreams(String[] cmdline, StringBuffer outBuf,
StringBuffer errBuf, int processReturnVal)
{
Hashtable attrs = new Hashtable();
attrs.put("program", cmdline[0]);
attrs.put("returnVal", String.valueOf(processReturnVal));
StringBuffer buf = new StringBuffer();
if ((null != errBuf) && (errBuf.length() > 0))
{
buf.append("<system-err>");
buf.append(errBuf);
buf.append("</system-err>\n");
}
if ((null != outBuf) && (outBuf.length() > 0))
{
buf.append("<system-out>");
buf.append(outBuf);
buf.append("</system-out>\n");
}
logger.logElement(Logger.INFOMSG, "checkOutputStreams", attrs,
buf.toString());
attrs = null;
buf = null;
}
/**
* Worker method to get a TransformWrapper; overridden as no-op.
*
* @param datalet to test with
* @return null; CmdlineTestlet does not use this
*/
protected TransformWrapper getTransformWrapper(StylesheetDatalet datalet)
{
return null;
}
} // end of class CmdlineTestlet
1.1
xml-xalan/test/java/src/org/apache/qetest/xsl/MSXSLTestlet.java
Index: MSXSLTestlet.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 2000, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.qetest.xsl;
import org.apache.qetest.CheckService;
import org.apache.qetest.Datalet;
import org.apache.qetest.Logger;
import org.apache.qetest.QetestFactory;
import org.apache.qetest.QetestUtils;
import org.apache.qetest.TestletImpl;
import org.apache.qetest.ThreadedStreamReader;
import org.apache.qetest.xslwrapper.TransformWrapper;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Hashtable;
/**
* Testlet for conformance testing of xsl stylesheet files using
* the MSXSL command line instead of a TransformWrapper.
*
* @author [EMAIL PROTECTED]
* @version $Id: MSXSLTestlet.java,v 1.1 2001/12/10 21:18:58 curcuru Exp $
*/
public class MSXSLTestlet extends CmdlineTestlet
{
// Initialize our classname for TestletImpl's main() method
static { thisClassName = "org.apache.qetest.xsl.MSXSLTestlet"; }
// Initialize our defaultDatalet
{ defaultDatalet = (Datalet)new StylesheetDatalet(); }
/**
* Accesor method for a brief description of this test.
*
* @return String describing what this MSXSLTestlet does.
*/
public String getDescription()
{
return "MSXSLTestlet";
}
/**
* Default Actual name of external program to call.
* @return msxsl, the MSXSL 4.0 command line.
*/
public String getDefaultProgName()
{
return "msxsl";
}
/**
* Worker method to get list of arguments specific to this program.
*
* <p>Must be overridden for different processors, obviously.
* This implementation returns the args for Xalan-C TestXSLT</p>
*
* @param program path\name of program to Runtime.exec()
* @param defaultArgs any additional arguments to pass
* @return String array of arguments suitable to pass to
* Runtime.exec()
*/
public String[] getProgramArguments(StylesheetDatalet datalet, String[]
defaultArgs)
{
final int NUMARGS = 6;
String[] args = new String[defaultArgs.length + NUMARGS];
String progName = datalet.options.getProperty(OPT_PROGNAME,
getDefaultProgName());
String progPath = datalet.options.getProperty(OPT_PROGPATH);
if ((null != progPath) && (progPath.length() > 0))
{
args[0] = progPath + File.separator + progName;
}
else
{
// Pesume the program is on the PATH already...
args[0] = progName;
}
// Default args for MSXSL 4.0
args[1] = datalet.xmlName;
args[2] = datalet.inputName;
args[3] = "-o"; // Write output to named file
args[4] = datalet.outputName;
args[5] = "-t"; // Show load and transformation timings
if (defaultArgs.length > 0)
System.arraycopy(defaultArgs, 0, args, NUMARGS,
defaultArgs.length);
return args;
}
/**
* Worker method to evaluate the System.out/.err streams of
* a particular processor.
*
* Overridden to parse out -t timings from msxsl output.
*
* @param cmdline that was used for execProcess
* @param outBuf buffer from execProcess' System.out
* @param errBuf buffer from execProcess' System.err
* @param processReturnVal from execProcess
*/
protected void checkOutputStreams(String[] cmdline, StringBuffer outBuf,
StringBuffer errBuf, int processReturnVal)
{
Hashtable attrs = new Hashtable();
attrs.put("program", cmdline[0]);
attrs.put("returnVal", String.valueOf(processReturnVal));
StringBuffer buf = new StringBuffer();
if ((null != errBuf) && (errBuf.length() > 0))
{
buf.append("<system-err>");
buf.append(errBuf);
buf.append("</system-err>\n");
}
if ((null != outBuf) && (outBuf.length() > 0))
{
buf.append("<system-out>");
buf.append(outBuf);
buf.append("</system-out>\n");
}
logger.logElement(Logger.INFOMSG, "checkOutputStreams", attrs,
buf.toString());
attrs = null;
buf = null;
try
{
final String SOURCE_LOAD = "Source document load time:";
final String STYLESHEET_LOAD = "Stylesheet document load time:";
final String STYLESHEET_COMPILE = "Stylesheet compile time:";
final String STYLESHEET_EXECUTE = "Stylesheet execution time:";
final String MILLISECONDS = "milliseconds";
double sourceLoad;
double stylesheetLoad;
double stylesheetCompile;
double stylesheetExecute;
// Now actually parse the system-err stream for performance
// This is embarassingly messy, but I'm not investing
// more time here until I'm sure it'll be worth it
String tmp = errBuf.toString();
String ms = null;
int tmpIdx = 0;
// Advance to source loading time
tmp = tmp.substring(tmp.indexOf(SOURCE_LOAD) +
SOURCE_LOAD.length());
// Time is spaces & numbers up to the 'milliseconds' marker
ms = tmp.substring(0, tmp.indexOf(MILLISECONDS)).trim();
sourceLoad = Double.parseDouble(ms);
// Advance to stylesheet loading time
tmp = tmp.substring(tmp.indexOf(STYLESHEET_LOAD) +
STYLESHEET_LOAD.length());
// Time is spaces & numbers up to the 'milliseconds' marker
ms = tmp.substring(0, tmp.indexOf(MILLISECONDS)).trim();
stylesheetLoad = Double.parseDouble(ms);
// Advance to stylesheet compile time
tmp = tmp.substring(tmp.indexOf(STYLESHEET_COMPILE) +
STYLESHEET_COMPILE.length());
// Time is spaces & numbers up to the 'milliseconds' marker
ms = tmp.substring(0, tmp.indexOf(MILLISECONDS)).trim();
stylesheetCompile = Double.parseDouble(ms);
// Advance to stylesheet execute time
tmp = tmp.substring(tmp.indexOf(STYLESHEET_EXECUTE) +
STYLESHEET_EXECUTE.length());
// Time is spaces & numbers up to the 'milliseconds' marker
ms = tmp.substring(0, tmp.indexOf(MILLISECONDS)).trim();
stylesheetExecute = Double.parseDouble(ms);
// Log out approximate timing data
// Log special performance element with our timing
attrs = new Hashtable();
// UniqRunid is an Id that our TestDriver normally sets
// with some unique code, so that results analysis
// stylesheets can compare different test runs
attrs.put("UniqRunid", "runId;notImplemented-MSXSLTestlet");
// processor is the 'flavor' of processor we're testing
attrs.put("processor", getDescription());
// idref is the individual filename
attrs.put("idref", (new File(cmdline[2])).getName());
// inputName is the actual name we gave to the processor
attrs.put("inputName", cmdline[2]);
attrs.put("iterations", new Integer(1));
attrs.put("sourceLoad", new Double(sourceLoad));
attrs.put("stylesheetLoad", new Double(stylesheetLoad));
attrs.put("stylesheetCompile", new Double(stylesheetCompile));
attrs.put("stylesheetExecute", new Double(stylesheetExecute));
logger.logElement(Logger.STATUSMSG, "perf", attrs, "PItr;");
}
catch (Exception e)
{
logger.logThrowable(Logger.WARNINGMSG, e, "checkOutputStreams
threw");
}
}
} // end of class MSXSLTestlet
1.1
xml-xalan/test/java/src/org/apache/qetest/xsl/XalanCTestlet.java
Index: XalanCTestlet.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 2000, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.qetest.xsl;
import org.apache.qetest.Datalet;
import org.apache.qetest.Logger;
/**
* Testlet for conformance testing of xsl stylesheet files using
* XalanC commandline instead of a TransformWrapper.
*
* Note: this class simply uses CmdlineTestlet's implementation.
*
* @author [EMAIL PROTECTED]
* @version $Id: XalanCTestlet.java,v 1.1 2001/12/10 21:18:58 curcuru Exp $
*/
public class XalanCTestlet extends CmdlineTestlet
{
// Initialize our classname for TestletImpl's main() method
static { thisClassName = "org.apache.qetest.xsl.XalanCTestlet"; }
// Initialize our defaultDatalet
{ defaultDatalet = (Datalet)new StylesheetDatalet(); }
/**
* Accesor method for a brief description of this test.
* @return String describing what this XalanCTestlet does.
*/
public String getDescription()
{
return "XalanCTestlet";
}
} // end of class XalanCTestlet
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]