You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by jg...@apache.org on 2012/03/06 00:05:21 UTC

svn commit: r1297271 - in /ant/core/trunk/src: etc/testcases/core/antclassloader.xml tests/junit/org/apache/tools/ant/AntClassLoaderTest.java

Author: jglick
Date: Mon Mar  5 23:05:21 2012
New Revision: 1297271

URL: http://svn.apache.org/viewvc?rev=1297271&view=rev
Log:
Random failures in AntClassLoaderTest traceable to different jobs overwriting the same test.jar.

Modified:
    ant/core/trunk/src/etc/testcases/core/antclassloader.xml
    ant/core/trunk/src/tests/junit/org/apache/tools/ant/AntClassLoaderTest.java

Modified: ant/core/trunk/src/etc/testcases/core/antclassloader.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/etc/testcases/core/antclassloader.xml?rev=1297271&r1=1297270&r2=1297271&view=diff
==============================================================================
--- ant/core/trunk/src/etc/testcases/core/antclassloader.xml (original)
+++ ant/core/trunk/src/etc/testcases/core/antclassloader.xml Mon Mar  5 23:05:21 2012
@@ -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">

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/AntClassLoaderTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/AntClassLoaderTest.java?rev=1297271&r1=1297270&r2=1297271&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/AntClassLoaderTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/AntClassLoaderTest.java Mon Mar  5 23:05:21 2012
@@ -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 
     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 
     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);