Browse Source

Make sure to set the context classloader to the AntClassLoader.

PR: 5006
Submitted by: mancarella@opoipi.bancaintesa.it (Stefano Mancarella)


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271433 13f79535-47bb-0310-9956-ffa450edef68
master
Stephane Bailliez 23 years ago
parent
commit
d3d1af8130
1 changed files with 5 additions and 3 deletions
  1. +5
    -3
      src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java

+ 5
- 3
src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java View File

@@ -195,7 +195,7 @@ public class JUnitTask extends Task {
* Tells this task to set the named property to "true" when there is a error in a test. * Tells this task to set the named property to "true" when there is a error in a test.
* This property is applied on all BatchTest (batchtest) and JUnitTest (test), * This property is applied on all BatchTest (batchtest) and JUnitTest (test),
* however, it can possibly be overriden by their own properties. * however, it can possibly be overriden by their own properties.
* @param value the name of the property to set in the event of an error.
* @param propertyName the name of the property to set in the event of an error.
*/ */
public void setErrorProperty(String propertyName) { public void setErrorProperty(String propertyName) {
Enumeration enum = allTests(); Enumeration enum = allTests();
@@ -223,7 +223,7 @@ public class JUnitTask extends Task {
* Tells this task to set the named property to "true" when there is a failure in a test. * Tells this task to set the named property to "true" when there is a failure in a test.
* This property is applied on all BatchTest (batchtest) and JUnitTest (test), * This property is applied on all BatchTest (batchtest) and JUnitTest (test),
* however, it can possibly be overriden by their own properties. * however, it can possibly be overriden by their own properties.
* @param value the name of the property to set in the event of an failure.
* @param propertyName the name of the property to set in the event of an failure.
*/ */
public void setFailureProperty(String propertyName) { public void setFailureProperty(String propertyName) {
Enumeration enum = allTests(); Enumeration enum = allTests();
@@ -603,9 +603,9 @@ public class JUnitTask extends Task {
if (sysProperties != null) { if (sysProperties != null) {
sysProperties.setSystem(); sysProperties.setSystem();
} }
AntClassLoader cl = null;
try { try {
log("Using System properties " + System.getProperties(), Project.MSG_VERBOSE); log("Using System properties " + System.getProperties(), Project.MSG_VERBOSE);
AntClassLoader cl = null;
Path classpath = commandline.getClasspath(); Path classpath = commandline.getClasspath();
if (classpath != null) { if (classpath != null) {
cl = new AntClassLoader(null, project, classpath, false); cl = new AntClassLoader(null, project, classpath, false);
@@ -616,6 +616,7 @@ public class JUnitTask extends Task {
cl.addSystemPackageRoot("junit"); cl.addSystemPackageRoot("junit");
// will cause trouble in JDK 1.1 if omitted // will cause trouble in JDK 1.1 if omitted
cl.addSystemPackageRoot("org.apache.tools.ant"); cl.addSystemPackageRoot("org.apache.tools.ant");
cl.setThreadContextLoader();
} }
runner = new JUnitTestRunner(test, test.getHaltonerror(), test.getFiltertrace(), test.getHaltonfailure(), cl); runner = new JUnitTestRunner(test, test.getHaltonerror(), test.getFiltertrace(), test.getHaltonfailure(), cl);
if (summary) { if (summary) {
@@ -646,6 +647,7 @@ public class JUnitTask extends Task {
if (sysProperties != null) { if (sysProperties != null) {
sysProperties.restoreSystem(); sysProperties.restoreSystem();
} }
cl.resetThreadContextLoader();
} }
} }




Loading…
Cancel
Save