harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r429247 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/net/URLStreamHandler.java test/java/tests/api/java/net/URLTest.java
Date Mon, 07 Aug 2006 06:02:32 GMT
Author: pyang
Date: Sun Aug  6 23:02:32 2006
New Revision: 429247

URL: http://svn.apache.org/viewvc?rev=429247&view=rev
Log:
Fix again for HARMONY-1040 ([classlib][luni] java.net.URLStreamHandler.hostEquals should return
true when two urls have the same host ip.)

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLStreamHandler.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/URLTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLStreamHandler.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLStreamHandler.java?rev=429247&r1=429246&r2=429247&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLStreamHandler.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLStreamHandler.java
Sun Aug  6 23:02:32 2006
@@ -374,10 +374,18 @@
 	 *         <code>false</code> if the hosts are different
 	 */
 	protected boolean hostsEqual(URL url1, URL url2) {
-		String host1 = url1.getHost(), host2 = url2.getHost();
-		return host1 == host2
-				|| (host1 != null && host1.equalsIgnoreCase(host2));
-	}
+        String host1 = url1.getHost(), host2 = url2.getHost();
+        if (host1 == host2 || (host1 != null && host1.equalsIgnoreCase(host2))) {
+            return true;
+        }
+        // Compare host address if the host name is not equal.
+        InetAddress address1 = getHostAddress(url1);
+        InetAddress address2 = getHostAddress(url2);
+        if (address1 != null && address1.equals(address2)) {
+            return true;
+        }
+        return false;
+    }
 
 	/**
 	 * Answers true if the urls refer to the same file. Compares the protocol,

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/URLTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/URLTest.java?rev=429247&r1=429246&r2=429247&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/URLTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/URLTest.java
Sun Aug  6 23:02:32 2006
@@ -768,22 +768,24 @@
 	/**
 	 * @tests java.net.URL#sameFile(java.net.URL)
 	 */
-	public void test_sameFileLjava_net_URL() {
-		// Test for method boolean java.net.URL.sameFile(java.net.URL)
-		try {
-			u = new URL("http://www.yahoo.com");
-			u1 = new URL("http", "www.yahoo.com", "");
-			assertTrue("Should be the same1", u.sameFile(u1));
-			u = new URL("http://www.yahoo.com/dir1/dir2/test.html#anchor1");
-			u1 = new URL("http://www.yahoo.com/dir1/dir2/test.html#anchor2");
-			assertTrue("Should be the same ", u.sameFile(u1));
-		} catch (Exception e) {
-		}
-	}
+	public void test_sameFileLjava_net_URL() throws Exception {
+        // Test for method boolean java.net.URL.sameFile(java.net.URL)
+        u = new URL("http://www.yahoo.com");
+        u1 = new URL("http", "www.yahoo.com", "");
+        assertTrue("Should be the same1", u.sameFile(u1));
+        u = new URL("http://www.yahoo.com/dir1/dir2/test.html#anchor1");
+        u1 = new URL("http://www.yahoo.com/dir1/dir2/test.html#anchor2");
+        assertTrue("Should be the same ", u.sameFile(u1));
+
+        // regression test for Harmony-1040
+        u = new URL("file", null, -1, "/d:/somedir/");
+        u1 = new URL("file:/d:/somedir/");
+        assertFalse(u.sameFile(u1));
+    }
 
 	/**
-	 * @tests java.net.URL#getContent()
-	 */
+     * @tests java.net.URL#getContent()
+     */
 	public void test_getContent() {
 		// Test for method java.lang.Object java.net.URL.getContent()
 		byte[] ba;
@@ -1197,12 +1199,12 @@
 			System.out.println("connection failed");
 		}
 
-		public List select(URI uri) {
-			isSelectCalled = true;
-			ArrayList proxyList = new ArrayList(1);
-			proxyList.add(Proxy.NO_PROXY);
-			return proxyList;
-		}
+		public List<Proxy> select(URI uri) {
+            isSelectCalled = true;
+            ArrayList<Proxy> proxyList = new ArrayList<Proxy>(1);
+            proxyList.add(Proxy.NO_PROXY);
+            return proxyList;
+        }
 	}
 
 	static class MockSecurityManager extends SecurityManager {



Mime
View raw message