fixed by making the classloader used by checkForkedPath behave like a real forked classpath, thus completely isolated from the launching jvmmaster
@@ -10,6 +10,9 @@ Fixed bugs: | |||||
is 'true'. | is 'true'. | ||||
Bugzilla Report 60062 | Bugzilla Report 60062 | ||||
* The junit task when used with includeantruntime="no" was incorrectly | |||||
printing a warning about multiple versions of ant detected in path | |||||
Changes from Ant 1.9.10 TO Ant 1.9.11 | Changes from Ant 1.9.10 TO Ant 1.9.11 | ||||
===================================== | ===================================== | ||||
@@ -358,4 +358,19 @@ | |||||
</junit> | </junit> | ||||
</target> | </target> | ||||
<target name="testCheckForkedPath"> | |||||
<property name="includeantruntime" value="yes" /> | |||||
<!-- duplicate the Ant classes into a jar --> | |||||
<jar destfile="${output}/ant.jar" basedir="${antclasses}" /> | |||||
<junit fork="yes" haltonerror="true" haltonfailure="true" | |||||
showoutput="${showoutput}" includeantruntime="${includeantruntime}"> | |||||
<test name="org.example.junit.Output" /> | |||||
<classpath> | |||||
<pathelement location="../../../../../build/testcases" /> | |||||
<pathelement location="${junitjar}" /> | |||||
<pathelement location="${output}/ant.jar" /> | |||||
</classpath> | |||||
</junit> | |||||
</target> | |||||
</project> | </project> |
@@ -1395,7 +1395,8 @@ public class JUnitTask extends Task { | |||||
loader = | loader = | ||||
AntClassLoader.newAntClassLoader(null, getProject(), | AntClassLoader.newAntClassLoader(null, getProject(), | ||||
cmd.createClasspath(getProject()), | cmd.createClasspath(getProject()), | ||||
true); | |||||
false); | |||||
loader.setIsolated(true); | |||||
final String projectResourceName = | final String projectResourceName = | ||||
LoaderUtils.classNameToResource(Project.class.getName()); | LoaderUtils.classNameToResource(Project.class.getName()); | ||||
URL previous = null; | URL previous = null; | ||||
@@ -577,6 +577,36 @@ public class JUnitTaskTest { | |||||
} | } | ||||
} | } | ||||
private void setupCheckDuplicateTest() { | |||||
final String projectResourceName = | |||||
LoaderUtils.classNameToResource(Project.class.getName()); | |||||
final File antclasses = LoaderUtils.getResourceSource( | |||||
Project.class.getClassLoader(), projectResourceName); | |||||
final String testResourceName = | |||||
LoaderUtils.classNameToResource(junit.framework.Test.class.getName()); | |||||
final File junitJar = LoaderUtils.getResourceSource( | |||||
Project.class.getClassLoader(), testResourceName); | |||||
buildRule.getProject().setProperty("antclasses", antclasses.getAbsolutePath()); | |||||
buildRule.getProject().setProperty("junitjar", junitJar.getAbsolutePath()); | |||||
} | |||||
@Test | |||||
public void testCheckDuplicateAntJar() throws Exception { | |||||
setupCheckDuplicateTest(); | |||||
buildRule.executeTarget("testCheckForkedPath"); | |||||
assertTrue("Expecting the warning about the duplicate ant jar", | |||||
buildRule.getLog().contains("WARNING: multiple versions of ant detected in path for junit")); | |||||
} | |||||
@Test | |||||
public void testCheckNonDuplicateAntJar() throws Exception { | |||||
setupCheckDuplicateTest(); | |||||
buildRule.getProject().setProperty("includeantruntime", "no"); | |||||
buildRule.executeTarget("testCheckForkedPath"); | |||||
assertFalse("Unexpected warning about the duplicate ant jar", | |||||
buildRule.getLog().contains("WARNING: multiple versions of ant detected in path for junit")); | |||||
} | |||||
private void delete(File f) { | private void delete(File f) { | ||||
if (f.isDirectory()) { | if (f.isDirectory()) { | ||||
final File[] clds = f.listFiles(); | final File[] clds = f.listFiles(); | ||||