Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.batik.test.xml
Class XMLTestReportProcessor  view XMLTestReportProcessor download XMLTestReportProcessor.java

java.lang.Object
  extended byorg.apache.batik.test.xml.XMLTestReportProcessor
All Implemented Interfaces:
org.apache.batik.test.TestReportProcessor, org.apache.batik.util.XMLConstants, XMLReflectConstants, XTRConstants

public class XMLTestReportProcessor
extends java.lang.Object
implements org.apache.batik.test.TestReportProcessor, XTRConstants, org.apache.batik.util.XMLConstants

This implementation of 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: XMLTestReportProcessor.java,v 1.19 2004/08/18 07:17:06 vhardy Exp $

Nested Class Summary
static interface XMLTestReportProcessor.XMLReportConsumer
          An XMLReportConsumer is notified every time a new report is generated by an XMLTestReportProcessor
 
Field Summary
protected  XMLTestReportProcessor.XMLReportConsumer consumer
          The XMLReportConsumer instance is notified whenever this object generates a new report.
private static java.lang.String EOL
           
static java.lang.String ERROR_REPORT_DIRECTORY_UNUSABLE
          Error message if report directory does not exist.
static java.lang.String ERROR_REPORT_RESOURCES_DIRECTORY_UNUSABLE
          Error message if report resources directory does not exist.
private static java.lang.String PROPERTY_LINE_SEPARATOR
           
private static java.lang.String PROPERTY_LINE_SEPARATOR_DEFAULT
           
protected  java.lang.String reportDate
          String encoding the date the report was generated.
protected  java.io.File reportDirectory
          Directory into which this processor puts all files and resources.
static java.lang.String XML_REPORT_DIRECTORY
          Directory where the XML report is created
static java.lang.String XML_RESOURCES_DIRECTORY
          Directory where resources (e.g., images) referenced by the XML report are copied.
static java.lang.String XML_TEST_REPORT_DEFAULT_DIRECTORY
          Default report directory
static java.lang.String XML_TEST_REPORT_NAME
          Test report name
protected  java.io.File xmlDirectory
          Directory into which XML files are created
protected  java.io.File xmlResourcesDirectory
          Directory into whichr resources refered to by XML files are created
 
Fields inherited from interface org.apache.batik.test.TestReportProcessor
INTERNAL_ERROR
 
Fields inherited from interface org.apache.batik.test.xml.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
 
Fields inherited from interface org.apache.batik.test.xml.XMLReflectConstants
XR_ARG_TAG, XR_CLASS_ATTRIBUTE, XR_NAME_ATTRIBUTE, XR_PROPERTY_TAG, XR_VALUE_ATTRIBUTE
 
Fields inherited from interface org.apache.batik.util.XMLConstants
XLINK_NAMESPACE_URI, XLINK_PREFIX, 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_QUOTE, XML_ENTITY_AMP, XML_ENTITY_APOS, XML_ENTITY_GT, XML_ENTITY_LT, XML_ENTITY_QUOT, XML_EQUAL_QUOT, XML_EQUAL_SIGN, XML_LANG_ATTRIBUTE, XML_NAMESPACE_URI, XML_OPEN_TAG_END_CHILDREN, XML_OPEN_TAG_END_NO_CHILDREN, XML_OPEN_TAG_START, XML_PREFIX, XML_PRESERVE_VALUE, XML_SPACE, XML_SPACE_ATTRIBUTE, XML_TAB, XMLNS_NAMESPACE_URI, XMLNS_PREFIX
 
Constructor Summary
XMLTestReportProcessor()
          Default constructor
XMLTestReportProcessor(XMLTestReportProcessor.XMLReportConsumer consumer)
           
 
Method Summary
 void checkDirectory(java.io.File dir, java.lang.String errorCode)
          Checks that the input File represents a directory that can be used.
protected  void copy(java.io.File in, java.io.File out)
          Utility method.
protected  java.io.File createResourceFileForName(java.lang.String fileName)
          Untility method.
protected  java.io.File createResourceFileForName(java.lang.String fileName, int instance)
           
protected  java.lang.String encode(java.lang.String attrValue)
          Poor way of replacing '<', '>', '"', '&' and ''' in attribute values.
 java.io.File getReportDirectory()
          Returns the report directory
 java.io.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  java.lang.String makeTwoDigits(int i)
          Forces a two digit string
protected  void processEntry(org.apache.batik.test.TestReport.Entry entry, org.w3c.dom.Element descriptionElement, org.w3c.dom.Document reportDocument)
           
 void processReport(org.apache.batik.test.TestReport report)
          Recursively processes the input TestReport and any of its children.
protected  void processReport(org.apache.batik.test.TestReport report, org.w3c.dom.Element reportElement, org.w3c.dom.Document reportDocument)
          Recursively processes the input TestReport adding the report information to the input element.
protected  void replace(java.lang.StringBuffer s, char c, java.lang.String r)
           
protected  void serializeAttributes(org.w3c.dom.Element element, java.io.Writer writer)
           
protected  void serializeElement(org.w3c.dom.Element element, java.lang.String prefix, java.io.Writer writer)
           
protected  java.io.File serializeReport(org.w3c.dom.Element reportElement)
          Saves the XML document into a file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ERROR_REPORT_DIRECTORY_UNUSABLE

public static final java.lang.String ERROR_REPORT_DIRECTORY_UNUSABLE
Error message if report directory does not exist.

See Also:
Constant Field Values

ERROR_REPORT_RESOURCES_DIRECTORY_UNUSABLE

public static final java.lang.String ERROR_REPORT_RESOURCES_DIRECTORY_UNUSABLE
Error message if report resources directory does not exist.

See Also:
Constant Field Values

XML_TEST_REPORT_DEFAULT_DIRECTORY

public static final java.lang.String XML_TEST_REPORT_DEFAULT_DIRECTORY
Default report directory


XML_REPORT_DIRECTORY

public static final java.lang.String XML_REPORT_DIRECTORY
Directory where the XML report is created


XML_RESOURCES_DIRECTORY

public static final java.lang.String XML_RESOURCES_DIRECTORY
Directory where resources (e.g., images) referenced by the XML report are copied.


XML_TEST_REPORT_NAME

public static final java.lang.String XML_TEST_REPORT_NAME
Test report name


consumer

protected XMLTestReportProcessor.XMLReportConsumer consumer
The XMLReportConsumer instance is notified whenever this object generates a new report.


reportDate

protected java.lang.String reportDate
String encoding the date the report was generated.


reportDirectory

protected java.io.File reportDirectory
Directory into which this processor puts all files and resources.


xmlDirectory

protected java.io.File xmlDirectory
Directory into which XML files are created


xmlResourcesDirectory

protected java.io.File xmlResourcesDirectory
Directory into whichr resources refered to by XML files are created


EOL

private static java.lang.String EOL

PROPERTY_LINE_SEPARATOR

private static java.lang.String PROPERTY_LINE_SEPARATOR

PROPERTY_LINE_SEPARATOR_DEFAULT

private static java.lang.String PROPERTY_LINE_SEPARATOR_DEFAULT
Constructor Detail

XMLTestReportProcessor

public XMLTestReportProcessor()
Default constructor


XMLTestReportProcessor

public XMLTestReportProcessor(XMLTestReportProcessor.XMLReportConsumer consumer)
Method Detail

processReport

public void processReport(org.apache.batik.test.TestReport report)
                   throws org.apache.batik.test.TestException
Recursively processes the input TestReport and any of its children.

Specified by:
processReport in interface org.apache.batik.test.TestReportProcessor

checkDirectory

public void checkDirectory(java.io.File dir,
                           java.lang.String errorCode)
                    throws org.apache.batik.test.TestException
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.


initializeReportDirectories

public void initializeReportDirectories()
                                 throws org.apache.batik.test.TestException
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.


makeTwoDigits

protected java.lang.String makeTwoDigits(int i)
Forces a two digit string


getReportDirectory

public java.io.File getReportDirectory()
Returns the report directory


getReportResourcesDirectory

public java.io.File getReportResourcesDirectory()
By default, the report resources directory is given by a configuration variable.


processReport

protected void processReport(org.apache.batik.test.TestReport report,
                             org.w3c.dom.Element reportElement,
                             org.w3c.dom.Document reportDocument)
                      throws java.io.IOException
Recursively processes the input TestReport adding the report information to the input element.


processEntry

protected void processEntry(org.apache.batik.test.TestReport.Entry entry,
                            org.w3c.dom.Element descriptionElement,
                            org.w3c.dom.Document reportDocument)
                     throws java.io.IOException

createResourceFileForName

protected java.io.File createResourceFileForName(java.lang.String fileName)
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.png" where will be one or several digits.


createResourceFileForName

protected java.io.File createResourceFileForName(java.lang.String fileName,
                                                 int instance)

copy

protected void copy(java.io.File in,
                    java.io.File out)
             throws java.io.IOException
Utility method. Copies in to out


serializeReport

protected java.io.File serializeReport(org.w3c.dom.Element reportElement)
                                throws java.io.IOException
Saves the XML document into a file


serializeElement

protected void serializeElement(org.w3c.dom.Element element,
                                java.lang.String prefix,
                                java.io.Writer writer)
                         throws java.io.IOException

serializeAttributes

protected void serializeAttributes(org.w3c.dom.Element element,
                                   java.io.Writer writer)
                            throws java.io.IOException

encode

protected java.lang.String encode(java.lang.String attrValue)
Poor way of replacing '<', '>', '"', '&' and ''' in attribute values.


replace

protected void replace(java.lang.StringBuffer s,
                       char c,
                       java.lang.String r)