You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by cu...@apache.org on 2002/07/13 01:31:46 UTC
cvs commit: xml-xalan/test/java/src/org/apache/qetest/xsl BugzillaTestletDriver.java StylesheetTestletDriver.java XSLProcessorTestBase.java
curcuru 2002/07/12 16:31:46
Modified: test/java/src/org/apache/qetest/xsl
BugzillaTestletDriver.java
StylesheetTestletDriver.java
XSLProcessorTestBase.java
Log:
Code simplification: continued; updates as per FileBasedTest or
FileTestletDriver
Prepare for removal of XSLProcessorTestBase file
Revision Changes Path
1.4 +3 -2 xml-xalan/test/java/src/org/apache/qetest/xsl/BugzillaTestletDriver.java
Index: BugzillaTestletDriver.java
===================================================================
RCS file: /home/cvs/xml-xalan/test/java/src/org/apache/qetest/xsl/BugzillaTestletDriver.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- BugzillaTestletDriver.java 12 Feb 2002 17:59:18 -0000 1.3
+++ BugzillaTestletDriver.java 12 Jul 2002 23:31:45 -0000 1.4
@@ -485,6 +485,7 @@
try
{
// Create it, optionally with a category
+ String excludes = testProps.getProperty(OPT_EXCLUDES);
if ((null != excludes) && (excludes.length() > 1)) // Arbitrary check for non-null, non-blank string
{
Class[] parameterTypes = { java.lang.String.class };
@@ -523,7 +524,7 @@
*/
public String usage()
{
- return ("Common [optional] options supported by BugzillaTestletDriver:\n"
+ return ("Additional options supported by BugzillaTestletDriver:\n"
+ " (Note: assumes inputDir=test/tests/bugzilla)"
+ " (Note: we do *not* support -embedded)"
+ super.usage()); // Grab our parent classes usage as well
1.7 +34 -5 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.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- StylesheetTestletDriver.java 26 Mar 2002 15:36:55 -0000 1.6
+++ StylesheetTestletDriver.java 12 Jul 2002 23:31:45 -0000 1.7
@@ -145,6 +145,28 @@
protected String fileFilter = null;
+ /**
+ * Parameter: What flavor of TransformWrapper to use: trax.sax|trax.stream|other?
+ * <p>Default: trax.</p>
+ */
+ public static final String OPT_FLAVOR = "flavor";
+
+ /** Parameter: What flavor of TransformWrapper to use: trax.sax|trax.stream|other? */
+ protected String flavor = "trax";
+
+
+ /**
+ * Parameter: Are there any embedded stylesheets in XML files?
+ * <p>Default: null (no embedded tests; otherwise specify
+ * semicolon delimited list of bare filenames something like
+ * 'axes02.xml;bool98.xml').</p>
+ */
+ public static final String OPT_EMBEDDED = "embedded";
+
+ /** Parameter: Are there any embedded stylesheets in XML files? */
+ protected String embedded = null;
+
+
/** Unique runId for each specific invocation of this test driver. */
protected String runId = null;
@@ -182,6 +204,7 @@
fileFilter = testProps.getProperty(OPT_FILEFILTER, fileFilter);
fileList = testProps.getProperty(OPT_FILELIST, fileList);
flavor = testProps.getProperty(OPT_FLAVOR, flavor);
+ embedded = testProps.getProperty(OPT_EMBEDDED, embedded);
// Grab a unique runid for logging out with our tests
// Used in results reporting stylesheets to differentiate
@@ -715,6 +738,7 @@
try
{
// Create it, optionally with a category
+ String category = testProps.getProperty(OPT_CATEGORY);
if ((null != category) && (category.length() > 1)) // Arbitrary check for non-null, non-blank string
{
Class[] parameterTypes = { java.lang.String.class };
@@ -751,6 +775,7 @@
try
{
// Create it, optionally with excludes
+ String excludes = testProps.getProperty(OPT_EXCLUDES);
if ((null != excludes) && (excludes.length() > 1)) // Arbitrary check for non-null, non-blank string
{
Class[] parameterTypes = { java.lang.String.class };
@@ -789,15 +814,19 @@
*/
public String usage()
{
- return ("Common [optional] options supported by StylesheetTestletDriver:\n"
+ return ("Additional options supported by StylesheetTestletDriver:\n"
+ " -" + OPT_FILELIST
- + " <name of listfile of tests to run>\n"
+ + " <name of listfile of tests to run>\n"
+ " -" + OPT_DIRFILTER
+ " <classname of FilenameFilter for dirs>\n"
+ " -" + OPT_FILEFILTER
- + " <classname of FilenameFilter for files>\n"
+ + " <classname of FilenameFilter for files>\n"
+ " -" + OPT_TESTLET
- + " <classname of Testlet to execute tests with>\n"
+ + " <classname of Testlet to execute tests with>\n"
+ + " -" + OPT_EMBEDDED
+ + " <list;of;specific file.xml embedded tests to run>\n"
+ + " -" + OPT_FLAVOR
+ + " <trax.sax|trax.dom|etc> which TransformWrapper to use\n"
+ super.usage()); // Grab our parent classes usage as well
}
1.19 +6 -573 xml-xalan/test/java/src/org/apache/qetest/xsl/XSLProcessorTestBase.java
Index: XSLProcessorTestBase.java
===================================================================
RCS file: /home/cvs/xml-xalan/test/java/src/org/apache/qetest/xsl/XSLProcessorTestBase.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- XSLProcessorTestBase.java 9 Apr 2002 20:36:25 -0000 1.18
+++ XSLProcessorTestBase.java 12 Jul 2002 23:31:46 -0000 1.19
@@ -74,583 +74,16 @@
/**
- * Base class for all Xalan tests.
- * <p>XSLProcessorTestBase defines a number of common fields
- * that most tests will use in addition to FileBasedTest. It
- * also defaults to using an XMLFileLogger as well as a
- * ConsoleLogger, if none have been specified.</p>
- * <ul>initializes all members from FileBasedTest, plus
- * <li>category</li>
- * <li>excludes</li>
- * <li>embedded - special case: tests with no .xsl file (embedded stylesheets)</li>
- * <li>liaison</li>
- * <li>flavor</li>
- * <li>runErr</li>
- * </ul>
+ * Base class for all Xalan tests (TO BE SUPERCEDED SOON!).
+ * <p>XSLProcessorTestBase will soon be replaced by functionality
+ * in FileBasedTest and/or in StylesheetTestletDriver, depending
+ * in the kind of test it is.</p>
* @author Shane_Curcuru@lotus.com
* @version $Id$
*/
public class XSLProcessorTestBase extends FileBasedTest
{
+ /* no-op: class to be removed */
- /**
- * Convenience method to print out usage information.
- * @author Shane Curcuru
- *
- * @return String describing our usage; includes most of the
- * flags we support and our parent class' usage; note avoidance
- * of < and > for Ant and xml-based output
- */
- public String usage()
- {
-
- return ("Common options supported by XSLProcessorTestBase:\n"
- + " -" + OPT_CATEGORY
- + " (name of single subdir within testDir to run)\n"
- + " -" + OPT_EXCLUDES
- + " (list;of;specific file.xsl tests to skip)\n"
- + " -" + OPT_EMBEDDED
- + " (list;of;specific file.xml embedded tests to run)\n"
- + " -" + OPT_LIAISON
- + " (liaisonClassName)\n"
- + " -" + OPT_FLAVOR
- + " (xalan|lotusxsl|xt|etc...) which kind of Processor to test\n"
- + " -" + OPT_NOERRTEST
- + " will skip running 'err' tests, if applicable\n"
- + super.usage());
- }
-
- //-----------------------------------------------------
- //-------- Constants for common input params --------
- //-----------------------------------------------------
-
- /**
- * Parameter: Only run a single subcategory of the tests.
- * <p>Default: blank, runs all tests - supply the directory name
- * of a subcategory to run just that set.</p>
- */
- public static final String OPT_CATEGORY = "category";
-
- /** Parameter: Only run a single subcategory of the tests. */
- protected String category = null;
-
- /**
- * Parameter: What parser liaison or option to use?
- * <p>Default: null, Whichever default your processor uses.</p>
- */
- public static final String OPT_LIAISON = "liaison";
-
- /** Parameter: What parser liaison or option to use?. */
- protected String liaison = null;
-
- /**
- * Parameter: What flavor of ProcessorWrapper to use: trax|xalan1|other?
- * <p>Default: trax.</p>
- */
- public static final String OPT_FLAVOR = "flavor";
-
- /** Parameter: What flavor of ProcessorWrapper to use: trax|xalan1|other? */
- protected String flavor = "trax";
-
- /**
- * Parameter: Should we run any 'err' subdir tests or not?
- * <p>Default: false (i.e. <b>do</B> run error tests by default).</p>
- * <p>Should be deprecated, I think: don't try to run both
- * positive and negative tests together, do them separately.
- * -sc 21-Mar-01</p>
- */
- public static final String OPT_NOERRTEST = "noErrTest";
-
- /** Parameter: Should we run any 'err' subdir tests or not? */
- protected boolean noErrTest = false;
-
- /**
- * Parameter: Which CheckService should we use for XML output Files?
- * <p>Default: org.apache.qetest.XHTFileCheckService.</p>
- */
- public static final String OPT_FILECHECKER = "fileChecker";
-
- /** Parameter: Which CheckService should we use for XML output Files? */
- protected String fileCheckerName =
- "org.apache.qetest.xsl.XHTFileCheckService";
-
- /** FileChecker instance for use by subclasses; created in preTestFileInit() */
- protected CheckService fileChecker = null;
-
- /**
- * Parameter: Should we exclude any specific test files?
- * <p>Default: null (no excludes; otherwise specify
- * semicolon delimited list of bare filenames something like
- * 'axes01.xsl;bool99.xsl').</p>
- */
- public static final String OPT_EXCLUDES = "excludes";
-
- /** Parameter: Should we exclude any specific test files? */
- protected String excludes = null;
-
- /**
- * Parameter: Are there any embedded stylesheets in XML files?
- * <p>Default: null (no embedded tests; otherwise specify
- * semicolon delimited list of bare filenames something like
- * 'axes02.xml;bool98.xml').</p>
- */
- public static final String OPT_EMBEDDED = "embedded";
-
- /** Parameter: Are there any embedded stylesheets in XML files? */
- protected String embedded = null;
-
- /**
- * Default constructor - initialize testName, Comment.
- */
- public XSLProcessorTestBase()
- {
-
- // Only set them if they're not set
- if (testName == null)
- testName = "XSLProcessorTestBase.defaultName";
-
- if (testComment == null)
- testComment = "XSLProcessorTestBase.defaultComment";
- }
-
- //-----------------------------------------------------
- //-------- Implement Test/TestImpl methods --------
- //----------------------------------------------------
-
- /**
- * Initialize this test - called once before running testcases.
- * <p>We auto-create a reporter and some loggers: if logFile is
- * set, we add an XMLFileLogger, and we usually add a
- * ConsoleLogger. We also create a fileChecker for later use.</p>
- * // REFACTOR: should call QetestFactory.newReporter(...) instead.
- * @author Shane_Curcuru@lotus.com
- *
- * @param p unused
- *
- * @return true always
- */
- public boolean preTestFileInit(Properties p)
- {
-
- // Ensure we have an XMLFileLogger if we have a logName
- String logF = testProps.getProperty(Logger.OPT_LOGFILE);
-
- if ((logF != null) && (!logF.equals("")))
- {
-
- // We should ensure there's an XMLFileReporter
- String r = testProps.getProperty(Reporter.OPT_LOGGERS);
-
- if (r == null)
- {
- testProps.put(Reporter.OPT_LOGGERS,
- "org.apache.qetest.XMLFileLogger");
- }
- else if (r.indexOf("XMLFileLogger") <= 0)
- {
- testProps.put(Reporter.OPT_LOGGERS,
- r + Reporter.LOGGER_SEPARATOR
- + "org.apache.qetest.XMLFileLogger");
- }
- }
-
- // Ensure we have a ConsoleLogger unless asked not to
- // @todo improve and document this feature
- String noDefault = testProps.getProperty("noDefaultReporter");
-
- if (noDefault == null)
- {
-
- // We should ensure there's an XMLFileReporter
- String r = testProps.getProperty(Reporter.OPT_LOGGERS);
-
- if (r == null)
- {
- testProps.put(Reporter.OPT_LOGGERS,
- "org.apache.qetest.ConsoleLogger");
- }
- else if (r.indexOf("ConsoleLogger") <= 0)
- {
- testProps.put(Reporter.OPT_LOGGERS,
- r + Reporter.LOGGER_SEPARATOR
- + "org.apache.qetest.ConsoleLogger");
- }
- }
-
- // Pass our properties block directly to the reporter
- // so it can use the same values in initialization
- // A Reporter will auto-initialize from the values
- // in the properties block
- setReporter(new Reporter(testProps));
- reporter.addDefaultLogger(); // add default logger if needed
- reporter.testFileInit(testName, testComment);
-
- // Create a file-based CheckService for later use
- if (null == fileChecker)
- {
- if ((null != fileCheckerName) && (fileCheckerName.length() > 0))
- {
- // Use the user's specified class; if not available
- // will return null which gets covered below
- fileChecker = QetestFactory.newCheckService(reporter, fileCheckerName);
- }
-
- if (null == fileChecker)
- {
- // If that didn't work, then ask for default one that does files
- fileChecker = QetestFactory.newCheckService(reporter, QetestFactory.TYPE_FILES);
- }
- // If we're creating a new one, also applyAttributes
- // (Assume that if we already had one, it already had this done)
- fileChecker.applyAttributes(testProps);
- }
-
- return true;
- }
-
- /**
- * Override mostly blank routine to dump environment info.
- * <p>Log out information about our environment in a structured
- * way: mainly by calling logTestProps() here.</p>
- *
- * @param p unused
- *
- * @return true always
- */
- public boolean postTestFileInit(Properties p)
- {
- logTestProps();
- return true;
- }
-
- /**
- * Log out any version or system info.
- * <p>Logs System.getProperties(), and our the testProps block.</p>
- */
- public void logTestProps()
- {
- reporter.logHashtable(reporter.CRITICALMSG, System.getProperties(),
- "System.getProperties");
- reporter.logHashtable(reporter.CRITICALMSG, testProps, "testProps");
- reporter.logHashtable(reporter.CRITICALMSG, QetestUtils.getEnvironmentHash(), "getEnvironmentHash");
- }
-
- /**
- * Mark the test complete - called once after running testcases.
- * <p>Currently logs a summary of our test status and then tells
- * our reporter to log the testFileClose. This will calculate
- * final results, and complete logging for any structured
- * output logs (like XML files).</p>
- *
- * @param p Unused; passed through to super
- *
- * @return true if OK, false otherwise
- */
- protected boolean postTestFileClose(Properties p)
- {
- // Log out a special summary status, with marker file
- reporter.writeResultsStatus(true);
-
- // Ask our superclass to handle this as well
- return super.postTestFileClose(p);
- }
-
- // use other implementations from FileBasedTest
- //-----------------------------------------------------
- //-------- Initialize our common input params --------
- //-----------------------------------------------------
-
- /**
- * Set our instance variables from a Properties file.
- * Simply clones the Properties block into our testProps;
- * and then explicitly sets known instance variables.
- *
- * //@todo improve error checking, if needed
- * @param props Properties block to initialize our internal
- * state from: mainly our common parameters/options
- * @return status - true if OK, false if error.
- */
- public boolean initializeFromProperties(Properties props)
- {
- // Get any superclass' default processing
- boolean b = super.initializeFromProperties(props);
-
- // Copy over all properties into our local block
- // this is a little unusual, but it does allow users
- // to set any new sort of properties via the properties
- // file, and we'll pick it up - that way this class doesn't
- // have to get updated when we have new properties
- for (Enumeration enum = props.propertyNames();
- enum.hasMoreElements(); /* no increment portion */ )
- {
- Object key = enum.nextElement();
-
- testProps.put(key, props.get(key));
- }
-
- // Now set any convenience instance variables based on
- // values set from the properties block
- category = props.getProperty(OPT_CATEGORY, category);
- liaison = props.getProperty(OPT_LIAISON, liaison);
- flavor = props.getProperty(OPT_FLAVOR, flavor);
- fileCheckerName = props.getProperty(OPT_FILECHECKER, fileCheckerName);
- excludes = props.getProperty(OPT_EXCLUDES, excludes);
- embedded = props.getProperty(OPT_EMBEDDED, embedded);
-
- String noet = props.getProperty(OPT_NOERRTEST);
-
- if ((noet != null) && noet.equalsIgnoreCase("true"))
- {
- noErrTest = true;
- // Default the value in properties block too
- testProps.put(OPT_NOERRTEST, "true");
- }
-
- return b;
- }
-
- /**
- * Sets the provided fields with data from an array, presumably
- * from the command line.
- * <p>Overridden from FileBasedTest, but calls super.() to
- * get default properties.</p>
- * @author Shane Curcuru
- *
- * NEEDSDOC @param args
- * @return status - true if OK, false if error.
- */
- public boolean initializeFromArray(String[] args)
- {
- // Read in command line args and setup internal variables
- String optPrefix = "-";
- int nArgs = args.length;
-
- if (nArgs == 0)
- {
- System.out.println("ERROR: you must supply required arguments!");
-
- return false;
- }
-
- // Our parent class already read in the properties file
- // override values from properties file
- for (int k = 0; k < nArgs; k++)
- {
- if (args[k].equalsIgnoreCase(optPrefix + OPT_LOAD))
- {
- if (++k >= nArgs)
- {
- System.out.println(
- "ERROR: must supply properties filename for: "
- + optPrefix + OPT_LOAD);
-
- return false;
- }
-
- load = args[k];
-
- try
- {
-
- // Load named file into our properties block
- FileInputStream fIS = new FileInputStream(load);
- Properties p = new Properties();
-
- p.load(fIS);
- initializeFromProperties(p);
- }
- catch (Exception e)
- {
- System.out.println(
- "ERROR: loading properties file failed: " + load);
- e.printStackTrace();
-
- return false;
- }
-
- break;
- }
- }
-
- // Now read in the rest of the command line
- // @todo cleanup loop to be more table-driven
- for (int i = 0; i < nArgs; i++)
- {
- if (args[i].equalsIgnoreCase(optPrefix + OPT_CATEGORY))
- {
- if (++i >= nArgs)
- {
- System.out.println("ERROR: must supply arg for: "
- + optPrefix + OPT_CATEGORY);
-
- return false;
- }
-
- category = args[i];
-
- testProps.put(OPT_CATEGORY, category);
-
- continue;
- }
-
- if (args[i].equalsIgnoreCase(optPrefix + OPT_LIAISON))
- {
- if (++i >= nArgs)
- {
- System.out.println("ERROR: must supply arg for: "
- + optPrefix + OPT_LIAISON);
-
- return false;
- }
-
- liaison = args[i];
-
- testProps.put(OPT_LIAISON, liaison);
-
- continue;
- }
-
- if (args[i].equalsIgnoreCase(optPrefix + OPT_FLAVOR))
- {
- if (++i >= nArgs)
- {
- System.out.println("ERROR: must supply arg for: "
- + optPrefix + OPT_FLAVOR);
-
- return false;
- }
-
- flavor = args[i];
-
- testProps.put(OPT_FLAVOR, flavor);
-
- continue;
- }
-
- if (args[i].equalsIgnoreCase(optPrefix + OPT_FILECHECKER))
- {
- if (++i >= nArgs)
- {
- System.out.println("ERROR: must supply arg for: "
- + optPrefix + OPT_FILECHECKER);
-
- return false;
- }
-
- fileCheckerName = args[i];
-
- testProps.put(OPT_FILECHECKER, fileCheckerName);
-
- continue;
- }
-
- if (args[i].equalsIgnoreCase(optPrefix + OPT_EXCLUDES))
- {
- if (++i >= nArgs)
- {
- System.out.println("ERROR: must supply arg for: "
- + optPrefix + OPT_EXCLUDES);
-
- return false;
- }
-
- excludes = args[i];
-
- testProps.put(OPT_EXCLUDES, excludes);
-
- continue;
- }
-
- if (args[i].equalsIgnoreCase(optPrefix + OPT_EMBEDDED))
- {
- if (++i >= nArgs)
- {
- System.out.println("ERROR: must supply arg for: "
- + optPrefix + OPT_EMBEDDED);
-
- return false;
- }
-
- embedded = args[i];
-
- testProps.put(OPT_EMBEDDED, embedded);
-
- continue;
- }
-
- if (args[i].equalsIgnoreCase(optPrefix + OPT_NOERRTEST))
- {
- noErrTest = true;
-
- testProps.put(OPT_NOERRTEST, "true");
-
- continue;
- }
- }
-
- // Be sure to ask our superclass to read it's options as well!
- return super.initializeFromArray(args, true);
- }
-
- //-----------------------------------------------------
- //-------- Other useful and utility methods --------
- //-----------------------------------------------------
- /**
- * Main worker method to run test from the command line.
- * Test subclasses generally need not override.
- * <p>This is primarily provided to make subclasses implementations
- * of the main method as simple as possible: in general, they
- * should simply do:
- * <code>
- * public static void main (String[] args)
- * {
- * TestSubClass app = new TestSubClass();
- * app.doMain(args);
- * }
- * </code>
- * @author Shane Curcuru
- *
- * NEEDSDOC @param args
- */
- public void doMain(String[] args)
- {
- // Initialize any instance variables from the command line
- // OR specified properties block
- if (!initializeFromArray(args))
- {
- System.err.println("ERROR in usage:");
- System.err.println(usage());
-
- // Don't use System.exit, since that will blow away any containing harnesses
- return;
- }
-
- // Also pass along the command line, in case someone has
- // specific code that's counting on this
- StringBuffer buf = new StringBuffer();
- for (int i = 0; i < args.length; i++)
- {
- buf.append(args[i]);
- buf.append(' ');
- }
- testProps.put(MAIN_CMDLINE, buf.toString());
-
- // Actually go and execute the test
- runTest(testProps);
- }
-
- /**
- * Main method to run test from the command line.
- * @author Shane Curcuru
- * <p>Test subclasses <b>must</b> override, obviously.
- * Only provided here for debugging.</p>
- *
- * @param args command line arguments
- */
- public static void main(String[] args)
- {
- XSLProcessorTestBase app = new XSLProcessorTestBase();
- app.doMain(args);
- }
} // end of class XSLProcessorTestBase
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org