ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r796667 - in /ant/core/trunk/src: etc/testcases/core/antclassloader.xml tests/junit/org/apache/tools/ant/AntClassLoaderTest.java
Date Wed, 22 Jul 2009 11:13:13 GMT
Author: bodewig
Date: Wed Jul 22 11:13:13 2009
New Revision: 796667

URL: http://svn.apache.org/viewvc?rev=796667&view=rev
Log:
passing test for PR 43994

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=796667&r1=796666&r2=796667&view=diff
==============================================================================
--- ant/core/trunk/src/etc/testcases/core/antclassloader.xml (original)
+++ ant/core/trunk/src/etc/testcases/core/antclassloader.xml Wed Jul 22 11:13:13 2009
@@ -17,9 +17,9 @@
 -->
 <project name="antclassloader-test" basedir=".">
 
-    <property name="tmp.dir" location="tmp space"/>
+    <property name="tmp.dir" location="${java.io.tmpdir}/tmp space"/>
     <!-- ant for germans -->
-    <property name="tmp.dir.nonascii" value="&#0227;nt"/>
+    <property name="tmp.dir.nonascii" value="${java.io.tmpdir}/&#0227;nt"/>
     <property name="ext.dir.relative" value="ext"/>
     <property name="main.jar" location="${tmp.dir}/main.jar"/>
     <property name="ext.jar.relative" value="${ext.dir.relative}/ext.jar"/>
@@ -54,5 +54,17 @@
         <delete dir="${tmp.dir.nonascii}" quiet="true"/>
     </target>
 
+    <target name="prepareGetPackageTest" depends="setup">
+      <mkdir dir="${tmp.dir.nonascii}/org/example"/>
+      <echo file="${tmp.dir.nonascii}/org/example/Foo.java"><![CDATA[
+package org.example;
+public class Foo {}
+]]></echo>
+      <javac srcdir="${tmp.dir.nonascii}"
+             destdir="${tmp.dir.nonascii}"/>
+      <jar destfile="${tmp.dir}/test.jar">
+        <fileset dir="${tmp.dir.nonascii}" includes="**/*.class"/>
+      </jar>
+    </target>
 
 </project>

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=796667&r1=796666&r2=796667&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 Wed Jul 22
11:13:13 2009
@@ -98,4 +98,25 @@
             fail("loader should not fail even if project finished");
         }
     }
+
+    public void testGetPackage() throws Exception {
+        executeTarget("prepareGetPackageTest");
+        Path myPath = new Path(getProject());
+        myPath.setLocation(new File(getProject().getProperty("tmp.dir")
+                                    + "/test.jar"));
+        getProject().setUserProperty("build.sysclasspath","ignore");
+        AntClassLoader loader = getProject().createClassLoader(myPath);
+        assertNotNull("should find class", loader.findClass("org.example.Foo"));
+        assertNotNull("should find package",
+                      new GetPackageWrapper(loader).getPackage("org.example"));
+    }
+
+    private static class GetPackageWrapper extends ClassLoader {
+        GetPackageWrapper(ClassLoader parent) {
+            super(parent);
+        }
+        public Package getPackage(String s) {
+            return super.getPackage(s);
+        }
+    }
 }



Mime
View raw message