org.apache.fop.tools

Class 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

protected SimpleLog
logger
logging instance

Constructor Summary

TestConverter()
Construct a new TestConverter

Method Summary

protected boolean
compareFiles(File f1, File f2)
Compare files.
static void
main(String[] args)
This main method can be used to run the test converter from the command line.
protected void
runTest(Node testcase, Node test)
Run a particular test.
protected void
runTestCase(Node tcase)
Run a test case.
Map
runTests(String fname, String dest, String compDir)
Run the Tests.
void
setBaseDir(String str)
Sets the base directory.
void
setDebug(boolean debug)
Controls whether to set logging to debug level
void
setFailOnly(boolean fail)
Controls whether to process only the tests which are specified as fail in the test results.
void
setOutputFormat(String outputFormat)
Controls output format to generate

Field Details

logger

protected SimpleLog logger
logging instance

Constructor Details

TestConverter

public TestConverter()
Construct a new TestConverter

Method Details

compareFiles

protected boolean compareFiles(File f1,
                               File f2)
Compare files.
Parameters:
f1 - first file
f2 - second file
Returns:
true if equal

main

public static void main(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

runTest

protected void runTest(Node testcase,
                       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 run
test - Test

runTestCase

protected void runTestCase(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

runTests

public Map runTests(String fname,
                    String dest,
                    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 file
dest - destination directory
compDir - comparison directory
Returns:
Map a Map containing differences

setBaseDir

public void setBaseDir(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

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

setOutputFormat

public void setOutputFormat(String outputFormat)
Controls output format to generate
Parameters:
outputFormat - the MIME type of the output format

Copyright 1999-2007 The Apache Software Foundation. All Rights Reserved.