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 2001/05/21 22:46:47 UTC
cvs commit: xml-xalan/test/java/src/org/apache/qetest/trax ErrorListenerTest.java
curcuru 01/05/21 13:46:46
Modified: test/java/src/org/apache/qetest/trax ErrorListenerTest.java
Log:
Added testCase4 to reproduce Bugzilla1266
Revision Changes Path
1.3 +79 -7 xml-xalan/test/java/src/org/apache/qetest/trax/ErrorListenerTest.java
Index: ErrorListenerTest.java
===================================================================
RCS file: /home/cvs/xml-xalan/test/java/src/org/apache/qetest/trax/ErrorListenerTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ErrorListenerTest.java 2001/03/22 19:57:07 1.2
+++ ErrorListenerTest.java 2001/05/21 20:46:42 1.3
@@ -90,7 +90,7 @@
/**
* Verify that ErrorListeners are called properly from Transformers.
* @author shane_curcuru@lotus.com
- * @version $Id: ErrorListenerTest.java,v 1.2 2001/03/22 19:57:07 curcuru Exp $
+ * @version $Id: ErrorListenerTest.java,v 1.3 2001/05/21 20:46:42 curcuru Exp $
*/
public class ErrorListenerTest extends XSLProcessorTestBase
{
@@ -98,9 +98,6 @@
/** Provide sequential output names automatically. */
protected OutputNameManager outNames;
- /** FilenameFilter that lists appropriate tests in api/err directory to use. */
- protected FilenameFilter errorFileFilter = null;
-
/**
* A simple stylesheet with errors for testing in various flavors.
* Must be coordinated with templatesExpectedType/Value,
@@ -108,6 +105,11 @@
*/
protected XSLTestfileInfo testFileInfo = new XSLTestfileInfo();
+ /**
+ * A simple stylesheet without errors in it.
+ */
+ protected XSLTestfileInfo goodFileInfo = new XSLTestfileInfo();
+
/** Expected type of error during stylesheet build. */
protected int templatesExpectedType = 0;
@@ -129,7 +131,7 @@
/** Just initialize test name, comment, numTestCases. */
public ErrorListenerTest()
{
- numTestCases = 3; // REPLACE_num
+ numTestCases = 4; // REPLACE_num
testName = "ErrorListenerTest";
testComment = "Verify that ErrorListeners are called properly from Transformers.";
}
@@ -151,8 +153,6 @@
outNames = new OutputNameManager(outputDir + File.separator + ERR_SUBDIR
+ File.separator + testName, ".out");
- errorFileFilter = new ConformanceErrFileRules(API_PARENTDIR);
-
String testBasePath = inputDir
+ File.separator
+ ERR_SUBDIR
@@ -162,6 +162,13 @@
+ ERR_SUBDIR
+ File.separator;
+ goodFileInfo.inputName = inputDir + File.separator
+ + "trax" + File.separator + "identity.xsl";
+ goodFileInfo.xmlName = inputDir + File.separator
+ + "trax" + File.separator + "identity.xml";
+ goodFileInfo.goldName = goldDir + File.separator
+ + "trax" + File.separator + "identity.out";
+
testFileInfo.inputName = testBasePath + "ErrorListenerTest.xsl";
testFileInfo.xmlName = testBasePath + "ErrorListenerTest.xml";
testFileInfo.goldName = goldBasePath + "ErrorListenerTest.out";
@@ -427,6 +434,71 @@
reporter.testCaseClose();
return true;
}
+
+
+ /**
+ * Miscellaneous other ErrorListener tests.
+ * Includes Bugzilla1266.
+ * Primarily using StreamSources.
+ * @return false if we should abort the test; true otherwise
+ */
+ public boolean testCase4()
+ {
+ reporter.testCaseInit("Miscellaneous other ErrorListener tests");
+ LoggingErrorListener loggingErrorListener = new LoggingErrorListener(reporter);
+ loggingErrorListener.setThrowWhen(LoggingErrorListener.THROW_NEVER);
+ reporter.logTraceMsg("loggingErrorListener originally setup:" + loggingErrorListener.getQuickCounters());
+
+ TransformerFactory factory = null;
+ Templates templates = null;
+ Transformer transformer = null;
+ try
+ {
+ factory = TransformerFactory.newInstance();
+ reporter.logInfoMsg("About to factory.newTemplates(" + QetestUtils.filenameToURL(goodFileInfo.inputName) + ")");
+ templates = factory.newTemplates(new StreamSource(QetestUtils.filenameToURL(goodFileInfo.inputName)));
+ transformer = templates.newTransformer();
+
+ // Set the errorListener and validate it
+ transformer.setErrorListener(loggingErrorListener);
+ reporter.check((transformer.getErrorListener() == loggingErrorListener),
+ true, "set/getErrorListener on transformer");
+
+ reporter.logStatusMsg("Reproduce Bugzilla1266 - warning due to bad output props not propagated");
+ reporter.logStatusMsg("transformer.setOutputProperty(encoding, illegal-encoding-value)");
+ transformer.setOutputProperty("encoding", "illegal-encoding-value");
+
+ reporter.logTraceMsg("about to transform(...)");
+ transformer.transform(new StreamSource(QetestUtils.filenameToURL(goodFileInfo.xmlName)),
+ new StreamResult(outNames.nextName()));
+ reporter.logTraceMsg("after transform(...)");
+ reporter.logStatusMsg("loggingErrorListener after transform:" + loggingErrorListener.getQuickCounters());
+
+ // Validate that one warning (about illegal-encoding-value) should have been reported
+ int[] errCtr = loggingErrorListener.getCounters();
+ reporter.check((errCtr[LoggingErrorListener.TYPE_WARNING] > 0), true, "At least one Warning listned to for illegal-encoding-value");
+
+ // Validate the actual output file as well: in this case,
+ // the stylesheet should still work
+ if (Logger.PASS_RESULT
+ != fileChecker.check(reporter,
+ new File(outNames.currentName()),
+ new File(goodFileInfo.goldName),
+ "transform of good xsl w/bad output props into: " + outNames.currentName())
+ )
+ reporter.logInfoMsg("transform of error xsl failure reason:" + fileChecker.getExtendedInfo());
+
+ }
+ catch (Throwable t)
+ {
+ reporter.checkFail("errorListener4 unexpectedly threw: " + t.toString());
+ reporter.logThrowable(Logger.ERRORMSG, t, "errorListener4 unexpectedly threw");
+ }
+
+ reporter.testCaseClose();
+ return true;
+ }
+
/**
* Convenience method to print out usage information - update if needed.
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org