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 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 1851346 2019-01-15 13:41:00Z ssteiner $
  • Field Details

    • ERROR_REPORT_DIRECTORY_UNUSABLE

      public static final String ERROR_REPORT_DIRECTORY_UNUSABLE
      Error message if report directory does not exist.
      See Also:
    • ERROR_REPORT_RESOURCES_DIRECTORY_UNUSABLE

      public static final String ERROR_REPORT_RESOURCES_DIRECTORY_UNUSABLE
      Error message if report resources directory does not exist.
      See Also:
    • XML_TEST_REPORT_DEFAULT_DIRECTORY

      public static final String XML_TEST_REPORT_DEFAULT_DIRECTORY
      Default report directory
    • XML_REPORT_DIRECTORY

      public static final String XML_REPORT_DIRECTORY
      Directory where the XML report is created
    • XML_RESOURCES_DIRECTORY

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

      public static final String XML_TEST_REPORT_NAME
      Test report name
    • consumer

      The XMLReportConsumer instance is notified whenever this object generates a new report.
    • reportDate

      protected String reportDate
      String encoding the date the report was generated.
    • reportDirectory

      protected File reportDirectory
      Directory into which this processor puts all files and resources.
    • xmlDirectory

      protected File xmlDirectory
      Directory into which XML files are created
    • xmlResourcesDirectory

      protected File xmlResourcesDirectory
      Directory into whichr resources refered to by XML files are created
    • EOL

      private static String EOL
    • PROPERTY_LINE_SEPARATOR

      private static String PROPERTY_LINE_SEPARATOR
    • PROPERTY_LINE_SEPARATOR_DEFAULT

      private static String PROPERTY_LINE_SEPARATOR_DEFAULT
  • Constructor Details

    • XMLTestReportProcessor

      public XMLTestReportProcessor()
      Default constructor
    • XMLTestReportProcessor

      public XMLTestReportProcessor(XMLTestReportProcessor.XMLReportConsumer consumer)
      Parameters:
      consumer - consumer for the XML report generated by this object. May be null.
  • Method Details

    • processReport

      public void processReport(TestReport report) throws TestException
      Recursively processes the input TestReport and any of its children.
      Specified by:
      processReport in interface TestReportProcessor
      Throws:
      TestException
    • checkDirectory

      public void checkDirectory(File dir, String errorCode) throws 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.
      Throws:
      TestException
    • initializeReportDirectories

      public void initializeReportDirectories() throws 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.
      Throws:
      TestException
    • makeTwoDigits

      protected String makeTwoDigits(int i)
      Forces a two digit string
    • getReportDirectory

      public File getReportDirectory()
      Returns the report directory
    • getReportResourcesDirectory

      public File 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 input TestReport adding 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

      protected File createResourceFileForName(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<n>.png" where <n> will be one or several digits.
    • createResourceFileForName

      protected File createResourceFileForName(String fileName, int instance)
    • copy

      protected void copy(File in, File out) throws IOException
      Utility method. Copies in to out
      Throws:
      IOException
    • serializeReport

      protected File serializeReport(Element reportElement) throws IOException
      Saves the XML document into a file
      Throws:
      IOException
    • serializeElement

      protected void serializeElement(Element element, String prefix, Writer writer) throws IOException
      Throws:
      IOException
    • serializeAttributes

      protected void serializeAttributes(Element element, Writer writer) throws IOException
      Throws:
      IOException
    • encode

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

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