From e9294e0a744ad2d48d1fa4da8a0fa16a30e4e2d3 Mon Sep 17 00:00:00 2001 From: Adam Retter Date: Sun, 4 Feb 2018 10:09:55 +0000 Subject: [PATCH] [bugfix] Allow Saxon to be used for junitreport XSL transformation This closes #57 pull request at github/apache/ant repo --- WHATSNEW | 3 + build.xml | 2 + contributors.xml | 4 + manual/Tasks/junitreport.html | 4 +- src/etc/ant-bin.wxs | 16 +- src/etc/junit-frames-saxon.xsl | 971 ++++++++++++++++++ src/etc/junit-noframes-saxon.xsl | 514 +++++++++ src/etc/poms/ant-junit/pom.xml | 2 + .../optional/junit/AggregateTransformer.java | 36 +- 9 files changed, 1535 insertions(+), 17 deletions(-) create mode 100644 src/etc/junit-frames-saxon.xsl create mode 100644 src/etc/junit-noframes-saxon.xsl diff --git a/WHATSNEW b/WHATSNEW index 75e48ff15..da5b9d421 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -10,6 +10,9 @@ Fixed bugs: * Fixed NullPointerException when a mappedresource is used in pathconvert Bugzilla Report 62076 + * Allow Saxon to be used for junitreport XSL transformation + Github Pull Request #57 + Changes from Ant 1.10.1 TO Ant 1.10.2 ===================================== diff --git a/build.xml b/build.xml index f9096f38b..f1aca800c 100644 --- a/build.xml +++ b/build.xml @@ -611,6 +611,8 @@ + + diff --git a/contributors.xml b/contributors.xml index fb92b6ba5..3ab3be8fe 100644 --- a/contributors.xml +++ b/contributors.xml @@ -38,6 +38,10 @@ Adam Bryzak + + Adam + Retter + Adam Sotona diff --git a/manual/Tasks/junitreport.html b/manual/Tasks/junitreport.html index 6c8e86192..79fd6590f 100644 --- a/manual/Tasks/junitreport.html +++ b/manual/Tasks/junitreport.html @@ -100,8 +100,8 @@ element.

The directory where the stylesheets are defined. They must be conforming to the following conventions: No. Default to embedded stylesheets. diff --git a/src/etc/ant-bin.wxs b/src/etc/ant-bin.wxs index 74ed74feb..f1f750850 100644 --- a/src/etc/ant-bin.wxs +++ b/src/etc/ant-bin.wxs @@ -436,16 +436,18 @@ - - - - + + + + + + - - - + + + diff --git a/src/etc/junit-frames-saxon.xsl b/src/etc/junit-frames-saxon.xsl new file mode 100644 index 000000000..f8de992fc --- /dev/null +++ b/src/etc/junit-frames-saxon.xsl @@ -0,0 +1,971 @@ + + + + + + + + + Unit Test Results. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + . + + + + + + + + + + + + + + + + + + + + + + + + + + + Standard Output from <xsl:value-of select="@name"/> + + +
+ + +
+
+ + + + + Standard Error from <xsl:value-of select="@name"/> + + +
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + <xsl:value-of select="$TITLE"/> + + + + + + + + + <h2>Frame Alert</h2> + <p> + This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. + </p> + + + + + + + + body { + font:normal 68% verdana,arial,helvetica; + color:#000000; + } + table tr td, table tr th { + font-size: 68%; + } + table.details tr th{ + font-weight: bold; + text-align:left; + background:#a6caf0; + } + table.details tr td{ + background:#eeeee0; + } + + p { + line-height:1.5em; + margin-top:0.5em; margin-bottom:1.0em; + } + h1 { + margin: 0px 0px 5px; font: 165% verdana,arial,helvetica + } + h2 { + margin-top: 1em; margin-bottom: 0.5em; font: bold 125% verdana,arial,helvetica + } + h3 { + margin-bottom: 0.5em; font: bold 115% verdana,arial,helvetica + } + h4 { + margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica + } + h5 { + margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica + } + h6 { + margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica + } + .Error { + font-weight:bold; color:red; + } + .Failure { + font-weight:bold; color:purple; + } + .Properties { + text-align:right; + } + + + + + + + + + + All Failures + + + All Errors + + + All Skipped + + + All Tests + + + + + Unit Test Results: <xsl:value-of select="$title"/> + + + + + + open('allclasses-frame.html','classListFrame') + +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ + + + + + + . + + + Unit Test Results: <xsl:value-of select="$class.name"/> + + + + + + + + +

Class

+ + + + + +
+ + + +

Failures

+
+ +

Errors

+
+ +

Skipped

+
+ +

Tests

+
+
+ + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + +
+ + + + cur = TestCases['.'] = new Array(); + + + cur[''] = ''; + + + + + + + + + + + Unit Test Classes: <xsl:value-of select="$name"/> + + + + + + + + + +
+

+ + <none> +

+
+ +

Classes

+ + + + + + + +
+ +
+ + +
+ + + + + + + All Unit Test Classes + + + + + +

Classes

+ + + + +
+ + +
+ + + + + + + + + / + _.html + + + + + + + + + + + + + All Unit Test Packages + + + + + +

Home

+

Packages

+ + + + +
+ + +
+ + + + + + + <none> + + + + + + + + + + Unit Test Results: Summary + + + + + + open('allclasses-frame.html','classListFrame') + +

Summary

+ + + + + + + + + + + + + + + + + + + Error + Failure + Pass + + + + + + + + + +
TestsFailuresErrorsSkippedSuccess rateTime
+ + + + + + + +
+ + + + +
+ Note: failures are anticipated and checked for with assertions while errors are unanticipated. +
+ +

Packages

+ + + + + + + + + + + Error + Failure + Pass + + + + + + + + + + + + +
+ + <none> + + + + +
+ + +
+ + + + + + + + + + + + open('package-frame.html','classListFrame') + +

Package

+ + + + + +

Classes

+

+ + + + + +
+

+
+ + +
+ + + + + + + ../ + + + + + + ../ + + + + + + + + stylesheet.css + + + + + +

+ + + + + +
Designed for use with JUnit and Ant.
+
+
+ + + + + Name + Tests + Errors + Failures + Skipped + Time(s) + Time Stamp + Host + + + + + + + + + Class + + Name + Status + Type + Time(s) + + + + + + + + + + Error + Failure + Pass + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Error + Failure + TableRowColor + + + + + + + + + + + + + + + + + + + + + + Failure + + + + Error + + + + Skipped + + + + Success + + + + + + + + + + + + + + + + + + + + + + + + + + + + + N/A + + + + + +

+ + + + + + + +
+ + + + + + + + + + + + + + + 32 + + + + + + + + + + + + +
+ + + +
+ + +
+ + + +
+ + + +
+
+ + + + + + + + + + +
diff --git a/src/etc/junit-noframes-saxon.xsl b/src/etc/junit-noframes-saxon.xsl new file mode 100644 index 000000000..fd1d3c98e --- /dev/null +++ b/src/etc/junit-noframes-saxon.xsl @@ -0,0 +1,514 @@ + + + + + + +Unit Test Results. + + + + + + <xsl:value-of select="$TITLE"/> + + + + + + + + + + +
+ + + +
+ + + +
+ + + + + + +
+ + + + + + + + +

Packages

+ Note: package statistics are not computed recursively, they only sum up all of its testsuites numbers. + + + + + + + + + + + + + + + + + + Failure + Error + + + + + + + + + + + + +
+ + + +
+
+ + + + + + + + + + + + +

Package

+ + + + + + +
+ Back to top +

+

+ + + + + + + + +

TestCase

+ + + + + + + + + + +
+ +

+ + Back to top + + + + +

Summary

+ + + + + + + + + + + + + + + + + + + Failure + Error + + + + + + + + + + +
TestsFailuresErrorsSkippedSuccess rateTime
+ + + + + + + +
+ + + + +
+ Note: failures are anticipated and checked for with assertions while errors are unanticipated. +
+
+ + + + cur = TestCases['.'] = new Array(); + + + cur[''] = ''; + + + + + +

+ + + + + +
Designed for use with JUnit and Ant.
+
+
+ + + + Name + Tests + Errors + Failures + Skipped + Time(s) + + + + + + + Name + Tests + Errors + Failures + Skipped + Time(s) + Time Stamp + Host + + + + + + + Name + Status + Type + Time(s) + + + + + + + + + + + Failure + Error + + + + + + + + + + + + + + + + + + + + + + + + Error + + + + + + Failure + + + + Error + + + + Skipped + + + + Success + + + + + + + + + + + + + + + + + + + + + + + + + + + + N/A + + + + + + +

+ + + +
+ + +
+ + + + + + + + + + + + + + + 32 + + + + + + + + + + + + +
+ + + +
+ + +
+ + + +
+ + + +
+
+ + + + + + + + + + + +
diff --git a/src/etc/poms/ant-junit/pom.xml b/src/etc/poms/ant-junit/pom.xml index b7238d657..c1ca76c70 100644 --- a/src/etc/poms/ant-junit/pom.xml +++ b/src/etc/poms/ant-junit/pom.xml @@ -67,6 +67,8 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma + + diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java index 84afe3c8c..637792a5a 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java @@ -297,10 +297,7 @@ public class AggregateTransformer { * @return stylesheet as a resource */ protected Resource getStylesheet() { - String xslname = "junit-frames.xsl"; - if (NOFRAMES.equals(format)) { - xslname = "junit-noframes.xsl"; - } + final String xslname = getXslName(); if (styleDir == null) { // If style dir is not specified we have to retrieve // the stylesheet from the classloader @@ -313,6 +310,32 @@ public class AggregateTransformer { return new FileResource(new File(styleDir, xslname)); } + /** + * Gets the filename of the XSL stylesheet + * + * Will provide Xalan or Saxon specific + * stylesheets. + * + * @return The filename of the stylesheet + */ + private String getXslName() { + final String suffix; + + final String xsltFactoryName = xsltFactory == null ? null : xsltFactory.getName(); + if(xsltFactoryName != null && "net.sf.saxon.TransformerFactoryImpl".equals(xsltFactoryName)) { + suffix = "-saxon.xsl"; + } else { + suffix = ".xsl"; + } + final String xslname; + if (NOFRAMES.equals(format)) { + xslname = "junit-noframes" + suffix; + } else { + xslname = "junit-frames" + suffix; + } + return xslname; + } + /** check for invalid options * @throws BuildException if something goes wrong. */ @@ -335,10 +358,7 @@ public class AggregateTransformer { * not exist. */ protected String getStylesheetSystemId() throws IOException { - String xslname = "junit-frames.xsl"; - if (NOFRAMES.equals(format)) { - xslname = "junit-noframes.xsl"; - } + final String xslname = getXslName(); if (styleDir == null) { URL url = getClass().getResource("xsl/" + xslname); if (url == null) {