aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop
diff options
context:
space:
mode:
authorFinn Bock <bckfnn@apache.org>2004-01-20 11:45:48 +0000
committerFinn Bock <bckfnn@apache.org>2004-01-20 11:45:48 +0000
commit84e81a5668ea99c941bf9bd560b55198cee9b9f8 (patch)
treec5f38aee012b6525b4d1f6bc3d492b80d3d827ed /src/java/org/apache/fop
parent11474a77088b72dc7e11138ccccec6b389310666 (diff)
downloadxmlgraphics-fop-84e81a5668ea99c941bf9bd560b55198cee9b9f8.tar.gz
xmlgraphics-fop-84e81a5668ea99c941bf9bd560b55198cee9b9f8.zip
Fix a NPE caused by avalonization of logging.
Support for 'results' attribute on 'test' element, used by NIST suite. Explicit close the output file, otherwise the file has a length of 0 when the files are compared (on windows). Added -d option to enable debug output. PR: 25691 git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197227 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop')
-rw-r--r--src/java/org/apache/fop/tools/TestConverter.java48
1 files changed, 39 insertions, 9 deletions
diff --git a/src/java/org/apache/fop/tools/TestConverter.java b/src/java/org/apache/fop/tools/TestConverter.java
index 25c712c0e..8bb54510f 100644
--- a/src/java/org/apache/fop/tools/TestConverter.java
+++ b/src/java/org/apache/fop/tools/TestConverter.java
@@ -52,6 +52,7 @@ package org.apache.fop.tools;
import java.io.File;
import java.io.InputStream;
+import java.io.OutputStream;
import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
@@ -106,7 +107,6 @@ public class TestConverter extends AbstractLogEnabled {
System.out.println("test suite file name required");
}
TestConverter tc = new TestConverter();
- tc.enableLogging(new ConsoleLogger(ConsoleLogger.LEVEL_ERROR));
String testFile = null;
for (int count = 0; count < args.length; count++) {
@@ -114,8 +114,10 @@ public class TestConverter extends AbstractLogEnabled {
tc.setFailOnly(true);
} else if (args[count].equals("-pdf")) {
tc.setOutputPDF(true);
+ } else if (args[count].equals("-d")) {
+ tc.setDebug(true);
} else if (args[count].equals("-b")) {
- tc.setBaseDir(args[count + 1]);
+ tc.setBaseDir(args[++count]);
} else {
testFile = args[count];
}
@@ -128,6 +130,13 @@ public class TestConverter extends AbstractLogEnabled {
}
/**
+ * Construct a new TestConverter
+ */
+ public TestConverter() {
+ enableLogging(new ConsoleLogger(ConsoleLogger.LEVEL_ERROR));
+ }
+
+ /**
* Controls whether to generate PDF or XML.
* @param pdf If True, PDF is generated, Area Tree XML otherwise.
*/
@@ -153,6 +162,16 @@ public class TestConverter extends AbstractLogEnabled {
}
/**
+ * Controls whether to generate PDF or XML.
+ * @param pdf If True, PDF is generated, Area Tree XML otherwise.
+ */
+ public void setDebug(boolean debug) {
+ if (debug) {
+ enableLogging(new ConsoleLogger(ConsoleLogger.LEVEL_DEBUG));
+ }
+ }
+
+ /**
* Run the Tests.
* This runs the tests specified in the xml file fname.
* The document is read as a dom and each testcase is covered.
@@ -264,6 +283,11 @@ public class TestConverter extends AbstractLogEnabled {
getLogger().debug("converting xml:" + xml + " and xsl:"
+ xsl + " to area tree");
+ String res = xml;
+ Node resNode = test.getAttributes().getNamedItem("results");
+ if (resNode != null) {
+ res = resNode.getNodeValue();
+ }
try {
File xmlFile = new File(baseDir + "/" + xml);
String baseURL = null;
@@ -283,8 +307,8 @@ public class TestConverter extends AbstractLogEnabled {
}
Driver driver = new Driver();
- setupLogger(driver, "fop");
FOUserAgent userAgent = new FOUserAgent();
+ setupLogger(userAgent, "fop");
userAgent.setBaseURL(baseURL);
driver.setUserAgent(userAgent);
if (outputPDF) {
@@ -299,15 +323,21 @@ public class TestConverter extends AbstractLogEnabled {
driver.getRenderer().setOptions(rendererOptions);
driver.getRenderer().setProducer("Testsuite Converter");
- String outname = xmlFile.getName();
- if (outname.endsWith(".xml")) {
+ String outname = res;
+ if (outname.endsWith(".xml") || outname.endsWith(".pdf")) {
outname = outname.substring(0, outname.length() - 4);
}
- driver.setOutputStream(new java.io.BufferedOutputStream(
- new java.io.FileOutputStream(new File(destdir,
- outname + (outputPDF ? ".pdf" : ".at.xml")))));
- getLogger().debug("ddir:" + destdir + " on:" + outname + ".pdf");
+ File outputFile = new File(destdir,
+ outname + (outputPDF ? ".pdf" : ".at.xml"));
+
+ outputFile.getParentFile().mkdirs();
+ OutputStream outStream = new java.io.BufferedOutputStream(
+ new java.io.FileOutputStream(outputFile));
+ driver.setOutputStream(outStream);
+ getLogger().debug("ddir:" + destdir + " on:" +
+ outputFile.getName());
driver.render(inputHandler);
+ outStream.close();
// check difference
if (compare != null) {