public class XMLTestReportProcessor extends Object implements TestReportProcessor, XTRConstants, XMLConstants
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.
XMLTestReportProcessor
can optionally notify a
report consumer of the XML file it created.Modifier and Type | Class and Description |
---|---|
static interface |
XMLTestReportProcessor.XMLReportConsumer
An
XMLReportConsumer is notified every time a
new report is generated by an XMLTestReportProcessor |
Modifier and Type | Field and Description |
---|---|
protected XMLTestReportProcessor.XMLReportConsumer |
consumer
The XMLReportConsumer instance is notified whenever
this object generates a new report.
|
static String |
ERROR_REPORT_DIRECTORY_UNUSABLE
Error message if report directory does not exist.
|
static String |
ERROR_REPORT_RESOURCES_DIRECTORY_UNUSABLE
Error message if report resources directory does not exist.
|
protected String |
reportDate
String encoding the date the report was generated.
|
protected File |
reportDirectory
Directory into which this processor puts all files and resources.
|
static String |
XML_REPORT_DIRECTORY
Directory where the XML report is created
|
static String |
XML_RESOURCES_DIRECTORY
Directory where resources (e.g., images) referenced by the
XML report are copied.
|
static String |
XML_TEST_REPORT_DEFAULT_DIRECTORY
Default report directory
|
static String |
XML_TEST_REPORT_NAME
Test report name
|
protected File |
xmlDirectory
Directory into which XML files are created
|
protected File |
xmlResourcesDirectory
Directory into whichr resources refered to by XML files are created
|
INTERNAL_ERROR
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
XR_ARG_TAG, XR_CLASS_ATTRIBUTE, XR_NAME_ATTRIBUTE, XR_PROPERTY_TAG, XR_VALUE_ATTRIBUTE
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_PREFIX
Constructor and Description |
---|
XMLTestReportProcessor()
Default constructor
|
XMLTestReportProcessor(XMLTestReportProcessor.XMLReportConsumer consumer) |
Modifier and Type | Method and Description |
---|---|
void |
checkDirectory(File dir,
String errorCode)
Checks that the input File represents a directory that
can be used.
|
protected void |
copy(File in,
File out)
Utility method.
|
protected File |
createResourceFileForName(String fileName)
Untility method.
|
protected File |
createResourceFileForName(String fileName,
int instance) |
protected String |
encode(String attrValue)
Poor way of replacing '<', '>', '"', '&' and '''
in attribute values.
|
File |
getReportDirectory()
Returns the report directory
|
File |
getReportResourcesDirectory()
By default, the report resources directory is
given by a configuration variable.
|
void |
initializeReportDirectories()
By default, the report directory is given by a configuration
variable.
|
protected String |
makeTwoDigits(int i)
Forces a two digit string
|
protected void |
processEntry(TestReport.Entry entry,
Element descriptionElement,
Document reportDocument) |
void |
processReport(TestReport report)
Recursively processes the input
TestReport and
any of its children. |
protected void |
processReport(TestReport report,
Element reportElement,
Document reportDocument)
Recursively processes the input
TestReport adding
the report information to the input element. |
protected void |
replace(StringBuffer s,
char c,
String r) |
protected void |
serializeAttributes(Element element,
Writer writer) |
protected void |
serializeElement(Element element,
String prefix,
Writer writer) |
protected File |
serializeReport(Element reportElement)
Saves the XML document into a file
|
public static final String ERROR_REPORT_DIRECTORY_UNUSABLE
public static final String ERROR_REPORT_RESOURCES_DIRECTORY_UNUSABLE
public static final String XML_TEST_REPORT_DEFAULT_DIRECTORY
public static final String XML_REPORT_DIRECTORY
public static final String XML_RESOURCES_DIRECTORY
public static final String XML_TEST_REPORT_NAME
protected XMLTestReportProcessor.XMLReportConsumer consumer
protected String reportDate
protected File reportDirectory
protected File xmlDirectory
protected File xmlResourcesDirectory
public XMLTestReportProcessor()
public XMLTestReportProcessor(XMLTestReportProcessor.XMLReportConsumer consumer)
consumer
- consumer for the XML report generated
by this object. May be null.public void processReport(TestReport report) throws TestException
TestReport
and
any of its children.processReport
in interface TestReportProcessor
TestException
public void checkDirectory(File dir, String errorCode) throws TestException
TestException
public void initializeReportDirectories() throws TestException
TestException
protected String makeTwoDigits(int i)
public File getReportDirectory()
public File getReportResourcesDirectory()
protected void processReport(TestReport report, Element reportElement, Document reportDocument) throws IOException
TestReport
adding
the report information to the input element.IOException
protected void processEntry(TestReport.Entry entry, Element descriptionElement, Document reportDocument) throws IOException
IOException
protected File createResourceFileForName(String fileName)
protected void copy(File in, File out) throws IOException
IOException
protected File serializeReport(Element reportElement) throws IOException
IOException
protected void serializeElement(Element element, String prefix, Writer writer) throws IOException
IOException
protected void serializeAttributes(Element element, Writer writer) throws IOException
IOException
protected String encode(String attrValue)
protected void replace(StringBuffer s, char c, String r)
Copyright © 2000–2023 Apache Software Foundation. All rights reserved.