Class XMLTestReportProcessor
java.lang.Object
org.apache.batik.test.xml.XMLTestReportProcessor
- All Implemented Interfaces:
XMLConstants, TestReportProcessor, XMLReflectConstants, XTRConstants
- Direct Known Subclasses:
SVGAccuracyTestProcessor
public class XMLTestReportProcessor
extends Object
implements TestReportProcessor, XTRConstants, XMLConstants
This implementation of the
The
TestReportProcessor interface
converts the TestReports it processes into an
XML document that it outputs in a directory. The directory
used by the object can be configured at creation time.
The
XMLTestReportProcessor can optionally notify a
report consumer of the XML file it created.- Version:
- $Id$
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceAnXMLReportConsumeris notified every time a new report is generated by anXMLTestReportProcessor -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected XMLTestReportProcessor.XMLReportConsumerThe XMLReportConsumer instance is notified whenever this object generates a new report.private static Stringstatic final StringError message if report directory does not exist.static final StringError message if report resources directory does not exist.private static Stringprivate static Stringprotected StringString encoding the date the report was generated.protected FileDirectory into which this processor puts all files and resources.static final StringDirectory where the XML report is createdstatic final StringDirectory where resources (e.g., images) referenced by the XML report are copied.static final StringDefault report directorystatic final StringTest report nameprotected FileDirectory into which XML files are createdprotected FileDirectory into whichr resources refered to by XML files are createdFields inherited from interface TestReportProcessor
INTERNAL_ERRORFields inherited from interface XMLConstants
XLINK_HREF_ATTRIBUTE, XLINK_HREF_QNAME, XLINK_NAMESPACE_URI, XLINK_PREFIX, XML_BASE_ATTRIBUTE, XML_BASE_QNAME, XML_CDATA_END, XML_CHAR_AMP, XML_CHAR_APOS, XML_CHAR_GT, XML_CHAR_LT, XML_CHAR_QUOT, XML_CHAR_REF_PREFIX, XML_CHAR_REF_SUFFIX, XML_CLOSE_TAG_END, XML_CLOSE_TAG_START, XML_DEFAULT_VALUE, XML_DOUBLE_DASH, XML_DOUBLE_QUOTE, XML_ENTITY_AMP, XML_ENTITY_APOS, XML_ENTITY_GT, XML_ENTITY_LT, XML_ENTITY_QUOT, XML_EQUAL_QUOT, XML_EQUAL_SIGN, XML_EVENTS_EVENT_ATTRIBUTE, XML_EVENTS_NAMESPACE_URI, XML_ID_ATTRIBUTE, XML_ID_QNAME, XML_LANG_ATTRIBUTE, XML_LANG_QNAME, XML_NAMESPACE_URI, XML_OPEN_TAG_END_CHILDREN, XML_OPEN_TAG_END_NO_CHILDREN, XML_OPEN_TAG_START, XML_PREFIX, XML_PRESERVE_VALUE, XML_PROCESSING_INSTRUCTION_END, XML_SPACE, XML_SPACE_ATTRIBUTE, XML_SPACE_QNAME, XML_TAB, XML_VERSION_10, XML_VERSION_11, XMLNS_NAMESPACE_URI, XMLNS_PREFIXFields inherited from interface XMLReflectConstants
XR_ARG_TAG, XR_CLASS_ATTRIBUTE, XR_NAME_ATTRIBUTE, XR_PROPERTY_TAG, XR_VALUE_ATTRIBUTEFields inherited from interface XTRConstants
XTR_CLASS_ATTRIBUTE, XTR_DATE_ATTRIBUTE, XTR_DESCRIPTION_TAG, XTR_ERROR_CODE_ATTRIBUTE, XTR_FAILED_VALUE, XTR_FILE_ENTRY_TAG, XTR_GENERIC_ENTRY_TAG, XTR_ID_ATTRIBUTE, XTR_KEY_ATTRIBUTE, XTR_NAMESPACE_URI, XTR_PASSED_VALUE, XTR_STATUS_ATTRIBUTE, XTR_TEST_NAME_ATTRIBUTE, XTR_TEST_REPORT_TAG, XTR_TEST_SUITE_REPORT_TAG, XTR_URI_ENTRY_TAG, XTR_VALUE_ATTRIBUTE -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckDirectory(File dir, String errorCode) Checks that the input File represents a directory that can be used.protected voidUtility method.protected FilecreateResourceFileForName(String fileName) Untility method.protected FilecreateResourceFileForName(String fileName, int instance) protected StringPoor way of replacing '<', '>', '"', '&' and ''' in attribute values.Returns the report directoryBy default, the report resources directory is given by a configuration variable.voidBy default, the report directory is given by a configuration variable.protected StringmakeTwoDigits(int i) Forces a two digit stringprotected voidprocessEntry(TestReport.Entry entry, Element descriptionElement, Document reportDocument) voidprocessReport(TestReport report) Recursively processes the inputTestReportand any of its children.protected voidprocessReport(TestReport report, Element reportElement, Document reportDocument) Recursively processes the inputTestReportadding the report information to the input element.protected voidreplace(StringBuffer s, char c, String r) protected voidserializeAttributes(Element element, Writer writer) protected voidserializeElement(Element element, String prefix, Writer writer) protected FileserializeReport(Element reportElement) Saves the XML document into a file
-
Field Details
-
ERROR_REPORT_DIRECTORY_UNUSABLE
Error message if report directory does not exist.- See Also:
-
ERROR_REPORT_RESOURCES_DIRECTORY_UNUSABLE
Error message if report resources directory does not exist.- See Also:
-
XML_TEST_REPORT_DEFAULT_DIRECTORY
Default report directory -
XML_REPORT_DIRECTORY
Directory where the XML report is created -
XML_RESOURCES_DIRECTORY
Directory where resources (e.g., images) referenced by the XML report are copied. -
XML_TEST_REPORT_NAME
Test report name -
consumer
The XMLReportConsumer instance is notified whenever this object generates a new report. -
reportDate
String encoding the date the report was generated. -
reportDirectory
Directory into which this processor puts all files and resources. -
xmlDirectory
Directory into which XML files are created -
xmlResourcesDirectory
Directory into whichr resources refered to by XML files are created -
EOL
-
PROPERTY_LINE_SEPARATOR
-
PROPERTY_LINE_SEPARATOR_DEFAULT
-
-
Constructor Details
-
XMLTestReportProcessor
public XMLTestReportProcessor()Default constructor -
XMLTestReportProcessor
- Parameters:
consumer- consumer for the XML report generated by this object. May be null.
-
-
Method Details
-
processReport
Recursively processes the inputTestReportand any of its children.- Specified by:
processReportin interfaceTestReportProcessor- Throws:
TestException
-
checkDirectory
Checks that the input File represents a directory that can be used. If the directory does not exist, this method will attempt to create it.- Throws:
TestException
-
initializeReportDirectories
By default, the report directory is given by a configuration variable. Each test run will create a sub directory with the current date and time as the same. All the resources created by the report processor are then put into that "dated" directory.- Throws:
TestException
-
makeTwoDigits
Forces a two digit string -
getReportDirectory
Returns the report directory -
getReportResourcesDirectory
By default, the report resources directory is given by a configuration variable. -
processReport
protected void processReport(TestReport report, Element reportElement, Document reportDocument) throws IOException Recursively processes the inputTestReportadding the report information to the input element.- Throws:
IOException
-
processEntry
protected void processEntry(TestReport.Entry entry, Element descriptionElement, Document reportDocument) throws IOException - Throws:
IOException
-
createResourceFileForName
Untility method. Creates a file in the resources directory for the given name. If a file in that directory does not exist yet, then it is used. Otherwise, a file with the same name with a digit suffix is created. For example, if "myFile.png" is requested, then "myFile.png" is created or "myFile<n>.png" where <n> will be one or several digits. -
createResourceFileForName
-
copy
Utility method. Copies in to out- Throws:
IOException
-
serializeReport
Saves the XML document into a file- Throws:
IOException
-
serializeElement
- Throws:
IOException
-
serializeAttributes
- Throws:
IOException
-
encode
-
replace
-