harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r527860 - in /harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/net/JarURLConnection.java test/java/tests/api/java/net/HttpURLConnectionTest.java test/java/tests/api/java/net/JarURLConnectionTest.java
Date Thu, 12 Apr 2007 09:46:18 GMT
Author: pyang
Date: Thu Apr 12 02:46:16 2007
New Revision: 527860

URL: http://svn.apache.org/viewvc?view=rev&rev=527860
Log:
Apply patch for HARMONY-3614( [classlib][luni]add tests for java.net.JarURLConnecttion and
HttpURLConnection)

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/JarURLConnection.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/HttpURLConnectionTest.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/JarURLConnectionTest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/JarURLConnection.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/JarURLConnection.java?view=diff&rev=527860&r1=527859&r2=527860
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/JarURLConnection.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/JarURLConnection.java
Thu Apr 12 02:46:16 2007
@@ -129,7 +129,7 @@
      * @return java.util.jar.Manifest The JarFile's Manifest
      */
     public Manifest getManifest() throws java.io.IOException {
-        return getJarFile().getManifest();
+        return (Manifest)getJarFile().getManifest().clone();
     }
 
     /**

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/HttpURLConnectionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/HttpURLConnectionTest.java?view=diff&rev=527860&r1=527859&r2=527860
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/HttpURLConnectionTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/HttpURLConnectionTest.java
Thu Apr 12 02:46:16 2007
@@ -25,9 +25,11 @@
 import java.net.HttpURLConnection;
 import java.net.MalformedURLException;
 import java.net.ResponseCache;
+import java.net.SocketPermission;
 import java.net.URI;
 import java.net.URL;
 import java.net.URLConnection;
+import java.security.Permission;
 import java.util.ArrayList;
 import java.util.Hashtable;
 import java.util.List;
@@ -566,6 +568,29 @@
         assertFalse(isPutCalled);
         assertFalse(isAbortCalled);
         uc.disconnect();
+    }
+    
+    /**
+     * @tests java.net.URLConnection#getErrorStream()
+     */
+    public void test_getErrorStream() throws Exception {
+        uc.setDoOutput(true);
+        uc.connect();
+        assertEquals(200, uc.getResponseCode());        
+        // no error stream
+        assertNull(uc.getErrorStream());        
+        uc.disconnect();
+        assertNull(uc.getErrorStream());
+    }
+    
+    /**
+     * @tests java.net.URLConnection#getPermission()
+     */
+    public void test_Permission() throws Exception {
+        uc.connect();
+        Permission permission = uc.getPermission();
+        assertNotNull(permission);
+        permission.implies(new SocketPermission("localhost","connect"));
     }
 
     class MockNonCachedResponseCache extends ResponseCache {

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/JarURLConnectionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/JarURLConnectionTest.java?view=diff&rev=527860&r1=527859&r2=527860
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/JarURLConnectionTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/JarURLConnectionTest.java
Thu Apr 12 02:46:16 2007
@@ -29,6 +29,7 @@
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
 import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
 
@@ -230,6 +231,46 @@
         assertTrue(file.delete());
     }
 
+    /**
+     * @tests java.net.JarURLConnection#getManifest()
+     */
+    public void test_getManifest() throws Exception {
+        URL u = new URL("jar:" + BASE.toString() + "/lf.jar!/plus.bmp");
+        juc = (JarURLConnection) u.openConnection();
+        Manifest mf = juc.getManifest();
+        assertNotNull(mf);
+        // equal but not same manifest
+        assertEquals(mf,juc.getManifest());
+        assertNotSame(mf,juc.getManifest());
+        // same main attrubutes
+        assertEquals(juc.getMainAttributes(),mf.getMainAttributes());
+    }
+
+    /**
+     * @tests java.net.JarURLConnection#getCertificates()
+     */
+    public void test_getCertificates() throws Exception {
+        URL u = new URL("jar:"
+                + BASE.toString()+"/lf.jar!/plus.bmp");
+        juc = (JarURLConnection) u.openConnection();
+        // read incomplete, shall return null
+        assertNull(juc.getCertificates());
+        assertEquals("Returned incorrect JarEntry", "plus.bmp", juc
+                .getJarEntry().getName());
+        // read them all
+        InputStream is =juc.getInputStream();        
+        byte[] buf = new byte[80];
+        while(is.read(buf)>0);
+        // still return null for this type of file
+        assertNull(juc.getCertificates());
+        
+        URL fileURL = new URL("jar:" + BASE.toString()+"/lf.jar!/");
+        juc = (JarURLConnection)fileURL.openConnection();
+        is = juc.getJarFileURL().openStream();
+        while(is.read(buf)>0);
+        // null for this jar file
+        assertNull(juc.getCertificates());
+    }
 
 	protected void setUp() {
 	}



Mime
View raw message