You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by vh...@apache.org on 2001/04/19 01:54:04 UTC
cvs commit: xml-batik/test-sources/org/apache/batik/test/xml XTRunConstants.java XMLTestSuiteRunner.java
vhardy 01/04/18 16:54:04
Modified: . build.xml
test-resources/org/apache/batik/test beSuite.xml
samplesRendering.xml
test-resources/org/apache/batik/test/resources
Messages.properties
test-resources/org/apache/batik/test/svg HTMLReport.xsl
test-sources/org/apache/batik/test
DefaultTestSuiteReport.java
test-sources/org/apache/batik/test/xml
XMLTestSuiteRunner.java
Added: test-resources/org/apache/batik/test regard.xml
unitTesting.xml
test-sources/org/apache/batik/test/xml XTRunConstants.java
Log:
Added concept of test run to allow various test suites to be more
easily reused by different test processors. A test run captures
the notion of run one or more test suites and processing their
reports with a specific testReportProcessor.
Improved HTML output for SVGRenderingAccuracyTest reports
Revision Changes Path
1.55 +2 -2 xml-batik/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/xml-batik/build.xml,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -r1.54 -r1.55
--- build.xml 2001/04/17 22:30:48 1.54
+++ build.xml 2001/04/18 23:54:01 1.55
@@ -45,7 +45,7 @@
[win32] .\build.bat help
- $Id: build.xml,v 1.54 2001/04/17 22:30:48 vhardy Exp $
+ $Id: build.xml,v 1.55 2001/04/18 23:54:01 vhardy Exp $
-->
@@ -596,7 +596,7 @@
<pathelement location="resources" />
<pathelement location="test-resources" />
</classpath>
- <arg line="test-resources/org/apache/batik/test/samplesRendering.xml"/>
+ <arg line="test-resources/org/apache/batik/test/regard.xml"/>
</java>
</target>
1.7 +1 -14 xml-batik/test-resources/org/apache/batik/test/beSuite.xml
Index: beSuite.xml
===================================================================
RCS file: /home/cvs/xml-batik/test-resources/org/apache/batik/test/beSuite.xml,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- beSuite.xml 2001/04/17 22:37:55 1.6
+++ beSuite.xml 2001/04/18 23:54:01 1.7
@@ -8,22 +8,9 @@
<!-- ========================================================================= -->
<!-- @author vincent.hardy@eng.sun.com -->
-<!-- @version $Id: beSuite.xml,v 1.6 2001/04/17 22:37:55 vhardy Exp $ -->
+<!-- @version $Id: beSuite.xml,v 1.7 2001/04/18 23:54:01 vhardy Exp $ -->
<!-- ========================================================================= -->
<testSuite name="SVG Basic Effectivity Test Suite">
- <testReportProcessor class="org.apache.batik.test.xml.XMLTestReportProcessor" >
- <arg class="org.apache.batik.test.xml.XSLXMLReportConsumer">
- <!-- Stylesheet -->
- <arg class="java.lang.String" value="file:test-resources/org/apache/batik/test/svg/HTMLReport.xsl" />
- <!-- Ouput Directory -->
- <arg class="java.lang.String" value="test-reports/html" />
- <!-- Output file prefix -->
- <arg class="java.lang.String" value="SVGRenderingAccuracyTestReport" />
- <!-- Output file suffix -->
- <arg class="java.lang.String" value=".html" />
- </arg>
- </testReportProcessor>
-
<!-- =================================================================== -->
<!-- Rendering -->
<!-- =================================================================== -->
1.5 +5 -28 xml-batik/test-resources/org/apache/batik/test/samplesRendering.xml
Index: samplesRendering.xml
===================================================================
RCS file: /home/cvs/xml-batik/test-resources/org/apache/batik/test/samplesRendering.xml,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- samplesRendering.xml 2001/04/18 18:30:06 1.4
+++ samplesRendering.xml 2001/04/18 23:54:02 1.5
@@ -8,33 +8,13 @@
<!-- ========================================================================= -->
<!-- @author vincent.hardy@eng.sun.com -->
-<!-- @version $Id: samplesRendering.xml,v 1.4 2001/04/18 18:30:06 tkormann Exp $ -->
+<!-- @version $Id: samplesRendering.xml,v 1.5 2001/04/18 23:54:02 vhardy Exp $ -->
<!-- ========================================================================= -->
-<testSuite name="REGARD">
- <testReportProcessor class="org.apache.batik.test.xml.XMLTestReportProcessor" >
- <arg class="org.apache.batik.test.xml.XSLXMLReportConsumer">
- <!-- Stylesheet -->
- <arg class="java.lang.String" value="file:test-resources/org/apache/batik/test/svg/HTMLReport.xsl" />
- <!-- Ouput Directory -->
- <arg class="java.lang.String" value="test-reports/html" />
- <!-- Output file prefix -->
- <arg class="java.lang.String" value="SVGRenderingAccuracyTestReport" />
- <!-- Output file suffix -->
- <arg class="java.lang.String" value=".html" />
- </arg>
- </testReportProcessor>
-
- <!-- ========================================================================== -->
- <!-- Validates that the SVGRenderingAccuracyTest class is operating as expected -->
+<testSuite name="samples and samples/test Rendering">
<!-- ========================================================================== -->
- <test class="org.apache.batik.test.svg.SVGRenderingAccuracyTestValidator" />
-
-
+ <!-- The following tests check correct rendering of images in the samples -->
+ <!-- directory. -->
<!-- ========================================================================== -->
- <!-- The following tests correspond to what regard used to do. -->
- <!-- ========================================================================== -->
- <!-- http://xml.apache.org/websrc/index.cgi/~checkout~/xml-batik/ -->
-
<test class="org.apache.batik.test.svg.SVGRenderingAccuracyTest">
<arg class="java.net.URL" value="file:samples/anne.svg" />
<arg class="java.net.URL" value="file:test-references/samples/anne.png" />
@@ -105,7 +85,6 @@
<property name="SaveVariation" class="java.io.File" value="test-references/samples/candidate-variation/batikLogo.png" />
</test>
-
<test class="org.apache.batik.test.svg.SVGRenderingAccuracyTest">
<arg class="java.net.URL" value="file:samples/batikMusic.svg" />
<arg class="java.net.URL" value="file:test-references/samples/batikMusic.png" />
@@ -113,7 +92,6 @@
<property name="SaveVariation" class="java.io.File" value="test-references/samples/candidate-variation/batikMusic.png" />
</test>
-
<test class="org.apache.batik.test.svg.SVGRenderingAccuracyTest">
<arg class="java.net.URL" value="file:samples/batikYin.svg" />
<arg class="java.net.URL" value="file:test-references/samples/batikYin.png" />
@@ -192,12 +170,11 @@
<property name="VariationURL" class="java.net.URL" value="file:test-references/samples/accepted-variation/textRotateShadows.png" />
<property name="SaveVariation" class="java.io.File" value="test-references/samples/candidate-variation/textRotateShadows.png" />
</test>
-
+ -->
<!-- ======================================================================= -->
<!-- Samples tests files -->
<!-- ======================================================================= -->
-
<test class="org.apache.batik.test.svg.SVGRenderingAccuracyTest">
<arg class="java.net.URL" value="file:samples/tests/display.svg" />
<arg class="java.net.URL" value="file:test-references/samples/tests/display.png" />
1.1 xml-batik/test-resources/org/apache/batik/test/regard.xml
Index: regard.xml
===================================================================
<!-- ========================================================================= -->
<!-- Copyright (C) The Apache Software Foundation. All rights reserved. -->
<!-- -->
<!-- This software is published under the terms of the Apache Software License -->
<!-- version 1.1, a copy of which has been included with this distribution in -->
<!-- the LICENSE file. -->
<!-- ========================================================================= -->
<!-- ========================================================================= -->
<!-- This file contains the set of tests that should be run for basic default -->
<!-- regression testing. -->
<!-- -->
<!-- @author vincent.hardy@eng.sun.com -->
<!-- @version $Id: regard.xml,v 1.1 2001/04/18 23:54:02 vhardy Exp $ -->
<!-- ========================================================================= -->
<testRun name="Batik Standard Regression Test Run">
<testRun name="REGARD">
<testReportProcessor class="org.apache.batik.test.xml.XMLTestReportProcessor" >
<arg class="org.apache.batik.test.xml.XSLXMLReportConsumer">
<!-- Stylesheet -->
<arg class="java.lang.String" value="file:test-resources/org/apache/batik/test/svg/HTMLReport.xsl" />
<!-- Ouput Directory -->
<arg class="java.lang.String" value="test-reports/html" />
<!-- Output file prefix -->
<arg class="java.lang.String" value="RegardResult" />
<!-- Output file suffix -->
<arg class="java.lang.String" value=".html" />
</arg>
</testReportProcessor>
<testSuite href="file:test-resources/org/apache/batik/test/samplesRendering.xml" />
<testSuite href="file:test-resources/org/apache/batik/test/unitTesting.xml" />
</testRun>
</testRun>
1.1 xml-batik/test-resources/org/apache/batik/test/unitTesting.xml
Index: unitTesting.xml
===================================================================
<!-- ========================================================================= -->
<!-- Copyright (C) The Apache Software Foundation. All rights reserved. -->
<!-- -->
<!-- This software is published under the terms of the Apache Software License -->
<!-- version 1.1, a copy of which has been included with this distribution in -->
<!-- the LICENSE file. -->
<!-- ========================================================================= -->
<!-- ========================================================================= -->
<!-- @author vincent.hardy@eng.sun.com -->
<!-- @version $Id: unitTesting.xml,v 1.1 2001/04/18 23:54:02 vhardy Exp $ -->
<!-- ========================================================================= -->
<testSuite name="Test Module - Unit Testing">
<!-- ========================================================================== -->
<!-- Validates that the SVGRenderingAccuracyTest class is operating as expected -->
<!-- ========================================================================== -->
<test class="org.apache.batik.test.svg.SVGRenderingAccuracyTestValidator" />
</testSuite>
1.3 +8 -0 xml-batik/test-resources/org/apache/batik/test/resources/Messages.properties
Index: Messages.properties
===================================================================
RCS file: /home/cvs/xml-batik/test-resources/org/apache/batik/test/resources/Messages.properties,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Messages.properties 2001/04/13 22:58:58 1.2
+++ Messages.properties 2001/04/18 23:54:02 1.3
@@ -15,6 +15,9 @@
DefaultTestSuiteReport.entry.key.failed.child.test.report = \
Child Report
+DefaultTestSuiteReport.entry.key.passed.child.test.report = \
+Child Report
+
TestReport.entry.key.test.failure.exception.class = \
Internal test exception class
@@ -54,6 +57,11 @@
xml.XMLTestSuiteRunner.error.cannot.create.test.report.processor = \
Cannot build TestReportProcessor instance of class : {0}. \
+Got exception of class : {1} with messages {2} \
+and stack trace : {3}
+
+xml.XMLTestSuiteRunner.error.test.suite.loading.exception = \
+Got exception while loading test suite {0} \
Got exception of class : {1} with messages {2} \
and stack trace : {3}
1.2 +55 -19 xml-batik/test-resources/org/apache/batik/test/svg/HTMLReport.xsl
Index: HTMLReport.xsl
===================================================================
RCS file: /home/cvs/xml-batik/test-resources/org/apache/batik/test/svg/HTMLReport.xsl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- HTMLReport.xsl 2001/04/13 22:58:58 1.1
+++ HTMLReport.xsl 2001/04/18 23:54:03 1.2
@@ -9,7 +9,7 @@
<!-- ========================================================================= -->
<!-- @author vincent.hardy@eng.sun.com -->
-<!-- @version $Id: HTMLReport.xsl,v 1.1 2001/04/13 22:58:58 vhardy Exp $ -->
+<!-- @version $Id: HTMLReport.xsl,v 1.2 2001/04/18 23:54:03 vhardy Exp $ -->
<!-- ========================================================================= -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xlink="http://www.w3.org/2000/xlink/namespace/" >
@@ -20,53 +20,89 @@
</head>
<body>
+ <table width="600" border="0" cellpadding="0" cellspacing="0" hspace="0" vspace="0">
+ <tr bgcolor="black"><td>
+ <table width="600" border="0" cellpadding="1" cellspacing="1" hspace="0" vspace="0">
+
<xsl:apply-templates/>
+ </table>
+ </td></tr>
+ </table>
</body>
</html>
</xsl:template>
<xsl:template match="testReport">
- <table width="600" border="0" cellpadding="0" cellspacing="0" hspace="0" vspace="0">
- <tr bgcolor="black"><td>
- <table width="600" border="0" cellpadding="0" cellspacing="1" hspace="0" vspace="0">
+ <xsl:param name="prefix" />
+ <xsl:variable name="childrenTests" select="description/testReport" />
+ <xsl:variable name="childrenTestsCount" select="count($childrenTests)" />
+
+ <xsl:choose>
+ <xsl:when test="$childrenTestsCount > 0 or @status='failed'">
<tr bgcolor="#cccccc">
- <td><b><xsl:value-of select="@testName" /></b></td>
+ <td colspan="2"><b><xsl:value-of select="$prefix" /><xsl:value-of select="@testName" /></b></td>
</tr>
<tr bgcolor="white">
- <td><xsl:value-of select="@status" /></td>
+ <td colspan="2">
+ <xsl:value-of select="$prefix" />
+
+ <!-- Plain Status -->
+ <xsl:value-of select="@status" />
+
+ <!-- If this is a composite report, add counts of success/failures -->
+ <xsl:choose>
+ <xsl:when test="$childrenTestsCount > 0" >
+ <xsl:variable name="passedChildrenTests"
+ select="description/testReport[attribute::status='passed']" />
+ -- Success Rate : <xsl:value-of select=" count($passedChildrenTests)" /> /
+ <xsl:value-of select="$childrenTestsCount" />
+ </xsl:when>
+ </xsl:choose>
+ </td>
</tr>
+
<tr bgcolor="white">
- <td><xsl:apply-templates/></td>
+ <td><xsl:apply-templates>
+ <xsl:with-param name="prefix" select="$prefix"/>
+ </xsl:apply-templates></td>
</tr>
- </table>
- </td></tr>
- </table>
+ </xsl:when>
+ </xsl:choose>
</xsl:template>
<xsl:template match="description">
- <table width="600" border="0" cellpadding="0" cellspacing="1" hspace="0" vspace="0">
- <xsl:apply-templates />
- </table>
+ <xsl:param name="prefix" select=" " />
+ <xsl:apply-templates select="genericEntry | uriEntry | fileEntry">
+ <xsl:with-param name="prefix" select="$prefix" />
+ </xsl:apply-templates>
+ <xsl:apply-templates select="testReport">
+ <xsl:with-param name="prefix">
+ <xsl:value-of select="$prefix"/>   
+ </xsl:with-param>
+ </xsl:apply-templates>
</xsl:template>
<xsl:template match="genericEntry">
- <tr>
- <td><xsl:value-of select="@key" /></td>
+ <xsl:param name="prefix" select=" " />
+ <tr bgcolor="white">
+ <td><xsl:value-of select="$prefix" /><xsl:value-of select="@key" /></td>
<td><xsl:value-of select="@value" /></td>
</tr>
</xsl:template>
<xsl:template match="uriEntry">
- <tr>
- <td><xsl:value-of select="@key" /></td>
+ <xsl:param name="prefix" select=" " />
+ <tr bgcolor="white" margin-left="50pt">
+ <td><xsl:value-of select="$prefix" /><xsl:value-of select="@key" /></td>
<xsl:variable name="value" select="@value" />
<td><a href="{$value}"><img height="150" src="{$value}" /></a></td>
</tr>
</xsl:template>
<xsl:template match="fileEntry">
- <tr>
- <td><xsl:value-of select="@key" /></td>
+ <xsl:param name="prefix" select=" " />
+ <tr bgcolor="white">
+ <td><xsl:value-of select="$prefix" /><xsl:value-of select="@key" /></td>
<xsl:variable name="value" select="@value" />
<td><a href="{$value}"><img height="150" src="{$value}" /></a></td>
</tr>
1.2 +18 -1 xml-batik/test-sources/org/apache/batik/test/DefaultTestSuiteReport.java
Index: DefaultTestSuiteReport.java
===================================================================
RCS file: /home/cvs/xml-batik/test-sources/org/apache/batik/test/DefaultTestSuiteReport.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DefaultTestSuiteReport.java 2001/04/10 22:10:25 1.1
+++ DefaultTestSuiteReport.java 2001/04/18 23:54:03 1.2
@@ -16,7 +16,7 @@
* for <tt>TestSuite</tt>
*
* @author <a href="mailto:vhardy@apache.lorg">Vincent Hardy</a>
- * @version $Id: DefaultTestSuiteReport.java,v 1.1 2001/04/10 22:10:25 vhardy Exp $
+ * @version $Id: DefaultTestSuiteReport.java,v 1.2 2001/04/18 23:54:03 vhardy Exp $
*/
public class DefaultTestSuiteReport implements TestReport {
/**
@@ -32,6 +32,12 @@
= "DefaultTestSuiteReport.entry.key.failed.child.test.report";
/**
+ * Entry for a passed child test report
+ */
+ public static final String ENTRY_KEY_PASSED_CHILD_TEST_REPORT
+ = "DefaultTestSuiteReport.entry.key.passed.child.test.report";
+
+ /**
* Set of <tt>TestReport</tt> coming from the <tt>TestSuite</tt>
*/
protected Vector reports = new Vector();
@@ -89,6 +95,17 @@
if(!childReport.hasPassed()){
TestReport.Entry entry
= new TestReport.Entry(Messages.formatMessage(ENTRY_KEY_FAILED_CHILD_TEST_REPORT, null),
+ childReport);
+ descs.addElement(entry);
+ }
+ }
+
+ iter = reports.iterator();
+ while(iter.hasNext()){
+ TestReport childReport = (TestReport)iter.next();
+ if(childReport.hasPassed()){
+ TestReport.Entry entry
+ = new TestReport.Entry(Messages.formatMessage(ENTRY_KEY_PASSED_CHILD_TEST_REPORT, null),
childReport);
descs.addElement(entry);
}
1.6 +205 -41 xml-batik/test-sources/org/apache/batik/test/xml/XMLTestSuiteRunner.java
Index: XMLTestSuiteRunner.java
===================================================================
RCS file: /home/cvs/xml-batik/test-sources/org/apache/batik/test/xml/XMLTestSuiteRunner.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XMLTestSuiteRunner.java 2001/04/16 22:42:37 1.5
+++ XMLTestSuiteRunner.java 2001/04/18 23:54:04 1.6
@@ -40,19 +40,23 @@
/**
* This class can be used to build and run a <tt>TestSuite</tt> from
- * an XML description following the "XML Test Suite" format, whose
- * constants are defined in the<tt>XTSConstants</tt> interface.
+ * an XML description following the "XML Test Run" and "XML Test Suite"
+ * formats, whose constants are defined in the <tt>XTRunConstants</tt>
+ * and <tt>XTSConstants</tt> interfaces.
*
- * In summary, this class builds a <tt>TestSuite</tt> which is
- * an aggregation of individual <tt>Test</tt> and <tt>TestSuite</tt>
- * and requests a set of <tt>TestResultProcessor</tt> to
- * process the <tt>TestResult</tt> that are produced by the
- * <tt>Test</tt> and <tt>TestSuite</tt> objects.
- *
+ * This class takes a "Test Run" XML description as an input. That
+ * description contains: <br />
+ * + pointers to a number of "Test Suite" XML descriptions,
+ * which contain the definition of the set of <tt>Tests</tt> to be
+ * run and their configuration.<br />
+ * + a description of the set of <tt>TestReportProcessor</tt> and
+ * their configuration that should be used to process the reports
+ * generated by the various <tt>TestSuites</tt>.<br />
+ *
* @author <a href="mailto:vhardy@apache.org">Vincent Hardy</a>
- * @version $Id: XMLTestSuiteRunner.java,v 1.5 2001/04/16 22:42:37 vhardy Exp $
+ * @version $Id: XMLTestSuiteRunner.java,v 1.6 2001/04/18 23:54:04 vhardy Exp $
*/
-public class XMLTestSuiteRunner implements XTSConstants{
+public class XMLTestSuiteRunner implements XTRunConstants, XTSConstants{
/**
* An error happened while processing a <tt>Test</tt>
* description.
@@ -65,6 +69,16 @@
= "xml.XMLTestSuiteRunner.error.cannot.create.test";
/**
+ * An error happened while loading a test suite document.
+ * {0} : the <testSuite> href value.
+ * {1} : the exception's class name
+ * {2} : exception's message
+ * {3} : exception's stack trace
+ */
+ public static final String TEST_SUITE_LOADING_EXCEPTION
+ = "xml.XMLTestSuiteRunner.error.test.suite.loading.exception";
+
+ /**
* An error happened while processing a <tt>TestreportProcessor</tt>
* description.
* {0} : the <testReportProcessor> "className" attribute value
@@ -114,7 +128,7 @@
if(child.getNodeType() == Node.ELEMENT_NODE){
Element childElement = (Element)child;
String tagName = childElement.getTagName().intern();
- if(tagName == XTS_TEST_REPORT_PROCESSOR_TAG){
+ if(tagName == XTRun_TEST_REPORT_PROCESSOR_TAG){
processors.addElement(buildProcessor(childElement));
}
}
@@ -138,7 +152,7 @@
String className
= element.getAttributeNS(null,
- XTS_CLASS_ATTRIBUTE);
+ XTRun_CLASS_ATTRIBUTE);
try{
return (TestReportProcessor)buildObject(className, element);
@@ -157,7 +171,107 @@
/**
* Builds a <tt>TestSuite</tt> from an input element.
- * This method assumes that element is a <testSuite>
+ * This method assumes that element is a <testRun>
+ * instance. The element is scanned for children
+ * <testSuite> elements which is loaded into
+ * a <tt>Test</tt> and composited into a <tt>TestSuite</tt>
+ */
+ protected DefaultTestSuite buildReferencedTestSuites(Element element)
+ throws TestException {
+ DefaultTestSuite testSuite = new DefaultTestSuite();
+
+ Element[] testSuites
+ = getChildrenByTagName(element, XTRun_TEST_SUITE_TAG);
+
+ int n = testSuites != null ? testSuites.length : 0;
+ for(int i=0; i<n; i++){
+ String suiteHref =
+ testSuites[i].getAttributeNS(null, XTRun_HREF_ATTRIBUTE);
+
+ testSuite.addTest( loadTestSuite(suiteHref) );
+ }
+
+ return testSuite;
+ }
+
+ /**
+ * Load the test suite defined by the input URI
+ */
+ protected TestSuite loadTestSuite(String testSuiteURI)
+ throws TestException{
+ Document testSuiteDocument = loadTestSuiteDocument(testSuiteURI);
+ return buildTestSuite(testSuiteDocument.getDocumentElement());
+ }
+
+ /**
+ * Loads the URI as a <tt>Document</tt>
+ */
+ protected Document loadTestSuiteDocument(String testSuiteURI)
+ throws TestException{
+ DocumentFactory df
+ = new SAXDocumentFactory(SVGDOMImplementation.getDOMImplementation(),
+ Messages.formatMessage(XML_PARSER, null));
+
+ Document doc = null;
+
+ try{
+ URL url = new URL(testSuiteURI);
+ doc = df.createDocument(null,
+ XTS_TEST_SUITE_TAG,
+ url.toString(),
+ url.openStream());
+ }catch(Exception e){
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ e.printStackTrace(pw);
+ throw new TestException(TEST_SUITE_LOADING_EXCEPTION,
+ new Object[] { testSuiteURI,
+ e.getClass().getName(),
+ e.getMessage(),
+ sw.toString() },
+ e);
+
+ }
+
+ return doc;
+ }
+
+ /**
+ * Gets all the children of a given type.
+ */
+ protected Element[] getChildrenByTagName(Element element,
+ String tagName)
+ {
+ tagName = tagName.intern();
+ Vector childrenWithTagName = new Vector();
+
+ NodeList children = element.getChildNodes();
+ if(children != null && children.getLength() > 0){
+ int n = children.getLength();
+ for(int i=0; i<n; i++){
+ Node child = children.item(i);
+ if(child.getNodeType() == Node.ELEMENT_NODE){
+ Element childElement = (Element)child;
+ String childTagName = childElement.getTagName().intern();
+ if(childTagName == tagName){
+ childrenWithTagName.addElement(childElement);
+ }
+ }
+ }
+ }
+
+ Element[] a = null;
+ if(childrenWithTagName.size() > 0){
+ a = new Element[childrenWithTagName.size()];
+ childrenWithTagName.copyInto(a);
+ }
+
+ return a;
+ }
+
+ /**
+ * Builds a <tt>TestSuite</tt> from an input element.
+ * This method assumes that element is a <testSuite>
* instance, as the input document should have been
* validated when loaded.
*/
@@ -168,9 +282,9 @@
String suiteName
= element.getAttributeNS(null,
- XTS_NAME_ATTRIBUTE);
+ XTRun_NAME_ATTRIBUTE);
- testSuite.setName(suiteName + "--" + testSuite.getName());
+ testSuite.setName(suiteName + " -- " + testSuite.getName());
NodeList children = element.getChildNodes();
if(children != null && children.getLength() > 0){
@@ -361,47 +475,43 @@
/**
* Runs the test suite described by the input
- * Document object.
+ * Document object. The root element on a
+ * 'Test Run' is <testRun> which can
+ * contain: <br />
+ * + children <testRun> elements.
+ * + <testReportProcessor> elements.
+ * + <testSuite> elements
+ * <br />
+ * Each <testRun> element is processed
+ * by loading
*/
public void run(Document doc)
throws TestException {
-
- //
- // First, extract the TestSuite to run
- // the actual tests.
- //
- TestSuite testSuite
- = buildTestSuite(doc.getDocumentElement());
-
- //
- // Now, get the set of TestReportProcessors
- // that can use the data
- //
- TestReportProcessor[] processors
- = extractTestReportProcessor(doc.getDocumentElement());
+ Element root = doc.getDocumentElement();
+ run(root);
+ }
- //
- // Run the test
- //
- TestReport report = null;
+ protected TestReport runTest(Test test)
+ throws TestException {
try{
- report = testSuite.run();
+ return test.run();
}catch(Exception e){
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
throw new TestException(TEST_SUITE_EXCEPTION,
- new Object[] { testSuite.getName(),
- testSuite.getClass().getName(),
+ new Object[] { test.getName(),
+ test.getClass().getName(),
e.getClass().getName(),
e.getMessage(),
sw.toString() },
e);
}
+ }
- //
- // Process the report
- //
+ protected void processReport(TestReport report,
+ TestReportProcessor[] processors)
+ throws TestException {
int n = processors.length;
int i=0;
try{
@@ -421,6 +531,58 @@
}
}
+ protected void run(Element testRunElement)
+ throws TestException{
+ //
+ // First, extract the TestSuite to run
+ // the actual tests.
+ //
+ DefaultTestSuite testSuite
+ = buildReferencedTestSuites(testRunElement);
+
+ //
+ // Set the testRun name on the top level testSuite
+ //
+ String name = testRunElement.getAttributeNS(null, XTRun_NAME_ATTRIBUTE);
+ testSuite.setName(name);
+
+ //
+ // Now, get the set of TestReportProcessors
+ // that can use the data
+ //
+ TestReportProcessor[] processors
+ = extractTestReportProcessor(testRunElement);
+
+ if(processors != null){
+ //
+ // Run the test
+ //
+ TestReport report = runTest(testSuite);
+
+ //
+ // Process the report
+ //
+ processReport(report, processors);
+ }
+
+ //
+ // Run child testRun element
+ //
+ run( getChildrenByTagName(testRunElement,
+ XTRun_TEST_RUN_TAG) );
+ }
+
+ protected void run(Element[] testRunElements)
+ throws TestException{
+ if(testRunElements != null
+ &&
+ testRunElements.length > 0){
+ for(int i=0; i<testRunElements.length; i++){
+ run(testRunElements[i]);
+ }
+ }
+ }
+
/**
* Displayed when the user passes no arguments to the command line.
*/
@@ -508,8 +670,9 @@
Document doc = null;
try{
+ System.err.println("Loading document ...");
doc = df.createDocument(null,
- XTS_TEST_SUITE_TAG,
+ XTRun_TEST_RUN_TAG,
url.toString(),
url.openStream());
}catch(Exception e){
@@ -522,6 +685,7 @@
}
try{
+ System.err.println("Running test run...");
XMLTestSuiteRunner r = new XMLTestSuiteRunner();
r.run(doc);
}catch(TestException e){
1.1 xml-batik/test-sources/org/apache/batik/test/xml/XTRunConstants.java
Index: XTRunConstants.java
===================================================================
/*****************************************************************************
* Copyright (C) The Apache Software Foundation. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Apache Software License *
* version 1.1, a copy of which has been included with this distribution in *
* the LICENSE file. *
*****************************************************************************/
package org.apache.batik.test.xml;
/**
* Contains constants for the XML Test Run (XTRun) syntax.
*
* @author <a href="mailto:vhardy@apache.org">Vincent Hardy</a>
* @version $Id: XTRunConstants.java,v 1.1 2001/04/18 23:54:04 vhardy Exp $
*/
public interface XTRunConstants {
String XTRun_NAMESPACE_URI
= "http://xml.apache.org/xml-batik/test/xtrun";
/////////////////////////////////////////////////////////////////////////
// XTRun tags
/////////////////////////////////////////////////////////////////////////
String XTRun_ARG_TAG = "arg";
String XTRun_PROPERTY_TAG = "property";
String XTRun_TEST_RUN_TAG = "testRun";
String XTRun_TEST_SUITE_TAG = "testSuite";
String XTRun_TEST_REPORT_PROCESSOR_TAG = "testReportProcessor";
/////////////////////////////////////////////////////////////////////////
// XTRun attributes
/////////////////////////////////////////////////////////////////////////
String XTRun_CLASS_ATTRIBUTE = "class";
String XTRun_HREF_ATTRIBUTE = "href";
String XTRun_NAME_ATTRIBUTE = "name";
String XTRun_VALUE_ATTRIBUTE = "value";
}
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org