 junitreport: Expose classpath and factory of internal XSLTProcess task.
This patch creates the nested XSLTProcess at creation of the
AggregateTransformer, not upon execution of the transformation. This way it
is much easier to simply wrap parts of the interface I'd like to expose,
like the new <classpath> and <factory> nested elements, but also the
existing <param> elements.
I haven't called XSLTProcess.init(), as the previous code didn't do that
either. I don't fully understand the difference between init() and a
constructor, but it might be a good thing to init the task somewhere.
The approach I chose is something like a whitelist delegation: the
XSLTProcess is a private member, and only selected methods of its interface
are wrapped and thus exposed to be configured. As an alternative, one could
do something like a blacklist delegation by deriving a class from
XSLTProcess and forbidding access to certain settings by ovverriding the
corresponding methods and throwing exceptions therein. In that case, one
might even turn the class derived from XSLTProcess into a nested <xslt>
element, which would be probably much clearer, as it would be configured in
the same way that a top-level <xslt> task is. I didn't choose this approach
in my patch for now.
10 years ago  junitreport: Expose classpath and factory of internal XSLTProcess task.
This patch creates the nested XSLTProcess at creation of the
AggregateTransformer, not upon execution of the transformation. This way it
is much easier to simply wrap parts of the interface I'd like to expose,
like the new <classpath> and <factory> nested elements, but also the
existing <param> elements.
I haven't called XSLTProcess.init(), as the previous code didn't do that
either. I don't fully understand the difference between init() and a
constructor, but it might be a good thing to init the task somewhere.
The approach I chose is something like a whitelist delegation: the
XSLTProcess is a private member, and only selected methods of its interface
are wrapped and thus exposed to be configured. As an alternative, one could
do something like a blacklist delegation by deriving a class from
XSLTProcess and forbidding access to certain settings by ovverriding the
corresponding methods and throwing exceptions therein. In that case, one
might even turn the class derived from XSLTProcess into a nested <xslt>
element, which would be probably much clearer, as it would be configured in
the same way that a top-level <xslt> task is. I didn't choose this approach
in my patch for now.
10 years ago  junitreport: Expose classpath and factory of internal XSLTProcess task.
This patch creates the nested XSLTProcess at creation of the
AggregateTransformer, not upon execution of the transformation. This way it
is much easier to simply wrap parts of the interface I'd like to expose,
like the new <classpath> and <factory> nested elements, but also the
existing <param> elements.
I haven't called XSLTProcess.init(), as the previous code didn't do that
either. I don't fully understand the difference between init() and a
constructor, but it might be a good thing to init the task somewhere.
The approach I chose is something like a whitelist delegation: the
XSLTProcess is a private member, and only selected methods of its interface
are wrapped and thus exposed to be configured. As an alternative, one could
do something like a blacklist delegation by deriving a class from
XSLTProcess and forbidding access to certain settings by ovverriding the
corresponding methods and throwing exceptions therein. In that case, one
might even turn the class derived from XSLTProcess into a nested <xslt>
element, which would be probably much clearer, as it would be configured in
the same way that a top-level <xslt> task is. I didn't choose this approach
in my patch for now.
10 years ago |
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
- <!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
- <html>
- <head>
- <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
- <title>JUnitReport Task</title>
- </head>
-
- <body>
-
- <h2 id="junitreport">JUnitReport</h2>
- <h3>Description</h3>
- Merge the individual XML files generated by the JUnit task and eventually apply
- a stylesheet on the resulting merged document to provide a browsable report of
- the testcases results.
-
- <p><strong>Note</strong>: This task depends on external libraries not
- included in the Apache Ant distribution. See <a href="../install.html#librarydependencies">Library Dependencies</a>
- for more information.</p>
-
- <h3>Requirements</h3>
-
- <p>The task needs Apache <a
- href="http://xml.apache.org/xalan-j/">Xalan 2.4.1+ or Xalan XSLTC</a>
- (JDK 1.4 contains a version of Xalan 2.x, while JDK 1.5 ships with a
- version of XSLTC). JDK 1.4.2-01 and later ships with a bundled
- Xalan 2.4.1+, meaning that JDKs prior to version 1.4.2-01 won't work
- out of the box. The table below summarize the compatibility status.
- </p>
- <table>
- <tr><th>Xalan</th><th>Sun JDK Bundle</th><th>Status<th></tr>
- <tr><td>2.4.1+</td><td>JDK 1.4.2-01+</td><td>OK</td></tr>
- <tr><td>XSLTC</td><td>JDK 1.5.x</td><td>OK</td></tr>
- <tr><td>2.x</td><td>JDK 1.4.x</td><td>DEPRECATED<br><i>Use ${ant.home}/etc/junit-frames-xalan1.xsl
- <br>Upgrade Xalan using the JDK endorsement mechanism</i></td></tr>
- </table>
-
- <p>In Ant 1.6.2, we had to decide between supporting Xalan 1/Xalan 2.4.1-
- and Xalan 2.4.1+/XSLTC, because there was no way to support both couples at the same
- time.</p>
- <p><em>Since Ant 1.7</em>, we dropped support for Xalan 1, because Xalan 1 was not
- available anymore for quite some time.</p>
-
- <h3>Parameters</h3>
- <table>
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">tofile</td>
- <td valign="top">The name of the XML file that will aggregate all individual
- XML testsuite previously generated by the JUnit task.</td>
- <td align="center" valign="top">No. Default to TESTS-TestSuites.xml</td>
- </tr>
- <tr>
- <td valign="top">todir</td>
- <td valign="top">The directory where should be written the file resulting
- from the individual XML testsuite aggregation.</td>
- <td align="center" valign="top">No. Default to current directory</td>
- </tr>
- </table>
- <h3 id="nested">Nested Elements</h3>
- <h4>fileset</h4>
- <p><code>junitreport</code> collects individual xml files generated by the JUnit
- task using the nested <a href="../Types/fileset.html"><code><FileSet></code></a>
- element.</p>
- <h4>report</h4>
- <p>Generate a browsable report based on the document created by the merge.</p>
- <h3>Parameters</h3>
- <table>
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">format</td>
- <td valign="top">The format of the generated report. Must be "noframes"
- or "frames".</td>
- <td align="center" valign="top">No, default to "frames"</td>
- </tr>
- <tr>
- <td valign="top">styledir</td>
- <td valign="top">The directory where the stylesheets are defined. They must
- be conforming to the following conventions:
- <ul>
- <li>frames format: the stylesheet must be named <i>junit-frames.xsl</i>, or <i>junit-frames-saxon.xsl if you are using Saxon 9+.</li>
- <li>noframes format: the stylesheet must be named <i>junit-noframes.xsl</i>, or <i>junit-noframes-saxon.xsl if you are using Saxon 9+.</li>
- </ul>
- </td>
- <td align="center" valign="top">No. Default to embedded stylesheets.</td>
- </tr>
- <tr>
- <td valign="top">todir</td>
- <td valign="top">The directory where the files resulting from the
- transformation should be written to.</td>
- <td align="center" valign="top">No. Default to current directory</td>
- </tr>
- </table>
- <p>Ant assumes the following concerning the <tt>frames</tt> and <tt>noframes</tt> formats:</p>
- <p>The <tt>frames</tt> format uses
- a stylesheet which is generating output <em>only</em> by redirecting.</p>
- <p>The
- <tt>noframes</tt> format does not use redirecting and generates one
- file called <tt>junit-noframes.html</tt>.</p>
- <p>Custom versions of <tt>junit-frames.xsl</tt> or <tt>junit-noframes.xsl</tt> must adhere to the above conventions.</p>
-
- <h3>Nested Element of the report tag</h3>
- <h4>param</h4>
- <em>Since Ant 1.7</em>the report tag supports nested param tags.
- These tags can pass XSL parameters to the stylesheet.
- <h3>Parameters</h3>
- <table>
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">name</td>
- <td valign="top">Name of the XSL parameter</td>
- <td align="center" valign="top">Yes</td>
- </tr>
- <tr>
- <td valign="top">expression</td>
- <td valign="top">Text value to be placed into the param.<br>
- Was originally intended to be an XSL expression.</td>
- <td align="center" valign="top">Yes</td>
- </tr>
- <tr>
- <td valign="top">if</td>
- <td valign="top">The param will only be passed <a href="../properties.html#if+unless">if this property is set</a>.</td>
- <td align="center" valign="top">No</td>
- </tr>
- <tr>
- <td valign="top">unless</td>
- <td valign="top">The param will not be passed <a href="../properties.html#if+unless">if this property is set</a>.</td>
- <td align="center" valign="top">No</td>
- </tr>
- </table>
-
- <p>The built-in stylesheets support the following parameters:</p>
- <table>
- <tr>
- <td valign="top"><b>XSL-Parameter</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">TITLE</td>
- <td valign="top">Title used in <title> and <h1> tags</td>
- <td align="center" valign="top">No. Defaults to <i>Unit Test Results.</i></td>
- </tr>
- </table>
-
- <h4>classpath</h4>
- <p><em>Since Ant 1.9.5</em>.
- Like for the <a href="../Tasks/style.html#classpath">XSLT task</a>,
- a nested <classpath> will be used to load the processor.</p>
-
- <h4>factory</h4>
- <p><em>Since Ant 1.9.5</em>.
- Like for the <a href="../Tasks/style.html#factory">XSLT task</a>,
- a nested <factory> can be used to specify factory settings.</p>
-
-
- <h3>Example of report</h3>
- <pre><junitreport todir="./reports">
- <fileset dir="./reports">
- <include name="TEST-*.xml"/>
- </fileset>
- <report format="frames" todir="./report/html"/>
- </junitreport></pre>
-
- <p>would generate a <tt>TESTS-TestSuites.xml</tt> file in the directory <tt>reports</tt> and
- generate the default framed report in the directory <tt>report/html</tt>.</p>
-
- <h3>Example of report with xsl params</h3>
- <pre>
- <junitreport todir="${outputdir}">
- <fileset dir="${jrdir}">
- <include name="TEST-*.xml"/>
- </fileset>
- <report todir="${outputdir}/html"
- styledir="junitreport"
- format="frames">
- <param name="key1" expression="value1"/>
- <param name="key2" expression="value2"/>
- </report>
- </junitreport></pre>
-
- <p>This example requires a file called <tt>junitreport/junit-frames.xsl</tt>.
- The XSL parameters key1 and key2 will be passed to the XSL transformation.</p>
-
- </body>
- </html>
|