You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2016/09/04 14:25:30 UTC
[1/9] ant git commit: update Xalan
Repository: ant
Updated Branches:
refs/heads/master b30a636ed -> 703aceddb
update Xalan
Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/bf3b31ac
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/bf3b31ac
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/bf3b31ac
Branch: refs/heads/master
Commit: bf3b31ac82fe844dfc2fabf865ad90a406767e90
Parents: 0c4f5b1
Author: Stefan Bodewig <bo...@apache.org>
Authored: Tue Aug 30 18:18:31 2016 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Tue Aug 30 18:18:31 2016 +0200
----------------------------------------------------------------------
lib/libraries.properties | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ant/blob/bf3b31ac/lib/libraries.properties
----------------------------------------------------------------------
diff --git a/lib/libraries.properties b/lib/libraries.properties
index d6aee6b..f2805fd 100644
--- a/lib/libraries.properties
+++ b/lib/libraries.properties
@@ -57,7 +57,7 @@ oro.version=2.0.8
regexp.version=1.3
servlet-api.version=2.3
which.version=1.0
-xalan.version=2.7.1
+xalan.version=2.7.2
xml-resolver.version=1.2
mail.version=1.4
#paired
[3/9] ant git commit: whitespace
Posted by bo...@apache.org.
whitespace
Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/bdba0f5c
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/bdba0f5c
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/bdba0f5c
Branch: refs/heads/master
Commit: bdba0f5c1f1647d8694fc95cbcf4c6457699ac0c
Parents: e290fd7
Author: Stefan Bodewig <bo...@apache.org>
Authored: Sun Sep 4 12:05:58 2016 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sun Sep 4 12:05:58 2016 +0200
----------------------------------------------------------------------
.../optional/junit/JUnitReportTest.java | 26 ++++++++++----------
1 file changed, 13 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ant/blob/bdba0f5c/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java
index c5b6feb..1551a5b 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java
@@ -40,11 +40,11 @@ import org.junit.Test;
*
*/
public class JUnitReportTest {
-
- @Rule
- public BuildFileRule buildRule = new BuildFileRule();
- @Before
+ @Rule
+ public BuildFileRule buildRule = new BuildFileRule();
+
+ @Before
public void setUp() {
buildRule.configureProject("src/etc/testcases/taskdefs/optional/junitreport.xml");
}
@@ -54,11 +54,11 @@ public class JUnitReportTest {
* output is selected via the default.
* Needs reports1 task from junitreport.xml.
*/
- @Test
+ @Test
public void testNoFileJUnitNoFrames() {
buildRule.executeTarget("reports1");
assertFalse("No file junit-noframes.html expected", (new File(System.getProperty("root"), "src/etc/testcases/taskdefs/optional/junitreport/test/html/junit-noframes.html").exists()));
-
+
}
public void assertIndexCreated() {
@@ -71,23 +71,23 @@ public class JUnitReportTest {
@Test
public void testEmptyFile() throws Exception {
- buildRule.executeTarget("testEmptyFile");
+ buildRule.executeTarget("testEmptyFile");
assertIndexCreated();
- assertContains("Required text not found in log", XMLResultAggregator.WARNING_EMPTY_FILE, buildRule.getLog());
+ assertContains("Required text not found in log", XMLResultAggregator.WARNING_EMPTY_FILE, buildRule.getLog());
}
@Test
public void testIncompleteFile() throws Exception {
buildRule.executeTarget("testIncompleteFile");
assertIndexCreated();
- assertContains("Required text not found in log", XMLResultAggregator.WARNING_IS_POSSIBLY_CORRUPTED, buildRule.getLog());
+ assertContains("Required text not found in log", XMLResultAggregator.WARNING_IS_POSSIBLY_CORRUPTED, buildRule.getLog());
}
-
+
@Test
public void testWrongElement() throws Exception {
buildRule.executeTarget("testWrongElement");
assertIndexCreated();
- assertContains("Required text not found in log", XMLResultAggregator.WARNING_INVALID_ROOT_ELEMENT, buildRule.getLog());
+ assertContains("Required text not found in log", XMLResultAggregator.WARNING_INVALID_ROOT_ELEMENT, buildRule.getLog());
}
// Bugzilla Report 34963
@@ -196,8 +196,8 @@ public class JUnitReportTest {
@Test
public void testWithParams() throws Exception {
- buildRule.executeTarget("testWithParams");
- assertContains("key1=value1,key2=value2", buildRule.getLog());
+ buildRule.executeTarget("testWithParams");
+ assertContains("key1=value1,key2=value2", buildRule.getLog());
File reportFile = new File(buildRule.getOutputDir(), "html/index.html");
// tests one the file object
assertTrue("No index.html present. Not generated?", reportFile.exists() );
[6/9] ant git commit: add support for TraX factory features
Posted by bo...@apache.org.
add support for TraX factory features
Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/cac55fbf
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/cac55fbf
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/cac55fbf
Branch: refs/heads/master
Commit: cac55fbfc097a36a2b6af3dc7a08c8418a9c02a5
Parents: 9b6f926
Author: Stefan Bodewig <bo...@apache.org>
Authored: Sun Sep 4 13:32:01 2016 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sun Sep 4 13:32:01 2016 +0200
----------------------------------------------------------------------
WHATSNEW | 3 +
manual/Tasks/style.html | 31 ++++++++-
.../apache/tools/ant/taskdefs/XSLTProcess.java | 73 ++++++++++++++++++--
.../ant/taskdefs/optional/TraXLiaison.java | 35 +++++++++-
4 files changed, 134 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ant/blob/cac55fbf/WHATSNEW
----------------------------------------------------------------------
diff --git a/WHATSNEW b/WHATSNEW
index cc199c2..3a23c1f 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -83,6 +83,9 @@ Other changes:
nativeheaderdir attribute.
Bugzilla Report 59905
+ * it is now possible to set features of the TraX factory used by <xslt>
+ and <junitreport>.
+
Changes from Ant 1.9.6 TO Ant 1.9.7
===================================
http://git-wip-us.apache.org/repos/asf/ant/blob/cac55fbf/manual/Tasks/style.html
----------------------------------------------------------------------
diff --git a/manual/Tasks/style.html b/manual/Tasks/style.html
index a1b9f2d..32fa621 100644
--- a/manual/Tasks/style.html
+++ b/manual/Tasks/style.html
@@ -395,7 +395,7 @@ Used to specify factory settings.
</tr>
</table>
<h3>Parameters specified as nested elements</h3>
-<h4>attribute </h4>
+<h4>attribute</h4>
<p>Used to specify settings of the processor factory.
The attribute names and values are entirely processor specific
so you must be aware of the implementation to figure them out.
@@ -435,6 +435,35 @@ And in Saxon 7.x:
</tr>
</table>
</blockquote>
+<h4>feature</h4>
+<p><em>since Ant 1.9.8</em></p>
+<p>Used to specify settings of the processor factory. The feature
+names are mostly processor specific so you must be aware of the
+implementation to figure them out. Read the documentation of your
+processor. The only feature all implementations are required to
+support
+is <code>http://javax.xml.XMLConstants/feature/secure-processing</code>.
+<blockquote>
+<h4>Parameters</h4>
+<table width="60%" border="1" cellpadding="2" cellspacing="0">
+ <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 feature</td>
+ <td align="center" valign="top">Yes</td>
+ </tr>
+ <tr>
+ <td valign="top">value</td>
+ <td valign="top">value of the feature. A boolean value
+ (i.e. permitted values are true,false,yes,no,on,off).</td>
+ <td align="center" valign="top">No, defaults to false</td>
+ </tr>
+</table>
+</blockquote>
</blockquote>
<h4>mapper</h4>
http://git-wip-us.apache.org/repos/asf/ant/blob/cac55fbf/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java b/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
index 4fe3126..6f54d1d 100644
--- a/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
+++ b/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
@@ -1462,7 +1462,12 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger {
/**
* the list of factory attributes to use for TraXLiaison
*/
- private final Vector attributes = new Vector();
+ private final List<Attribute> attributes = new ArrayList<Attribute>();
+
+ /**
+ * the list of factory features to use for TraXLiaison
+ */
+ private final List<Feature> features = new ArrayList<Feature>();
/**
* @return the name of the factory.
@@ -1484,7 +1489,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger {
* @param attr the newly created factory attribute
*/
public void addAttribute(final Attribute attr) {
- attributes.addElement(attr);
+ attributes.add(attr);
}
/**
@@ -1492,7 +1497,24 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger {
* @return the enumeration of attributes
*/
public Enumeration getAttributes() {
- return attributes.elements();
+ return Collections.enumeration(attributes);
+ }
+
+ /**
+ * Create an instance of a factory feature.
+ * @param feature the newly created feature
+ * @since Ant 1.9.8
+ */
+ public void addFeature(final Feature feature) {
+ features.add(feature);
+ }
+
+ /**
+ * The configured features.
+ * @since Ant 1.9.8
+ */
+ public Iterable<Feature> getFeatures() {
+ return features;
}
/**
@@ -1519,7 +1541,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger {
}
/**
- * @return the output property value.
+ * @return the attribute value.
*/
public Object getValue() {
return value;
@@ -1565,6 +1587,49 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger {
}
}
} // -- class Attribute
+
+ /**
+ * A feature for the TraX factory.
+ * @since Ant 1.9.8
+ */
+ public static class Feature {
+ private String name;
+ private boolean value;
+
+ public Feature() { }
+ public Feature(String name, boolean value) {
+ this.name = name;
+ this.value = value;
+ }
+
+ /**
+ * @param name the feature name.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * @param value the feature value.
+ */
+ public void setValue(boolean value) {
+ this.value = value;
+ }
+
+ /**
+ * @return the feature name.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @return the feature value.
+ */
+ public boolean getValue() {
+ return value;
+ }
+ }
} // -- class Factory
/**
http://git-wip-us.apache.org/repos/asf/ant/blob/cac55fbf/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java b/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java
index 8d9a44a..fea97d2 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java
@@ -28,8 +28,12 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Field;
import java.net.URL;
+import java.util.ArrayList;
import java.util.Enumeration;
+import java.util.HashMap;
import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
import java.util.Vector;
import javax.xml.parsers.ParserConfigurationException;
@@ -123,7 +127,10 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware
private final Hashtable<String, Object> params = new Hashtable<String, Object>();
/** factory attributes */
- private final Vector attributes = new Vector();
+ private final List<Object[]> attributes = new ArrayList<Object[]>();
+
+ /** factory features */
+ private final Map<String, Boolean> features = new HashMap<String, Boolean>();
/** whether to suppress warnings */
private boolean suppressWarnings = false;
@@ -436,10 +443,18 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware
// specific attributes for the transformer
final int size = attributes.size();
for (int i = 0; i < size; i++) {
- final Object[] pair = (Object[]) attributes.elementAt(i);
+ final Object[] pair = attributes.get(i);
tfactory.setAttribute((String) pair[0], pair[1]);
}
+ for (Map.Entry<String, Boolean> feature : features.entrySet()) {
+ try {
+ tfactory.setFeature(feature.getKey(), feature.getValue());
+ } catch (TransformerConfigurationException ex) {
+ throw new BuildException(ex);
+ }
+ }
+
if (uriResolver != null) {
tfactory.setURIResolver(uriResolver);
}
@@ -466,7 +481,17 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware
*/
public void setAttribute(final String name, final Object value) {
final Object[] pair = new Object[]{name, value};
- attributes.addElement(pair);
+ attributes.add(pair);
+ }
+
+ /**
+ * Set a custom feature for the JAXP factory implementation.
+ * @param name the feature name.
+ * @param value the value of the feature
+ * @since Ant 1.9.8
+ */
+ public void setFeature(final String name, final boolean value) {
+ features.put(name, value);
}
/**
@@ -625,6 +650,10 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware
(XSLTProcess.Factory.Attribute) attrs.nextElement();
setAttribute(attr.getName(), attr.getValue());
}
+ for (final XSLTProcess.Factory.Feature feature
+ : factory.getFeatures()) {
+ setFeature(feature.getName(), feature.getValue());
+ }
}
final XMLCatalog xmlCatalog = xsltTask.getXMLCatalog();
[7/9] ant git commit: use the undocumented TraX factory feature for
extensions
Posted by bo...@apache.org.
use the undocumented TraX factory feature for extensions
https://bz.apache.org/bugzilla/show_bug.cgi?id=60060
won't work until https://bugs.openjdk.java.net/browse/JDK-8165116 has
been fixed.
Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/7e55fea8
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/7e55fea8
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/7e55fea8
Branch: refs/heads/master
Commit: 7e55fea85d915ba19a4c8526d46dcf05fd415cf3
Parents: cac55fb
Author: Stefan Bodewig <bo...@apache.org>
Authored: Sun Sep 4 15:54:33 2016 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sun Sep 4 15:54:33 2016 +0200
----------------------------------------------------------------------
.../optional/junit/AggregateTransformer.java | 36 +++++++++++++++++++-
.../ant/taskdefs/optional/TraXLiaisonTest.java | 2 ++
2 files changed, 37 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ant/blob/7e55fea8/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java
----------------------------------------------------------------------
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 ec3506d..51be1b2 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
@@ -29,6 +29,8 @@ import java.util.Vector;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.TransformerFactoryConfigurationError;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
@@ -43,6 +45,7 @@ import org.apache.tools.ant.types.resources.FileResource;
import org.apache.tools.ant.types.resources.URLResource;
import org.apache.tools.ant.util.FileUtils;
import org.apache.tools.ant.util.JAXPUtils;
+import org.apache.tools.ant.util.JavaEnvUtils;
import org.w3c.dom.Document;
/**
@@ -98,6 +101,11 @@ public class AggregateTransformer {
private XSLTProcess xsltTask;
/**
+ * The JAXP factory used for the internal XSLT task.
+ */
+ private XSLTProcess.Factory xsltFactory;
+
+ /**
* Instance of a utility class to use for file operations.
*
* @since Ant 1.7
@@ -231,7 +239,8 @@ public class AggregateTransformer {
* @since Ant 1.9.5
*/
public XSLTProcess.Factory createFactory() {
- return xsltTask.createFactory();
+ return xsltFactory != null ? xsltFactory
+ : (xsltFactory = xsltTask.createFactory());
}
/**
@@ -266,6 +275,7 @@ public class AggregateTransformer {
paramx.setProject(task.getProject());
paramx.setName("output.dir");
paramx.setExpression(toDir.getAbsolutePath());
+ configureForRedirectExtension();
final long t0 = System.currentTimeMillis();
try {
xsltTask.execute();
@@ -343,4 +353,28 @@ public class AggregateTransformer {
return JAXPUtils.getSystemId(file);
}
+ private static final String JDK_INTERNAL_FACTORY = "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl";
+
+ /**
+ * If we end up using the JDK's own TraX factory on Java 9+, then
+ * set the features and attributes necessary to allow redirect
+ * extensions to be used.
+ * @since Ant 1.9.8
+ */
+ protected void configureForRedirectExtension() {
+ XSLTProcess.Factory factory = createFactory();
+ String factoryName = factory.getName();
+ if (factoryName == null) {
+ try {
+ factoryName = TransformerFactory.newInstance().getClass().getName();
+ } catch (TransformerFactoryConfigurationError exc) {
+ throw new BuildException(exc);
+ }
+ }
+ if (JDK_INTERNAL_FACTORY.equals(factoryName)
+ && JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9)) {
+ factory.addFeature(new XSLTProcess.Factory.Feature("http://www.oracle.com/xml/jaxp/properties/enableExtensionFunctions",
+ true));
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/ant/blob/7e55fea8/src/tests/junit/org/apache/tools/ant/taskdefs/optional/TraXLiaisonTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/TraXLiaisonTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/TraXLiaisonTest.java
index d4ff72a..f36a4db 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/TraXLiaisonTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/TraXLiaisonTest.java
@@ -67,6 +67,8 @@ public class TraXLiaisonTest extends AbstractXSLTLiaisonTest
}
File xsl = getFile("/taskdefs/optional/xalan-redirect-in.xsl");
liaison.setStylesheet(xsl);
+ ((TraXLiaison) liaison)
+ .setFeature("http://www.oracle.com/xml/jaxp/properties/enableExtensionFunctions", true);
File out = new File("xalan2-redirect-out-dummy.tmp");
File in = getFile("/taskdefs/optional/xsltliaison-in.xsl");
ClassLoader orig = Thread.currentThread().getContextClassLoader();
[2/9] ant git commit: line-ends
Posted by bo...@apache.org.
line-ends
Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/e290fd74
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/e290fd74
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/e290fd74
Branch: refs/heads/master
Commit: e290fd7431f9ba46a58071da50296277a04a7fed
Parents: bf3b31a
Author: Stefan Bodewig <bo...@apache.org>
Authored: Sun Sep 4 12:05:20 2016 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sun Sep 4 12:05:20 2016 +0200
----------------------------------------------------------------------
.../optional/junit/JUnitReportTest.java | 422 +++++++++----------
1 file changed, 211 insertions(+), 211 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ant/blob/e290fd74/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java
index 63eb197..c5b6feb 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java
@@ -1,211 +1,211 @@
-/*
- * 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.
- *
- */
-
-package org.apache.tools.ant.taskdefs.optional.junit;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.apache.tools.ant.AntAssert.assertContains;
-import static org.junit.Assert.fail;
-
-import java.io.File;
-import java.io.FileReader;
-import java.io.InputStream;
-import java.net.URL;
-
-import org.apache.tools.ant.BuildFileRule;
-import org.apache.tools.ant.util.FileUtils;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-/**
- * Small testcase for the junitreporttask.
- * First test added to reproduce an fault, still a lot to improve
- *
- */
-public class JUnitReportTest {
-
- @Rule
- public BuildFileRule buildRule = new BuildFileRule();
-
- @Before
- public void setUp() {
- buildRule.configureProject("src/etc/testcases/taskdefs/optional/junitreport.xml");
- }
-
- /**
- * Verifies that no empty junit-noframes.html is generated when frames
- * output is selected via the default.
- * Needs reports1 task from junitreport.xml.
- */
- @Test
- public void testNoFileJUnitNoFrames() {
- buildRule.executeTarget("reports1");
- assertFalse("No file junit-noframes.html expected", (new File(System.getProperty("root"), "src/etc/testcases/taskdefs/optional/junitreport/test/html/junit-noframes.html").exists()));
-
- }
-
- public void assertIndexCreated() {
- if (!new File(buildRule.getProject().getProperty("output"), "html/index.html").exists()) {
- fail("No file index file found");
- }
-
- }
-
-
- @Test
- public void testEmptyFile() throws Exception {
- buildRule.executeTarget("testEmptyFile");
- assertIndexCreated();
- assertContains("Required text not found in log", XMLResultAggregator.WARNING_EMPTY_FILE, buildRule.getLog());
- }
-
- @Test
- public void testIncompleteFile() throws Exception {
- buildRule.executeTarget("testIncompleteFile");
- assertIndexCreated();
- assertContains("Required text not found in log", XMLResultAggregator.WARNING_IS_POSSIBLY_CORRUPTED, buildRule.getLog());
- }
-
- @Test
- public void testWrongElement() throws Exception {
- buildRule.executeTarget("testWrongElement");
- assertIndexCreated();
- assertContains("Required text not found in log", XMLResultAggregator.WARNING_INVALID_ROOT_ELEMENT, buildRule.getLog());
- }
-
- // Bugzilla Report 34963
- @Test
- public void testStackTraceLineBreaks() throws Exception {
- buildRule.executeTarget("testStackTraceLineBreaks");
- assertIndexCreated();
- FileReader r = null;
- try {
- r = new FileReader(new File(buildRule.getOutputDir(), "html/sampleproject/coins/0_CoinTest.html"));
- String report = FileUtils.readFully(r);
- assertContains("output must contain <br>:\n" + report, "junit.framework.AssertionFailedError: DOEG<br>", report);
- assertContains("#51049: output must translate line breaks:\n" + report, "cur['line.separator'] = '\\r\\n';", report);
- } finally {
- FileUtils.close(r);
- }
- }
-
-
- // Bugzilla Report 38477
- @Test
- public void testSpecialSignsInSrcPath() throws Exception {
- buildRule.executeTarget("testSpecialSignsInSrcPath");
- File reportFile = new File(buildRule.getOutputDir(), "html/index.html");
- // tests one the file object
- assertTrue("No index.html present. Not generated?", reportFile.exists() );
- assertTrue("Cant read the report file.", reportFile.canRead() );
- assertTrue("File shouldn't be empty.", reportFile.length() > 0 );
- // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report
- URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) );
- InputStream reportStream = reportUrl.openStream();
- assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0);
- }
-
- @Test
- public void testSpecialSignsInHtmlPath() throws Exception {
- buildRule.executeTarget("testSpecialSignsInHtmlPath");
- File reportFile = new File(buildRule.getOutputDir(), "html# $%\u00A7&-!report/index.html");
- // tests one the file object
- assertTrue("No index.html present. Not generated?", reportFile.exists() );
- assertTrue("Cant read the report file.", reportFile.canRead() );
- assertTrue("File shouldn't be empty.", reportFile.length() > 0 );
- // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report
- URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) );
- InputStream reportStream = reportUrl.openStream();
- assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0);
- }
-
- //Bugzilla Report 39708
- @Test
- public void testWithStyleFromDir() throws Exception {
- buildRule.executeTarget("testWithStyleFromDir");
- File reportFile = new File(buildRule.getOutputDir(), "html/index.html");
- // tests one the file object
- assertTrue("No index.html present. Not generated?", reportFile.exists() );
- assertTrue("Cant read the report file.", reportFile.canRead() );
- assertTrue("File shouldn't be empty.", reportFile.length() > 0 );
- // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report
- URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) );
- InputStream reportStream = reportUrl.openStream();
- assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0);
- }
-
- //Bugzilla Report 40021
- @Test
- public void testNoFrames() throws Exception {
- buildRule.executeTarget("testNoFrames");
- File reportFile = new File(buildRule.getOutputDir(), "html/junit-noframes.html");
- // tests one the file object
- assertTrue("No junit-noframes.html present. Not generated?", reportFile.exists() );
- assertTrue("Cant read the report file.", reportFile.canRead() );
- assertTrue("File shouldn't be empty.", reportFile.length() > 0 );
- // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report
- URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) );
- InputStream reportStream = reportUrl.openStream();
- assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0);
- }
- //Bugzilla Report 39708
- @Test
- public void testWithStyleFromDirAndXslImport() throws Exception {
- buildRule.executeTarget("testWithStyleFromDirAndXslImport");
- File reportFile = new File(buildRule.getOutputDir(), "html/index.html");
- // tests one the file object
- assertTrue("No index.html present. Not generated?", reportFile.exists() );
- assertTrue("Cant read the report file.", reportFile.canRead() );
- assertTrue("File shouldn't be empty.", reportFile.length() > 0 );
- // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report
- URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) );
- InputStream reportStream = reportUrl.openStream();
- assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0);
- }
-
- @Test
- public void testWithStyleFromClasspath() throws Exception {
- buildRule.executeTarget("testWithStyleFromClasspath");
- File reportFile = new File(buildRule.getOutputDir(), "html/index.html");
- // tests one the file object
- assertTrue("No index.html present. Not generated?", reportFile.exists() );
- assertTrue("Cant read the report file.", reportFile.canRead() );
- assertTrue("File shouldn't be empty.", reportFile.length() > 0 );
- // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report
- URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) );
- InputStream reportStream = reportUrl.openStream();
- assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0);
- }
-
- @Test
- public void testWithParams() throws Exception {
- buildRule.executeTarget("testWithParams");
- assertContains("key1=value1,key2=value2", buildRule.getLog());
- File reportFile = new File(buildRule.getOutputDir(), "html/index.html");
- // tests one the file object
- assertTrue("No index.html present. Not generated?", reportFile.exists() );
- assertTrue("Cant read the report file.", reportFile.canRead() );
- assertTrue("File shouldn't be empty.", reportFile.length() > 0 );
- // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report
- URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) );
- InputStream reportStream = reportUrl.openStream();
- assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0);
- }
-}
+/*
+ * 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.
+ *
+ */
+
+package org.apache.tools.ant.taskdefs.optional.junit;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.apache.tools.ant.AntAssert.assertContains;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.InputStream;
+import java.net.URL;
+
+import org.apache.tools.ant.BuildFileRule;
+import org.apache.tools.ant.util.FileUtils;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+/**
+ * Small testcase for the junitreporttask.
+ * First test added to reproduce an fault, still a lot to improve
+ *
+ */
+public class JUnitReportTest {
+
+ @Rule
+ public BuildFileRule buildRule = new BuildFileRule();
+
+ @Before
+ public void setUp() {
+ buildRule.configureProject("src/etc/testcases/taskdefs/optional/junitreport.xml");
+ }
+
+ /**
+ * Verifies that no empty junit-noframes.html is generated when frames
+ * output is selected via the default.
+ * Needs reports1 task from junitreport.xml.
+ */
+ @Test
+ public void testNoFileJUnitNoFrames() {
+ buildRule.executeTarget("reports1");
+ assertFalse("No file junit-noframes.html expected", (new File(System.getProperty("root"), "src/etc/testcases/taskdefs/optional/junitreport/test/html/junit-noframes.html").exists()));
+
+ }
+
+ public void assertIndexCreated() {
+ if (!new File(buildRule.getProject().getProperty("output"), "html/index.html").exists()) {
+ fail("No file index file found");
+ }
+
+ }
+
+
+ @Test
+ public void testEmptyFile() throws Exception {
+ buildRule.executeTarget("testEmptyFile");
+ assertIndexCreated();
+ assertContains("Required text not found in log", XMLResultAggregator.WARNING_EMPTY_FILE, buildRule.getLog());
+ }
+
+ @Test
+ public void testIncompleteFile() throws Exception {
+ buildRule.executeTarget("testIncompleteFile");
+ assertIndexCreated();
+ assertContains("Required text not found in log", XMLResultAggregator.WARNING_IS_POSSIBLY_CORRUPTED, buildRule.getLog());
+ }
+
+ @Test
+ public void testWrongElement() throws Exception {
+ buildRule.executeTarget("testWrongElement");
+ assertIndexCreated();
+ assertContains("Required text not found in log", XMLResultAggregator.WARNING_INVALID_ROOT_ELEMENT, buildRule.getLog());
+ }
+
+ // Bugzilla Report 34963
+ @Test
+ public void testStackTraceLineBreaks() throws Exception {
+ buildRule.executeTarget("testStackTraceLineBreaks");
+ assertIndexCreated();
+ FileReader r = null;
+ try {
+ r = new FileReader(new File(buildRule.getOutputDir(), "html/sampleproject/coins/0_CoinTest.html"));
+ String report = FileUtils.readFully(r);
+ assertContains("output must contain <br>:\n" + report, "junit.framework.AssertionFailedError: DOEG<br>", report);
+ assertContains("#51049: output must translate line breaks:\n" + report, "cur['line.separator'] = '\\r\\n';", report);
+ } finally {
+ FileUtils.close(r);
+ }
+ }
+
+
+ // Bugzilla Report 38477
+ @Test
+ public void testSpecialSignsInSrcPath() throws Exception {
+ buildRule.executeTarget("testSpecialSignsInSrcPath");
+ File reportFile = new File(buildRule.getOutputDir(), "html/index.html");
+ // tests one the file object
+ assertTrue("No index.html present. Not generated?", reportFile.exists() );
+ assertTrue("Cant read the report file.", reportFile.canRead() );
+ assertTrue("File shouldn't be empty.", reportFile.length() > 0 );
+ // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report
+ URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) );
+ InputStream reportStream = reportUrl.openStream();
+ assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0);
+ }
+
+ @Test
+ public void testSpecialSignsInHtmlPath() throws Exception {
+ buildRule.executeTarget("testSpecialSignsInHtmlPath");
+ File reportFile = new File(buildRule.getOutputDir(), "html# $%\u00A7&-!report/index.html");
+ // tests one the file object
+ assertTrue("No index.html present. Not generated?", reportFile.exists() );
+ assertTrue("Cant read the report file.", reportFile.canRead() );
+ assertTrue("File shouldn't be empty.", reportFile.length() > 0 );
+ // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report
+ URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) );
+ InputStream reportStream = reportUrl.openStream();
+ assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0);
+ }
+
+ //Bugzilla Report 39708
+ @Test
+ public void testWithStyleFromDir() throws Exception {
+ buildRule.executeTarget("testWithStyleFromDir");
+ File reportFile = new File(buildRule.getOutputDir(), "html/index.html");
+ // tests one the file object
+ assertTrue("No index.html present. Not generated?", reportFile.exists() );
+ assertTrue("Cant read the report file.", reportFile.canRead() );
+ assertTrue("File shouldn't be empty.", reportFile.length() > 0 );
+ // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report
+ URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) );
+ InputStream reportStream = reportUrl.openStream();
+ assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0);
+ }
+
+ //Bugzilla Report 40021
+ @Test
+ public void testNoFrames() throws Exception {
+ buildRule.executeTarget("testNoFrames");
+ File reportFile = new File(buildRule.getOutputDir(), "html/junit-noframes.html");
+ // tests one the file object
+ assertTrue("No junit-noframes.html present. Not generated?", reportFile.exists() );
+ assertTrue("Cant read the report file.", reportFile.canRead() );
+ assertTrue("File shouldn't be empty.", reportFile.length() > 0 );
+ // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report
+ URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) );
+ InputStream reportStream = reportUrl.openStream();
+ assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0);
+ }
+ //Bugzilla Report 39708
+ @Test
+ public void testWithStyleFromDirAndXslImport() throws Exception {
+ buildRule.executeTarget("testWithStyleFromDirAndXslImport");
+ File reportFile = new File(buildRule.getOutputDir(), "html/index.html");
+ // tests one the file object
+ assertTrue("No index.html present. Not generated?", reportFile.exists() );
+ assertTrue("Cant read the report file.", reportFile.canRead() );
+ assertTrue("File shouldn't be empty.", reportFile.length() > 0 );
+ // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report
+ URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) );
+ InputStream reportStream = reportUrl.openStream();
+ assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0);
+ }
+
+ @Test
+ public void testWithStyleFromClasspath() throws Exception {
+ buildRule.executeTarget("testWithStyleFromClasspath");
+ File reportFile = new File(buildRule.getOutputDir(), "html/index.html");
+ // tests one the file object
+ assertTrue("No index.html present. Not generated?", reportFile.exists() );
+ assertTrue("Cant read the report file.", reportFile.canRead() );
+ assertTrue("File shouldn't be empty.", reportFile.length() > 0 );
+ // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report
+ URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) );
+ InputStream reportStream = reportUrl.openStream();
+ assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0);
+ }
+
+ @Test
+ public void testWithParams() throws Exception {
+ buildRule.executeTarget("testWithParams");
+ assertContains("key1=value1,key2=value2", buildRule.getLog());
+ File reportFile = new File(buildRule.getOutputDir(), "html/index.html");
+ // tests one the file object
+ assertTrue("No index.html present. Not generated?", reportFile.exists() );
+ assertTrue("Cant read the report file.", reportFile.canRead() );
+ assertTrue("File shouldn't be empty.", reportFile.length() > 0 );
+ // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report
+ URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) );
+ InputStream reportStream = reportUrl.openStream();
+ assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0);
+ }
+}
[9/9] ant git commit: Merge branch '1.9.x'
Posted by bo...@apache.org.
Merge branch '1.9.x'
Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/703acedd
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/703acedd
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/703acedd
Branch: refs/heads/master
Commit: 703aceddb6c444728107d47ceb5458154e6e39db
Parents: b30a636 2cec63f
Author: Stefan Bodewig <bo...@apache.org>
Authored: Sun Sep 4 16:25:14 2016 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sun Sep 4 16:25:14 2016 +0200
----------------------------------------------------------------------
WHATSNEW | 6 +
lib/libraries.properties | 2 +-
manual/Tasks/style.html | 61 ++-
.../apache/tools/ant/taskdefs/XSLTProcess.java | 86 +++-
.../ant/taskdefs/optional/TraXLiaison.java | 35 +-
.../optional/junit/AggregateTransformer.java | 36 +-
.../ant/taskdefs/optional/TraXLiaisonTest.java | 35 +-
.../optional/junit/JUnitReportTest.java | 438 ++++++++++---------
8 files changed, 476 insertions(+), 223 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ant/blob/703acedd/WHATSNEW
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ant/blob/703acedd/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ant/blob/703acedd/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java
----------------------------------------------------------------------
[8/9] ant git commit: allow Ant references to be used for xslt
attributes
Posted by bo...@apache.org.
allow Ant references to be used for xslt attributes
Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/2cec63f6
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/2cec63f6
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/2cec63f6
Branch: refs/heads/master
Commit: 2cec63f68a7d43b7645135df6ba8da3a84cce912
Parents: 7e55fea
Author: Stefan Bodewig <bo...@apache.org>
Authored: Sun Sep 4 16:24:18 2016 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sun Sep 4 16:24:18 2016 +0200
----------------------------------------------------------------------
WHATSNEW | 3 ++
manual/Tasks/style.html | 32 +++++++++++++++++++-
.../apache/tools/ant/taskdefs/XSLTProcess.java | 13 +++++++-
3 files changed, 46 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ant/blob/2cec63f6/WHATSNEW
----------------------------------------------------------------------
diff --git a/WHATSNEW b/WHATSNEW
index 3a23c1f..7a9e070 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -86,6 +86,9 @@ Other changes:
* it is now possible to set features of the TraX factory used by <xslt>
and <junitreport>.
+ * it is now possible to use references to Ant types and classloaders
+ built around Ant <path>s as values for TraX factory attributes.
+
Changes from Ant 1.9.6 TO Ant 1.9.7
===================================
http://git-wip-us.apache.org/repos/asf/ant/blob/2cec63f6/manual/Tasks/style.html
----------------------------------------------------------------------
diff --git a/manual/Tasks/style.html b/manual/Tasks/style.html
index 32fa621..5eda026 100644
--- a/manual/Tasks/style.html
+++ b/manual/Tasks/style.html
@@ -431,9 +431,39 @@ And in Saxon 7.x:
<tr>
<td valign="top">value</td>
<td valign="top">value of the attribute.</td>
- <td align="center" valign="top">Yes</td>
+ <td align="center" valign="middle" rowspan="3">Exactly one of these</td>
+ </tr>
+ <tr>
+ <td valign="top">valueref</td>
+ <td valign="top">value of the attribute is the value of the
+ project reference with the given id. <em>since Ant 1.9.8</em></td>
+ </tr>
+ <tr>
+ <td valign="top">classloaderforpath</td>
+ <td valign="top">value of the attribute is a classloader that uses
+ the classpath specified by a path that is the project reference
+ with the given id. <em>since Ant 1.9.8</em></td>
</tr>
</table>
+
+<h4>Examples</h4>
+
+<pre>
+ <path id="extension-path">
+ ...
+ </path>
+
+
+ <xslt ...>
+ <factory>
+ <attribute name="jdk.xml.transform.extensionClassLoader"
+ classloaderforpath="extension-path"/>
+ </factory>
+ </xslt ...>
+</pre>
+<p>Sets the classloader to use when loading extension functions to a
+ classloader using the <code>path</code> with the
+ id <code>extension-path</code>.
</blockquote>
<h4>feature</h4>
<p><em>since Ant 1.9.8</em></p>
http://git-wip-us.apache.org/repos/asf/ant/blob/2cec63f6/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java b/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
index 6f54d1d..f9c53ea 100644
--- a/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
+++ b/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
@@ -39,6 +39,7 @@ import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.DynamicConfigurator;
import org.apache.tools.ant.Project;
+import org.apache.tools.ant.ProjectComponent;
import org.apache.tools.ant.PropertyHelper;
import org.apache.tools.ant.types.CommandlineJava;
import org.apache.tools.ant.types.Environment;
@@ -53,6 +54,7 @@ import org.apache.tools.ant.types.resources.FileProvider;
import org.apache.tools.ant.types.resources.FileResource;
import org.apache.tools.ant.types.resources.Resources;
import org.apache.tools.ant.types.resources.Union;
+import org.apache.tools.ant.util.ClasspathUtils;
import org.apache.tools.ant.util.FileNameMapper;
import org.apache.tools.ant.util.FileUtils;
import org.apache.tools.ant.util.ResourceUtils;
@@ -1525,7 +1527,9 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger {
* <li>http://xml.apache.org/xalan/features/incremental (true|false) </li>
* </ul>
*/
- public static class Attribute implements DynamicConfigurator {
+ public static class Attribute
+ extends ProjectComponent
+ implements DynamicConfigurator {
/** attribute name, mostly processor specific */
private String name;
@@ -1582,6 +1586,13 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger {
this.value = value;
}
}
+ } else if ("valueref".equalsIgnoreCase(name)) {
+ this.value = getProject().getReference(value);
+ } else if ("classloaderforpath".equalsIgnoreCase(name)) {
+ this.value =
+ ClasspathUtils.getClassLoaderForPath(getProject(),
+ new Reference(getProject(),
+ value));
} else {
throw new BuildException("Unsupported attribute: " + name);
}
[5/9] ant git commit: some additional redirect-extension tests
Posted by bo...@apache.org.
some additional redirect-extension tests
https://bz.apache.org/bugzilla/show_bug.cgi?id=60060
Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/9b6f9269
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/9b6f9269
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/9b6f9269
Branch: refs/heads/master
Commit: 9b6f92697ff0c474da0d27d10321a3c5131c1098
Parents: e345ccf
Author: Stefan Bodewig <bo...@apache.org>
Authored: Sun Sep 4 12:23:17 2016 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sun Sep 4 12:23:17 2016 +0200
----------------------------------------------------------------------
.../ant/taskdefs/optional/TraXLiaisonTest.java | 33 +++++++++++++-
.../optional/junit/JUnitReportTest.java | 47 ++++++++++++++++++++
2 files changed, 79 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ant/blob/9b6f9269/src/tests/junit/org/apache/tools/ant/taskdefs/optional/TraXLiaisonTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/TraXLiaisonTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/TraXLiaisonTest.java
index 52605b4..d4ff72a 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/TraXLiaisonTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/TraXLiaisonTest.java
@@ -24,6 +24,8 @@ import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.InputStream;
import java.security.Permission;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.TransformerFactoryConfigurationError;
import junit.framework.AssertionFailedError;
@@ -57,7 +59,7 @@ public class TraXLiaisonTest extends AbstractXSLTLiaisonTest
}
@Test
- public void testXalan2Redirect() throws Exception {
+ public void testXalan2RedirectViaJDKFactory() throws Exception {
try {
getClass().getClassLoader().loadClass("org.apache.xalan.lib.Redirect");
} catch (Exception exc) {
@@ -91,6 +93,35 @@ public class TraXLiaisonTest extends AbstractXSLTLiaisonTest
}
@Test
+ public void testXalan2RedirectViaXalan() throws Exception {
+ try {
+ getClass().getClassLoader().loadClass("org.apache.xalan.lib.Redirect");
+ } catch (Exception exc) {
+ Assume.assumeNoException("xalan redirect is not on the classpath", exc);
+ }
+ try {
+ String factoryName = TransformerFactory.newInstance().getClass().getName();
+ Assume.assumeTrue("TraxFactory is " + factoryName + " and not Xalan",
+ "org.apache.xalan.processor.TransformerFactoryImpl"
+ .equals(factoryName));
+ } catch (TransformerFactoryConfigurationError exc) {
+ throw new RuntimeException(exc);
+ }
+ File xsl = getFile("/taskdefs/optional/xalan-redirect-in.xsl");
+ liaison.setStylesheet(xsl);
+ File out = new File("xalan2-redirect-out-dummy.tmp");
+ File in = getFile("/taskdefs/optional/xsltliaison-in.xsl");
+ try {
+ liaison.addParam("xalan-version", "2");
+ System.setSecurityManager(new SecurityManager() {public void checkPermission(Permission perm) {}});
+ liaison.transform(in, out);
+ } finally {
+ out.delete();
+ System.setSecurityManager(null);
+ }
+ }
+
+ @Test
public void testMultipleTransform() throws Exception {
File xsl = getFile("/taskdefs/optional/xsltliaison-in.xsl");
liaison.setStylesheet(xsl);
http://git-wip-us.apache.org/repos/asf/ant/blob/9b6f9269/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java
index 8737a94..a7ebbc6 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java
@@ -23,14 +23,19 @@ import static org.junit.Assert.assertTrue;
import static org.apache.tools.ant.AntAssert.assertContains;
import static org.junit.Assert.fail;
+import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileReader;
import java.io.InputStream;
import java.io.IOException;
import java.net.URL;
+import java.security.Permission;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.TransformerFactoryConfigurationError;
import org.apache.tools.ant.BuildFileRule;
import org.apache.tools.ant.util.FileUtils;
+import org.junit.Assume;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -177,4 +182,46 @@ public class JUnitReportTest {
assertContains("key1=value1,key2=value2", buildRule.getLog());
commonIndexFileAssertions();
}
+
+ @Test
+ public void testWithSecurityManagerAndXalanFactory() throws Exception {
+ try {
+ String factoryName = TransformerFactory.newInstance().getClass().getName();
+ Assume.assumeTrue("TraxFactory is " + factoryName + " and not Xalan",
+ "org.apache.xalan.processor.TransformerFactoryImpl"
+ .equals(factoryName));
+ } catch (TransformerFactoryConfigurationError exc) {
+ throw new RuntimeException(exc);
+ }
+ try {
+ System.setSecurityManager(new SecurityManager() {public void checkPermission(Permission perm) {}});
+ buildRule.executeTarget("testWithStyleFromClasspath");
+ commonIndexFileAssertions();
+ } finally {
+ System.setSecurityManager(null);
+ }
+ }
+
+ @Test
+ public void testWithSecurityManagerAndJDKFactory() throws Exception {
+ ClassLoader orig = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(new ClassLoader(ClassLoader.getSystemClassLoader().getParent()) {
+ public InputStream getResourceAsStream(String name) {
+ if (name.startsWith("META-INF/services/")) {
+ // work around JAXP #6723276 in JDK 6
+ return new ByteArrayInputStream(new byte[0]);
+ }
+ return super.getResourceAsStream(name);
+ }
+ });
+ System.setSecurityManager(new SecurityManager() {public void checkPermission(Permission perm) {}});
+ buildRule.executeTarget("testWithStyleFromClasspath");
+ commonIndexFileAssertions();
+ } finally {
+ System.setSecurityManager(null);
+ Thread.currentThread().setContextClassLoader(orig);
+ }
+ }
+
}
[4/9] ant git commit: refactor test
Posted by bo...@apache.org.
refactor test
Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/e345ccf5
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/e345ccf5
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/e345ccf5
Branch: refs/heads/master
Commit: e345ccf5393aae4b8ba9f21fc2faf288099fdc63
Parents: bdba0f5
Author: Stefan Bodewig <bo...@apache.org>
Authored: Sun Sep 4 12:15:49 2016 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sun Sep 4 12:15:49 2016 +0200
----------------------------------------------------------------------
.../optional/junit/JUnitReportTest.java | 95 +++++++-------------
1 file changed, 32 insertions(+), 63 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ant/blob/e345ccf5/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java
index 1551a5b..8737a94 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java
@@ -26,6 +26,7 @@ import static org.junit.Assert.fail;
import java.io.File;
import java.io.FileReader;
import java.io.InputStream;
+import java.io.IOException;
import java.net.URL;
import org.apache.tools.ant.BuildFileRule;
@@ -62,12 +63,33 @@ public class JUnitReportTest {
}
public void assertIndexCreated() {
- if (!new File(buildRule.getProject().getProperty("output"), "html/index.html").exists()) {
- fail("No file index file found");
+ try {
+ commonIndexFileAssertions();
+ } catch (IOException ex) {
+ throw new RuntimeException(ex);
}
+ }
+ private File commonIndexFileAssertions() throws IOException {
+ File reportFile = new File(buildRule.getOutputDir(), "html/index.html");
+ commonIndexFileAssertions(reportFile);
+ return reportFile;
}
+ private void commonIndexFileAssertions(File reportFile) throws IOException {
+ // tests one the file object
+ assertTrue("No index.html present. Not generated?", reportFile.exists() );
+ assertTrue("Cant read the report file.", reportFile.canRead() );
+ assertTrue("File shouldn't be empty.", reportFile.length() > 0 );
+ // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report
+ URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) );
+ InputStream reportStream = reportUrl.openStream();
+ try {
+ assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0);
+ } finally {
+ FileUtils.getFileUtils().close(reportStream);
+ }
+ }
@Test
public void testEmptyFile() throws Exception {
@@ -111,44 +133,21 @@ public class JUnitReportTest {
@Test
public void testSpecialSignsInSrcPath() throws Exception {
buildRule.executeTarget("testSpecialSignsInSrcPath");
- File reportFile = new File(buildRule.getOutputDir(), "html/index.html");
- // tests one the file object
- assertTrue("No index.html present. Not generated?", reportFile.exists() );
- assertTrue("Cant read the report file.", reportFile.canRead() );
- assertTrue("File shouldn't be empty.", reportFile.length() > 0 );
- // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report
- URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) );
- InputStream reportStream = reportUrl.openStream();
- assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0);
+ commonIndexFileAssertions();
}
@Test
public void testSpecialSignsInHtmlPath() throws Exception {
buildRule.executeTarget("testSpecialSignsInHtmlPath");
File reportFile = new File(buildRule.getOutputDir(), "html# $%\u00A7&-!report/index.html");
- // tests one the file object
- assertTrue("No index.html present. Not generated?", reportFile.exists() );
- assertTrue("Cant read the report file.", reportFile.canRead() );
- assertTrue("File shouldn't be empty.", reportFile.length() > 0 );
- // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report
- URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) );
- InputStream reportStream = reportUrl.openStream();
- assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0);
+ commonIndexFileAssertions(reportFile);
}
//Bugzilla Report 39708
@Test
public void testWithStyleFromDir() throws Exception {
buildRule.executeTarget("testWithStyleFromDir");
- File reportFile = new File(buildRule.getOutputDir(), "html/index.html");
- // tests one the file object
- assertTrue("No index.html present. Not generated?", reportFile.exists() );
- assertTrue("Cant read the report file.", reportFile.canRead() );
- assertTrue("File shouldn't be empty.", reportFile.length() > 0 );
- // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report
- URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) );
- InputStream reportStream = reportUrl.openStream();
- assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0);
+ commonIndexFileAssertions();
}
//Bugzilla Report 40021
@@ -156,56 +155,26 @@ public class JUnitReportTest {
public void testNoFrames() throws Exception {
buildRule.executeTarget("testNoFrames");
File reportFile = new File(buildRule.getOutputDir(), "html/junit-noframes.html");
- // tests one the file object
- assertTrue("No junit-noframes.html present. Not generated?", reportFile.exists() );
- assertTrue("Cant read the report file.", reportFile.canRead() );
- assertTrue("File shouldn't be empty.", reportFile.length() > 0 );
- // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report
- URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) );
- InputStream reportStream = reportUrl.openStream();
- assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0);
+ commonIndexFileAssertions(reportFile);
}
+
//Bugzilla Report 39708
@Test
public void testWithStyleFromDirAndXslImport() throws Exception {
buildRule.executeTarget("testWithStyleFromDirAndXslImport");
- File reportFile = new File(buildRule.getOutputDir(), "html/index.html");
- // tests one the file object
- assertTrue("No index.html present. Not generated?", reportFile.exists() );
- assertTrue("Cant read the report file.", reportFile.canRead() );
- assertTrue("File shouldn't be empty.", reportFile.length() > 0 );
- // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report
- URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) );
- InputStream reportStream = reportUrl.openStream();
- assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0);
+ commonIndexFileAssertions();
}
@Test
public void testWithStyleFromClasspath() throws Exception {
buildRule.executeTarget("testWithStyleFromClasspath");
- File reportFile = new File(buildRule.getOutputDir(), "html/index.html");
- // tests one the file object
- assertTrue("No index.html present. Not generated?", reportFile.exists() );
- assertTrue("Cant read the report file.", reportFile.canRead() );
- assertTrue("File shouldn't be empty.", reportFile.length() > 0 );
- // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report
- URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) );
- InputStream reportStream = reportUrl.openStream();
- assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0);
+ commonIndexFileAssertions();
}
@Test
public void testWithParams() throws Exception {
buildRule.executeTarget("testWithParams");
assertContains("key1=value1,key2=value2", buildRule.getLog());
- File reportFile = new File(buildRule.getOutputDir(), "html/index.html");
- // tests one the file object
- assertTrue("No index.html present. Not generated?", reportFile.exists() );
- assertTrue("Cant read the report file.", reportFile.canRead() );
- assertTrue("File shouldn't be empty.", reportFile.length() > 0 );
- // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report
- URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) );
- InputStream reportStream = reportUrl.openStream();
- assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0);
+ commonIndexFileAssertions();
}
}