Browse Source

Random failures in AntClassLoaderTest traceable to different jobs overwriting the same test.jar.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1297271 13f79535-47bb-0310-9956-ffa450edef68
master
Jesse N. Glick 13 years ago
parent
commit
d516870b6a
2 changed files with 14 additions and 13 deletions
  1. +4
    -3
      src/etc/testcases/core/antclassloader.xml
  2. +10
    -10
      src/tests/junit/org/apache/tools/ant/AntClassLoaderTest.java

+ 4
- 3
src/etc/testcases/core/antclassloader.xml View File

@@ -61,15 +61,16 @@ package org.example;
public class Foo {}
]]></echo>
<javac srcdir="${tmp.dir.nonascii}"
destdir="${tmp.dir.nonascii}"/>
<jar destfile="${tmp.dir}/test.jar">
destdir="${tmp.dir.nonascii}" source="1.4"/>
<tempfile property="test.jar" destdir="${tmp.dir}" suffix="test" prefix=".jar" deleteonexit="true"/>
<jar destfile="${test.jar}">
<fileset dir="${tmp.dir.nonascii}" includes="**/*.class"/>
</jar>
</target>

<target name="signTestJar" depends="prepareGetPackageTest">
<signjar alias="testonly" keystore="../testkeystore"
storepass="apacheant" jar="${tmp.dir}/test.jar"/>
storepass="apacheant" jar="${test.jar}"/>
</target>

<target name="createNonJar">


+ 10
- 10
src/tests/junit/org/apache/tools/ant/AntClassLoaderTest.java View File

@@ -20,7 +20,9 @@ package org.apache.tools.ant;

import java.io.File;
import java.io.PrintStream;
import java.net.URL;
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.util.FileUtils;

/**
* Test case for ant class loader
@@ -107,8 +109,7 @@ public class AntClassLoaderTest extends BuildFileTest {
public void testGetPackage() throws Exception {
executeTarget("prepareGetPackageTest");
Path myPath = new Path(getProject());
myPath.setLocation(new File(getProject().getProperty("tmp.dir")
+ "/test.jar"));
myPath.setLocation(new File(getProject().getProperty("test.jar")));
getProject().setUserProperty("build.sysclasspath","ignore");
loader = getProject().createClassLoader(myPath);
assertNotNull("should find class", loader.findClass("org.example.Foo"));
@@ -119,21 +120,20 @@ public class AntClassLoaderTest extends BuildFileTest {
public void testCodeSource() throws Exception {
executeTarget("prepareGetPackageTest");
Path myPath = new Path(getProject());
myPath.setLocation(new File(getProject().getProperty("tmp.dir")
+ "/test.jar"));
File testJar = new File(getProject().getProperty("test.jar"));
myPath.setLocation(testJar);
getProject().setUserProperty("build.sysclasspath","ignore");
loader = getProject().createClassLoader(myPath);
Class foo = loader.findClass("org.example.Foo");
String codeSourceLocation =
foo.getProtectionDomain().getCodeSource().getLocation().toString();
assertTrue(codeSourceLocation + " should point to test.jar",
codeSourceLocation.endsWith("test.jar"));
URL codeSourceLocation =
foo.getProtectionDomain().getCodeSource().getLocation();
assertEquals(codeSourceLocation + " should point to test.jar",
FileUtils.getFileUtils().getFileURL(testJar), codeSourceLocation);
}

public void testSignedJar() throws Exception {
executeTarget("signTestJar");
File jar = new File(getProject().getProperty("tmp.dir")
+ "/test.jar");
File jar = new File(getProject().getProperty("test.jar"));

Path myPath = new Path(getProject());
myPath.setLocation(jar);


Loading…
Cancel
Save