You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by qi...@apache.org on 2009/05/25 11:28:49 UTC
svn commit: r778363 -
/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLClassLoaderTest.java
Author: qiuxx
Date: Mon May 25 09:28:49 2009
New Revision: 778363
URL: http://svn.apache.org/viewvc?rev=778363&view=rev
Log:
Apply test case for HARMONY-6074,[classlib][luni] JAR referenced in a JAR's manifest 'Class-Path' that contains 'file' scheme URIs aren't loaded
Modified:
harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLClassLoaderTest.java
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLClassLoaderTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLClassLoaderTest.java?rev=778363&r1=778362&r2=778363&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLClassLoaderTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLClassLoaderTest.java Mon May 25 09:28:49 2009
@@ -18,6 +18,7 @@
package org.apache.harmony.luni.tests.java.net;
import java.io.File;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
@@ -29,6 +30,10 @@
import java.util.NoSuchElementException;
import java.util.StringTokenizer;
import java.util.Vector;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
import junit.framework.TestCase;
import tests.support.Support_Configuration;
@@ -477,4 +482,35 @@
in = this.getClass().getResourceAsStream("test%25.properties");
assertNull(in);
}
+
+ /**
+ * Regression test for HARMONY-6074
+ */
+ public void test_findClassLjava_lang_String_Jar_Class_Path() throws Exception{
+ File resources = Support_Resources.createTempFolder();
+ String resPath = resources.toString();
+ if (resPath.charAt(0) == '/' || resPath.charAt(0) == '\\') {
+ resPath = resPath.substring(1);
+ }
+
+ Support_Resources.copyFile(resources, "JarIndex", "hyts_11.jar");
+ Support_Resources.copyFile(resources, "JarIndex", "hyts_13.jar");
+
+ JarFile jarFile = new JarFile(resources.getAbsolutePath() + "/JarIndex/hyts_11.jar");
+ Manifest mf = jarFile.getManifest();
+ Attributes attrs = mf.getMainAttributes();
+ attrs.putValue("Class-Path", "file:/" + resPath + "/JarIndex/hyts_13.jar");
+
+ File mainJar = new File(resources.getAbsolutePath() + "/JarIndex/main.jar");
+ JarOutputStream jos = new JarOutputStream(new FileOutputStream(mainJar), mf);
+ jos.flush();
+ jos.close();
+ assertTrue(mainJar.exists());
+
+ URL[] urls = new URL[1];
+ urls[0] = new URL("file:/" + resPath + "/JarIndex/main.jar");
+ ucl = URLClassLoader.newInstance(urls, null);
+ assertNotNull(Class.forName("Main2", true, ucl));
+ }
+
}