harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r735873 - /harmony/enhanced/classlib/trunk/modules/luni/src/test/impl/common/org/apache/harmony/luni/tests/java/net/URLClassLoaderImplTest.java
Date Mon, 19 Jan 2009 23:20:21 GMT
Author: ndbeyer
Date: Mon Jan 19 15:20:20 2009
New Revision: 735873

URL: http://svn.apache.org/viewvc?rev=735873&view=rev
Log:
Clean up test and make it more portable (work on windows) -     public void test_Constructor$Ljava_net_URLLjava_lang_ClassLoaderLjava_net_URLStreamHandlerFactory()
throws Exception {

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/test/impl/common/org/apache/harmony/luni/tests/java/net/URLClassLoaderImplTest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/impl/common/org/apache/harmony/luni/tests/java/net/URLClassLoaderImplTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/impl/common/org/apache/harmony/luni/tests/java/net/URLClassLoaderImplTest.java?rev=735873&r1=735872&r2=735873&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/impl/common/org/apache/harmony/luni/tests/java/net/URLClassLoaderImplTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/impl/common/org/apache/harmony/luni/tests/java/net/URLClassLoaderImplTest.java
Mon Jan 19 15:20:20 2009
@@ -17,60 +17,49 @@
 
 package org.apache.harmony.luni.tests.java.net;
 
-import java.io.File;
-import java.net.MalformedURLException;
+import java.net.URI;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.net.URLStreamHandler;
 import java.net.URLStreamHandlerFactory;
 
-import org.apache.harmony.luni.internal.net.www.protocol.jar.Handler;
-
 import junit.framework.TestCase;
 
-import tests.support.Support_Configuration;
-import tests.support.resource.Support_Resources;
+import org.apache.harmony.luni.internal.net.www.protocol.jar.Handler;
 
 /**
- *  Depends on:
- *    file://<basedir>/src/test/resources/org/apache/harmony/luni/tests/java/net/lf.jar
+ * Depends on: file://<basedir>/src/test/resources/org/apache/harmony/luni/tests/java/net/lf.jar
  */
 public class URLClassLoaderImplTest extends TestCase {
-    
-    private static final char SEP = File.separatorChar;
-    private static final URL BASE = URLClassLoaderImplTest.class.getClassLoader().getResource(".."+SEP+URLClassLoaderImplTest.class.getPackage().getName().replace('.',
SEP));
 
     /**
-     * @tests java.net.URLClassLoader#URLClassLoader(java.net.URL[],
-     *        java.lang.ClassLoader, java.net.URLStreamHandlerFactory)
+     * @tests java.net.URLClassLoader#URLClassLoader(java.net.URL[], java.lang.ClassLoader,
+     *        java.net.URLStreamHandlerFactory)
      */
-    public void test_Constructor$Ljava_net_URLLjava_lang_ClassLoaderLjava_net_URLStreamHandlerFactory()
{
+    public void test_Constructor$Ljava_net_URLLjava_lang_ClassLoaderLjava_net_URLStreamHandlerFactory()
+            throws Exception {
         class TestFactory implements URLStreamHandlerFactory {
             public URLStreamHandler createURLStreamHandler(String protocol) {
                 if ("jar".equals(protocol)) {
                     return new Handler();
-                } else {
-                    fail("Should be jar Handler. But " + protocol);
-                    return null;
                 }
-            }
 
+                fail("Should be jar Handler. But " + protocol);
+                return null;
+            }
         }
 
-        URLClassLoader ucl = null;
+        final URL base = getClass().getResource("lf.jar");
 
-        URL[] u = new URL[1];
-        try {
-            u[0] = new URL(BASE.toString() + SEP + "lf.jar");
-            ucl = new URLClassLoader(u, null, new TestFactory());
-            URL res = null;
-            res = ucl.findResource("swt.dll");
-
-            assertNotNull(res);
-            assertEquals("Failed", BASE.toString()+SEP+"lf.jar!"+SEP+"swt.dll", res.getFile());
-        } catch (MalformedURLException e) {
-            fail("should not be here. " + e);
-        }
+        final URL[] urls = { base };
+        final URLClassLoader ucl = new URLClassLoader(urls, null, new TestFactory());
+
+        final URL res = ucl.findResource("swt.dll");
+        assertNotNull(res);
+
+        final URI e = new URI("jar:" + base.toExternalForm() + "!/swt.dll");
+        final URI a = res.toURI();
+        assertEquals(e, a);
     }
 
 }



Mime
View raw message