Package org.apache.fop.tools
Class TestConverter
- java.lang.Object
-
- org.apache.fop.tools.TestConverter
-
public class TestConverter extends java.lang.Object
TestConverter is used to process a set of tests specified in a testsuite. This class retrieves the data in the testsuite and uses FOP to convert the xml and xsl file into either an xml representation of the area tree or a pdf document. The area tree can be used for automatic comparisons between different versions of FOP or the pdf can be view for manual checking and pdf rendering.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
baseDir
private java.io.File
compare
private java.io.File
destdir
private java.util.Map
differ
private boolean
failOnly
protected org.apache.commons.logging.impl.SimpleLog
logger
logging instanceprivate java.lang.String
outputFormat
-
Constructor Summary
Constructors Constructor Description TestConverter()
Construct a new TestConverter
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
compareFiles(java.io.File f1, java.io.File f2)
Compare files.private org.w3c.dom.Node
locateResult(org.w3c.dom.Node testcase, java.lang.String id)
static void
main(java.lang.String[] args)
This main method can be used to run the test converter from the command line.private java.lang.String
makeResultExtension()
Return a suitable file extension for the output format.protected void
runTest(org.w3c.dom.Node testcase, org.w3c.dom.Node test)
Run a particular test.protected void
runTestCase(org.w3c.dom.Node tcase)
Run a test case.java.util.Map
runTests(java.lang.String fname, java.lang.String dest, java.lang.String compDir)
Run the Tests.void
setBaseDir(java.lang.String str)
Sets the base directory.void
setDebug(boolean debug)
Controls whether to set logging to debug levelvoid
setFailOnly(boolean fail)
Controls whether to process only the tests which are specified as fail in the test results.void
setOutputFormat(java.lang.String outputFormat)
Controls output format to generate
-
-
-
Field Detail
-
failOnly
private boolean failOnly
-
outputFormat
private java.lang.String outputFormat
-
destdir
private java.io.File destdir
-
compare
private java.io.File compare
-
baseDir
private java.lang.String baseDir
-
differ
private java.util.Map differ
-
logger
protected org.apache.commons.logging.impl.SimpleLog logger
logging instance
-
-
Method Detail
-
main
public static void main(java.lang.String[] args)
This main method can be used to run the test converter from the command line. This will take a specified testsuite xml and process all tests in it. The command line options are: -b to set the base directory for where the testsuite and associated files are -failOnly to process only the tests which are specified as fail in the test results -pdf to output the result as pdf- Parameters:
args
- command-line arguments
-
setOutputFormat
public void setOutputFormat(java.lang.String outputFormat)
Controls output format to generate- Parameters:
outputFormat
- the MIME type of the output format
-
setFailOnly
public void setFailOnly(boolean fail)
Controls whether to process only the tests which are specified as fail in the test results.- Parameters:
fail
- True if only fail tests should be processed
-
setBaseDir
public void setBaseDir(java.lang.String str)
Sets the base directory.- Parameters:
str
- base directory
-
setDebug
public void setDebug(boolean debug)
Controls whether to set logging to debug level- Parameters:
debug
- If true, debug level, if false, error level
-
runTests
public java.util.Map runTests(java.lang.String fname, java.lang.String dest, java.lang.String compDir)
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.- Parameters:
fname
- filename of the input filedest
- destination directorycompDir
- comparison directory- Returns:
- Map a Map containing differences
-
runTestCase
protected void runTestCase(org.w3c.dom.Node tcase)
Run a test case. This goes through a test case in the document. A testcase can contain a test, a result or more test cases. A test case is handled recursively otherwise the test is run.- Parameters:
tcase
- Test case node to run
-
runTest
protected void runTest(org.w3c.dom.Node testcase, org.w3c.dom.Node test)
Run a particular test. This runs a test defined by the xml and xsl documents. If the test has a result specified it is checked. This creates an XSLTInputHandler to provide the input for FOP and writes the data out to an XML are tree.- Parameters:
testcase
- Test case to runtest
- Test
-
makeResultExtension
private java.lang.String makeResultExtension()
Return a suitable file extension for the output format.
-
compareFiles
protected boolean compareFiles(java.io.File f1, java.io.File f2)
Compare files.- Parameters:
f1
- first filef2
- second file- Returns:
- true if equal
-
locateResult
private org.w3c.dom.Node locateResult(org.w3c.dom.Node testcase, java.lang.String id)
-
-