You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by to...@apache.org on 2008/03/04 09:02:45 UTC

svn commit: r633384 [9/15] - in /harmony/enhanced/classlib/branches/java6: depends/build/platform/ depends/files/ depends/files/bcprov/ doc/ doc/classlib/ make/ make/linux.ia64/ make/linux.ppc32/ make/linux.ppc64/ make/linux.x86.libstdc++6/ make/linux....

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/NoRouteToHostExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/NoRouteToHostExceptionTest.java?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/NoRouteToHostExceptionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/NoRouteToHostExceptionTest.java Tue Mar  4 00:02:13 2008
@@ -21,50 +21,33 @@
 
 public class NoRouteToHostExceptionTest extends junit.framework.TestCase {
 
-	/**
-	 * @tests java.net.NoRouteToHostException#NoRouteToHostException()
-	 */
-	public void test_Constructor() {
-		// Test for method java.net.NoRouteToHostException()
+    /**
+     * @tests java.net.NoRouteToHostException#NoRouteToHostException()
+     */
+    public void test_Constructor() {
+        try {
+            if (true) {
+                throw new NoRouteToHostException();
+            }
+            fail("Failed to generate expected exception");
+        } catch (NoRouteToHostException e) {
+            // Expected
+        }
+    }
 
-		try {
-			if (true)
-				throw new NoRouteToHostException();
-		} catch (NoRouteToHostException e) {
-			return;
-		}
-		fail("Failed to generate expected exception");
-	}
-
-	/**
-	 * @tests java.net.NoRouteToHostException#NoRouteToHostException(java.lang.String)
-	 */
-	public void test_ConstructorLjava_lang_String() {
-		// Test for method java.net.NoRouteToHostException(java.lang.String)
-		// Cannot test correctly without changing some routing tables !!
-
-		try {
-			if (true)
-				throw new NoRouteToHostException("test");
-		} catch (NoRouteToHostException e) {
-			assertEquals("Threw exception with incorrect message", "test", e.getMessage()
-					);
-			return;
-		}
-		fail("Failed to generate expected exception");
-	}
-
-	/**
-	 * Sets up the fixture, for example, open a network connection. This method
-	 * is called before a test is executed.
-	 */
-	protected void setUp() {
-	}
-
-	/**
-	 * Tears down the fixture, for example, close a network connection. This
-	 * method is called after a test is executed.
-	 */
-	protected void tearDown() {
-	}
+    /**
+     * @tests java.net.NoRouteToHostException#NoRouteToHostException(java.lang.String)
+     */
+    public void test_ConstructorLjava_lang_String() {
+        // Cannot test correctly without changing some routing tables !!
+        try {
+            if (true) {
+                throw new NoRouteToHostException("test");
+            }
+            fail("Failed to generate expected exception");
+        } catch (NoRouteToHostException e) {
+            assertEquals("Threw exception with incorrect message", "test", e
+                    .getMessage());
+        }
+    }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketExceptionTest.java?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketExceptionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketExceptionTest.java Tue Mar  4 00:02:13 2008
@@ -21,45 +21,31 @@
 
 public class SocketExceptionTest extends junit.framework.TestCase {
 
-	/**
-	 * @tests java.net.SocketException#SocketException()
-	 */
-	public void test_Constructor() {
-		try {
-			throw new SocketException();
-		} catch (SocketException e) {
-			return;
-		} catch (Exception e) {
-			fail("Exception during SocketException test : " + e.getMessage());
-		}
-		fail("Failed to generate expected exception");
-	}
+    /**
+     * @tests java.net.SocketException#SocketException()
+     */
+    public void test_Constructor() {
+        try {
+            if (true) {
+                throw new SocketException();
+            }
+            fail("Failed to generate expected exception");
+        } catch (SocketException e) {
+            // Expected
+        }
+    }
 
-	/**
-	 * @tests java.net.SocketException#SocketException(java.lang.String)
-	 */
-	public void test_ConstructorLjava_lang_String() {
-		try {
-			throw new SocketException("Some error message");
-		} catch (SocketException e) {
-			return;
-		} catch (Exception e) {
-			fail("Exception during SocketException test" + e.toString());
-		}
-		fail("Failed to generate expected exception");
-	}
-
-	/**
-	 * Sets up the fixture, for example, open a network connection. This method
-	 * is called before a test is executed.
-	 */
-	protected void setUp() {
-	}
-
-	/**
-	 * Tears down the fixture, for example, close a network connection. This
-	 * method is called after a test is executed.
-	 */
-	protected void tearDown() {
-	}
+    /**
+     * @tests java.net.SocketException#SocketException(java.lang.String)
+     */
+    public void test_ConstructorLjava_lang_String() {
+        try {
+            if (true) {
+                throw new SocketException("Some error message");
+            }
+            fail("Failed to generate expected exception");
+        } catch (SocketException e) {
+            // Expected
+        }
+    }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketImplTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketImplTest.java?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketImplTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketImplTest.java Tue Mar  4 00:02:13 2008
@@ -28,22 +28,24 @@
 
 public class SocketImplTest extends junit.framework.TestCase {
 
-	
-    public void test_Constructor_fd() throws Exception {
-        // regression test for Harmony-1117
+    /**
+     * @tests java.net.SocketImpl#SocketImpl()
+     */
+    public void test_Constructor_fd() {
+        // Regression test for HARMONY-1117
         MockSocketImpl mockSocketImpl = new MockSocketImpl();
         assertNull(mockSocketImpl.getFileDescriptor());
     }
-    
-	/*
-	* @tests java.net.SocketImpl#setPerformancePreference()
-	*/
-	public void test_setPerformancePreference_Int_Int_Int() throws Exception {
-		MockSocketImpl theSocket = new MockSocketImpl();
-		theSocket.setPerformancePreference(1,1,1);
-	}
 
-    /*
+    /**
+     * @tests java.net.SocketImpl#setPerformancePreference()
+     */
+    public void test_setPerformancePreference_Int_Int_Int() {
+        MockSocketImpl theSocket = new MockSocketImpl();
+        theSocket.setPerformancePreference(1, 1, 1);
+    }
+
+    /**
      * @tests java.net.SocketImpl#shutdownOutput()
      */
     public void test_shutdownOutput() {
@@ -55,90 +57,82 @@
             // expected
         }
     }
-    
-    /*
+
+    /**
      * @tests java.net.SocketImpl#shutdownOutput()
      */
     public void test_supportsUrgentData() {
         MockSocketImpl s = new MockSocketImpl();
         assertFalse(s.testSupportsUrgentData());
     }
-    
-	// the mock class for test, leave all method empty
-	class MockSocketImpl extends SocketImpl{
-		
-		protected void accept(SocketImpl newSocket) throws IOException {
-		}
-
-		protected int available() throws IOException {
-			return 0;
-		}
-
-		protected void bind(InetAddress address, int port) throws IOException {
-		}
-
-		protected void close() throws IOException {
-		}
-
-		protected void connect(String host, int port) throws IOException {
-		}
-
-		protected void connect(InetAddress address, int port) throws IOException {
-		}
-
-		protected void create(boolean isStreaming) throws IOException {
-		}
-
-		protected InputStream getInputStream() throws IOException {
-			return null;
-		}
-
-		public Object getOption(int optID) throws SocketException {
-			return null;
-		}
-
-		protected OutputStream getOutputStream() throws IOException {
-			return null;
-		}
-
-		protected void listen(int backlog) throws IOException {
-		}
-
-		public void setOption(int optID, Object val) throws SocketException {
-		}
-
-		protected void connect(SocketAddress remoteAddr, int timeout) throws IOException {
-		}
-
-		protected void sendUrgentData(int value) throws IOException {
-		}
-		
-		public void setPerformancePreference(int connectionTime,
-                int latency,
-                int bandwidth){
-			super.setPerformancePreferences(connectionTime, latency, bandwidth);
-		}
+
+    // the mock class for test, leave all methods empty
+    class MockSocketImpl extends SocketImpl {
+
+        protected void accept(SocketImpl newSocket) throws IOException {
+        }
+
+        protected int available() throws IOException {
+            return 0;
+        }
+
+        protected void bind(InetAddress address, int port) throws IOException {
+        }
+
+        protected void close() throws IOException {
+        }
+
+        protected void connect(String host, int port) throws IOException {
+        }
+
+        protected void connect(InetAddress address, int port)
+                throws IOException {
+        }
+
+        protected void create(boolean isStreaming) throws IOException {
+        }
+
+        protected InputStream getInputStream() throws IOException {
+            return null;
+        }
+
+        public Object getOption(int optID) throws SocketException {
+            return null;
+        }
+
+        protected OutputStream getOutputStream() throws IOException {
+            return null;
+        }
+
+        protected void listen(int backlog) throws IOException {
+        }
+
+        public void setOption(int optID, Object val) throws SocketException {
+        }
+
+        protected void connect(SocketAddress remoteAddr, int timeout)
+                throws IOException {
+        }
+
+        protected void sendUrgentData(int value) throws IOException {
+        }
+
+        public void setPerformancePreference(int connectionTime, int latency,
+                int bandwidth) {
+            super.setPerformancePreferences(connectionTime, latency, bandwidth);
+        }
 
         public FileDescriptor getFileDescriptor() {
             return super.getFileDescriptor();
         }
-        
+
         public void shutdownOutput() throws IOException {
             super.shutdownOutput();
         }
-        
-        public boolean testSupportsUrgentData(){
+
+        public boolean testSupportsUrgentData() {
             return super.supportsUrgentData();
         }
-        
-	}
-
-	protected void setUp() {
-	}
 
-	protected void tearDown() {
-	}
-
-	protected void doneSuite() {
-	}
+    }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketPermissionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketPermissionTest.java?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketPermissionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketPermissionTest.java Tue Mar  4 00:02:13 2008
@@ -26,203 +26,171 @@
 
 public class SocketPermissionTest extends junit.framework.TestCase {
 
-	String starName = "*." + Support_Configuration.DomainAddress;
+    String starName = "*." + Support_Configuration.DomainAddress;
 
-	String wwwName = Support_Configuration.HomeAddress;
+    String wwwName = Support_Configuration.HomeAddress;
 
-	SocketPermission star_Resolve = new SocketPermission(starName, "resolve");
+    SocketPermission star_Resolve = new SocketPermission(starName, "resolve");
 
-	SocketPermission star_All = new SocketPermission(starName,
-			"listen,accept,connect");
+    SocketPermission star_All = new SocketPermission(starName,
+            "listen,accept,connect");
 
-	SocketPermission www_All = new SocketPermission(wwwName,
-			"connect,listen,accept");
-
-	SocketPermission copyOfWww_All = new SocketPermission(wwwName,
-			"connect,listen,accept");
-
-	/**
-	 * @tests java.net.SocketPermission#SocketPermission(java.lang.String,
-	 *        java.lang.String)
-	 */
-	public void test_ConstructorLjava_lang_StringLjava_lang_String() {
-		// Test for method java.net.SocketPermission(java.lang.String,
-		// java.lang.String)
-		assertTrue("Incorrect name", star_Resolve.getName().equals(starName));
-		assertEquals("Incorrect actions", 
-				"resolve", star_Resolve.getActions());
-
-		SocketPermission sp1 = new SocketPermission("", "connect");
-		assertEquals("Wrong name1", "localhost", sp1.getName());
-		SocketPermission sp2 = new SocketPermission(":80", "connect");
-		assertEquals("Wrong name2", ":80", sp2.getName());
-        
-		// regression for HARMONY-1462
+    SocketPermission www_All = new SocketPermission(wwwName,
+            "connect,listen,accept");
+
+    SocketPermission copyOfWww_All = new SocketPermission(wwwName,
+            "connect,listen,accept");
+
+    /**
+     * @tests java.net.SocketPermission#SocketPermission(java.lang.String,
+     *        java.lang.String)
+     */
+    public void test_ConstructorLjava_lang_StringLjava_lang_String() {
+        assertEquals("Incorrect name", starName, star_Resolve.getName());
+        assertEquals("Incorrect actions", "resolve", star_Resolve.getActions());
+
+        SocketPermission sp1 = new SocketPermission("", "connect");
+        assertEquals("Wrong name1", "localhost", sp1.getName());
+        SocketPermission sp2 = new SocketPermission(":80", "connect");
+        assertEquals("Wrong name2", ":80", sp2.getName());
+
+        // Regression for HARMONY-1462
         SocketPermission sp3 = new SocketPermission("localhost:*", "listen");
         assertEquals("Wrong name3", "localhost:*", sp3.getName());
-        // for all ports
+        // For all ports
         SocketPermission spAllPorts = new SocketPermission("localhost:0-65535",
                 "listen");
         assertTrue("Port range error", sp3.implies(spAllPorts));
         assertTrue("Port range error", spAllPorts.implies(sp3));
-	}
+    }
 
-	/**
-	 * @tests java.net.SocketPermission#equals(java.lang.Object)
-	 */
-	public void test_equalsLjava_lang_Object() {
-		// Test for method boolean
-		// java.net.SocketPermission.equals(java.lang.Object)
-		assertTrue("Different names but returned equal", !star_All
-				.equals(www_All));
-		assertTrue("Different actions but returned equal", !star_Resolve
-				.equals(star_All));
-		assertTrue("Same but returned unequal", www_All.equals(copyOfWww_All));
-		assertTrue("Returned true when compared to a String", !www_All
-				.equals(www_All.toString()));
-
-		SocketPermission sp1 = new SocketPermission("TEST1.com",
-				"resolve,connect");
-		SocketPermission sp2 = new SocketPermission("test1.com",
-				"resolve,connect");
-		assertTrue("Different cases should be equal", sp1.equals(sp2));
+    /**
+     * @tests java.net.SocketPermission#equals(java.lang.Object)
+     */
+    public void test_equalsLjava_lang_Object() {
+        assertTrue("Different names but returned equal", !star_All
+                .equals(www_All));
+        assertTrue("Different actions but returned equal", !star_Resolve
+                .equals(star_All));
+        assertTrue("Same but returned unequal", www_All.equals(copyOfWww_All));
+        assertTrue("Returned true when compared to a String", !www_All
+                .equals(www_All.toString()));
+
+        SocketPermission sp1 = new SocketPermission("TEST1.com",
+                "resolve,connect");
+        SocketPermission sp2 = new SocketPermission("test1.com",
+                "resolve,connect");
+        assertTrue("Different cases should be equal", sp1.equals(sp2));
 
         // Regression for HARMONY-1524
         assertFalse(sp1.equals(null));
-        
+
         // Regression for HARMONY-3333
         sp1 = new SocketPermission("TEST1.com:333", "resolve");
         sp2 = new SocketPermission("test1.com:444", "resolve");
         assertTrue("Different cases should be equal", sp1.equals(sp2));
-	}
 
-	/**
-	 * @tests java.net.SocketPermission#equals(java.lang.Object)
-	 */
-	public void test_equalsLjava_lang_Object_subtest0() {
-		SocketPermission sp1 = new SocketPermission(
-				Support_Configuration.InetTestAddress, "resolve,connect");
-		SocketPermission sp2 = new SocketPermission(
-				Support_Configuration.InetTestIP, "resolve,connect");
-		assertTrue("Same IP address should be equal", sp1.equals(sp2));
-
-	}
-
-	/**
-	 * @tests java.net.SocketPermission#getActions()
-	 */
-	public void test_getActions() {
-		// Test for method java.lang.String
-		// java.net.SocketPermission.getActions()
-		assertEquals("Incorrect actions", 
-				"resolve", star_Resolve.getActions());
-		assertEquals("Incorrect actions/not in canonical form", "connect,listen,accept,resolve", star_All
-				.getActions());
-	}
-
-	/**
-	 * @tests java.net.SocketPermission#implies(java.security.Permission)
-	 */
-	public void test_impliesLjava_security_Permission() {
-		// Test for method boolean
-		// java.net.SocketPermission.implies(java.security.Permission)
-		assertTrue("All should imply resolve", star_All.implies(star_Resolve));
-		
-        // regression for HARMONY-1200
-        assertFalse("Null should not be implied", star_All.implies((SocketPermission)null));
-        
-		assertTrue("Equals should imply eachother", www_All
-				.implies(copyOfWww_All));
-		assertTrue("Wild should imply normal", star_All.implies(www_All));
-		assertTrue("Normal shouldn't imply wildcard", !www_All
-				.implies(star_Resolve));
-		assertTrue("Resolve shouldn't imply all", !star_Resolve
-				.implies(star_All));
-		SocketPermission p1 = new SocketPermission(wwwName + ":80-81",
-				"connect");
-		SocketPermission p2 = new SocketPermission(wwwName + ":80", "connect");
-		assertTrue("Port 80 is implied by 80-81", p1.implies(p2));
-		p1 = new SocketPermission(wwwName + ":79-80", "connect");
-		assertTrue("Port 80 is implied by 79-80", p1.implies(p2));
-		p1 = new SocketPermission(wwwName + ":79-81", "connect");
-		assertTrue("Port 80 is implied by 79-81", p1.implies(p2));
-		p2 = new SocketPermission(wwwName + ":79-80", "connect");
-		assertTrue("Port 79-80 is implied by 79-81", p1.implies(p2));
-		p2 = new SocketPermission(wwwName, "resolve");
-		assertTrue(
-				"Any identical host should imply resolve regardless of the ports",
-				p1.implies(p2));
-
-		SocketPermission sp1 = new SocketPermission("www.Ibm.com", "resolve");
-		SocketPermission sp2 = new SocketPermission("www.IBM.com", "resolve");
-		assertTrue("SocketPermission is case sensitive", sp1.implies(sp2));
-
-		SocketPermission sp3 = new SocketPermission("*.ibm.com", "resolve");
-		assertTrue("SocketPermission wildcard is case sensitive", sp3
-				.implies(sp2));
-
-		InetAddress host = null;
-		try {
-			host = InetAddress.getByName(Support_Configuration.UnresolvedIP);
-		} catch (UnknownHostException e) {
-		}
-		
-		SocketPermission perm1 = new SocketPermission(
-				Support_Configuration.UnresolvedIP, "connect");
-		SocketPermission perm2 = new SocketPermission(
-				Support_Configuration.UnresolvedIP + ":80", "connect");
-		assertTrue("should imply port 80", perm1.implies(perm2));
-		PermissionCollection col = perm1.newPermissionCollection();
-		col.add(perm1);
-		assertTrue("collection should imply port 80", col.implies(perm2));
-
-	}
-
-	/**
-	 * @tests java.net.SocketPermission#newPermissionCollection()
-	 */
-	public void test_newPermissionCollection() {
-		// Test for method java.security.PermissionCollection
-		// java.net.SocketPermission.newPermissionCollection()
-		java.security.PermissionCollection pc = star_Resolve
-				.newPermissionCollection();
-		pc.add(star_Resolve);
-		pc.add(www_All);
-		assertTrue("Should imply all on " + wwwName, pc.implies(www_All));
-		assertTrue("Should imply resolve on " + starName, pc
-				.implies(star_Resolve));
-		assertTrue("Should not imply all on " + starName, !pc.implies(star_All));
-
-		// wipe out pc
-		pc = star_Resolve.newPermissionCollection();
-		pc.add(star_All);
-		assertTrue("Should imply resolve on " + starName, pc
-				.implies(star_Resolve));
-		assertTrue("Should imply all on " + wwwName, pc.implies(www_All));
-
-		pc = star_Resolve.newPermissionCollection();
-		SocketPermission p1 = new SocketPermission(wwwName + ":79-80",
-				"connect");
-		pc.add(p1);
-		SocketPermission p2 = new SocketPermission(wwwName, "resolve");
-		assertTrue(
-				"Any identical host should imply resolve regardless of the ports",
-				pc.implies(p2));
-		assertTrue("A different host should not imply resolve", !pc
-				.implies(star_Resolve));
-	}
-
-	/**
-	 * Sets up the fixture, for example, open a network connection. This method
-	 * is called before a test is executed.
-	 */
-	protected void setUp() {
-	}
-
-	/**
-	 * Tears down the fixture, for example, close a network connection. This
-	 * method is called after a test is executed.
-	 */
-	protected void tearDown() {
-	}
+        sp1 = new SocketPermission(Support_Configuration.InetTestAddress,
+                "resolve,connect");
+        sp2 = new SocketPermission(Support_Configuration.InetTestIP,
+                "resolve,connect");
+        assertEquals("Same IP address should be equal", sp1, sp2);
+    }
+
+    /**
+     * @tests java.net.SocketPermission#getActions()
+     */
+    public void test_getActions() {
+        assertEquals("Incorrect actions", "resolve", star_Resolve.getActions());
+        assertEquals("Incorrect actions/not in canonical form",
+                "connect,listen,accept,resolve", star_All.getActions());
+    }
+
+    /**
+     * @tests java.net.SocketPermission#implies(java.security.Permission)
+     */
+    public void test_impliesLjava_security_Permission() {
+        assertTrue("All should imply resolve", star_All.implies(star_Resolve));
+
+        // Regression for HARMONY-1200
+        assertFalse("Null should not be implied", star_All
+                .implies((SocketPermission) null));
+
+        assertTrue("Equals should imply eachother", www_All
+                .implies(copyOfWww_All));
+        assertTrue("Wild should imply normal", star_All.implies(www_All));
+        assertTrue("Normal shouldn't imply wildcard", !www_All
+                .implies(star_Resolve));
+        assertTrue("Resolve shouldn't imply all", !star_Resolve
+                .implies(star_All));
+        SocketPermission p1 = new SocketPermission(wwwName + ":80-81",
+                "connect");
+        SocketPermission p2 = new SocketPermission(wwwName + ":80", "connect");
+        assertTrue("Port 80 is implied by 80-81", p1.implies(p2));
+        p1 = new SocketPermission(wwwName + ":79-80", "connect");
+        assertTrue("Port 80 is implied by 79-80", p1.implies(p2));
+        p1 = new SocketPermission(wwwName + ":79-81", "connect");
+        assertTrue("Port 80 is implied by 79-81", p1.implies(p2));
+        p2 = new SocketPermission(wwwName + ":79-80", "connect");
+        assertTrue("Port 79-80 is implied by 79-81", p1.implies(p2));
+        p2 = new SocketPermission(wwwName, "resolve");
+        assertTrue(
+                "Any identical host should imply resolve regardless of the ports",
+                p1.implies(p2));
+
+        SocketPermission sp1 = new SocketPermission("www.Ibm.com", "resolve");
+        SocketPermission sp2 = new SocketPermission("www.IBM.com", "resolve");
+        assertTrue("SocketPermission is case sensitive", sp1.implies(sp2));
+
+        SocketPermission sp3 = new SocketPermission("*.ibm.com", "resolve");
+        assertTrue("SocketPermission wildcard is case sensitive", sp3
+                .implies(sp2));
+
+        InetAddress host = null;
+        try {
+            host = InetAddress.getByName(Support_Configuration.UnresolvedIP);
+        } catch (UnknownHostException e) {
+        }
+
+        SocketPermission perm1 = new SocketPermission(
+                Support_Configuration.UnresolvedIP, "connect");
+        SocketPermission perm2 = new SocketPermission(
+                Support_Configuration.UnresolvedIP + ":80", "connect");
+        assertTrue("should imply port 80", perm1.implies(perm2));
+        PermissionCollection col = perm1.newPermissionCollection();
+        col.add(perm1);
+        assertTrue("collection should imply port 80", col.implies(perm2));
+    }
+
+    /**
+     * @tests java.net.SocketPermission#newPermissionCollection()
+     */
+    public void test_newPermissionCollection() {
+        java.security.PermissionCollection pc = star_Resolve
+                .newPermissionCollection();
+        pc.add(star_Resolve);
+        pc.add(www_All);
+        assertTrue("Should imply all on " + wwwName, pc.implies(www_All));
+        assertTrue("Should imply resolve on " + starName, pc
+                .implies(star_Resolve));
+        assertTrue("Should not imply all on " + starName, !pc.implies(star_All));
+
+        // wipe out pc
+        pc = star_Resolve.newPermissionCollection();
+        pc.add(star_All);
+        assertTrue("Should imply resolve on " + starName, pc
+                .implies(star_Resolve));
+        assertTrue("Should imply all on " + wwwName, pc.implies(www_All));
+
+        pc = star_Resolve.newPermissionCollection();
+        SocketPermission p1 = new SocketPermission(wwwName + ":79-80",
+                "connect");
+        pc.add(p1);
+        SocketPermission p2 = new SocketPermission(wwwName, "resolve");
+        assertTrue(
+                "Any identical host should imply resolve regardless of the ports",
+                pc.implies(p2));
+        assertTrue("A different host should not imply resolve", !pc
+                .implies(star_Resolve));
+    }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java Tue Mar  4 00:02:13 2008
@@ -490,6 +490,8 @@
             fail("No exception when connecting to address nobody listening on");
         } catch (ConnectException e) {
             // Expected
+        } catch (SocketTimeoutException e) {
+            // The other possibility is that the system timed us out.
         }
         theSocket.close();
 

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URISyntaxExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URISyntaxExceptionTest.java?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URISyntaxExceptionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URISyntaxExceptionTest.java Tue Mar  4 00:02:13 2008
@@ -21,102 +21,95 @@
 
 public class URISyntaxExceptionTest extends junit.framework.TestCase {
 
-	/**
-	 * @tests java.net.URISyntaxException#URISyntaxException(java.lang.String,
-	 *        java.lang.String, int)
-	 */
-	public void test_ConstructorLjava_lang_StringLjava_lang_StringI() {
-		// test for Constructor(String str, String problem, int index);
-		try {
-			new URISyntaxException(null, "problem", 2);
-			fail("Expected NullPointerException");
-		} catch (NullPointerException npe) {
-		}
-
-		try {
-			new URISyntaxException("str", null, 2);
-			fail("Expected NullPointerException");
-		} catch (NullPointerException npe) {
-		}
-
-		try {
-			new URISyntaxException("str", "problem", -2);
-			fail("Expected IllegalArgumentException");
-		} catch (IllegalArgumentException iae) {
-		}
-
-		URISyntaxException e = new URISyntaxException("str", "problem", 2);
-		assertEquals("returned incorrect reason", "problem", e.getReason());
-		assertEquals("returned incorrect input", "str", e.getInput());
-		assertEquals("returned incorrect index", 2, e.getIndex());
-	}
-
-	/**
-	 * @tests java.net.URISyntaxException#URISyntaxException(java.lang.String,
-	 *        java.lang.String)
-	 */
-	public void test_ConstructorLjava_lang_StringLjava_lang_String() {
-		// test for Constructor(String str, String problem);
-		try {
-			new URISyntaxException(null, "problem");
-			fail("Expected NullPointerException");
-		} catch (NullPointerException npe) {
-		}
-
-		try {
-			new URISyntaxException("str", null);
-			fail("Expected NullPointerException");
-		} catch (NullPointerException npe) {
-		}
-
-		URISyntaxException e = new URISyntaxException("str", "problem");
-		assertEquals("returned incorrect reason", "problem", e.getReason());
-		assertEquals("returned incorrect input", "str", e.getInput());
-		assertEquals("returned incorrect index", -1, e.getIndex());
-	}
-
-	/**
-	 * @tests java.net.URISyntaxException#getIndex()
-	 */
-	public void test_getIndex() {
-		// see constructor tests
-	}
-
-	/**
-	 * @tests java.net.URISyntaxException#getReason()
-	 */
-	public void test_getReason() {
-		// see constructor tests
-	}
-
-	/**
-	 * @tests java.net.URISyntaxException#getInput()
-	 */
-	public void test_getInput() {
-		// see constructor tests
-	}
-
-	/**
-	 * @tests java.net.URISyntaxException#getMessage()
-	 */
-	public void test_getMessage() {
-		// tests for java.lang.String getMessage()
-		Locale.setDefault(Locale.US);
-		URISyntaxException e = new URISyntaxException("str", "problem", 3);
-		assertEquals("Returned incorrect message", "problem at index 3: str", e
-				.getMessage());
-
-		e = new URISyntaxException("str", "problem");
-		assertEquals("Returned incorrect message", "problem: str", e
-				.getMessage());
-	}
-
-	protected void setUp() {
-	}
-
-	protected void tearDown() {
-	}
-
-	protected void doneSuite() {
-	}
+    /**
+     * @tests java.net.URISyntaxException#URISyntaxException(java.lang.String,
+     *        java.lang.String, int)
+     */
+    public void test_ConstructorLjava_lang_StringLjava_lang_StringI() {
+        try {
+            new URISyntaxException(null, "problem", 2);
+            fail("Expected NullPointerException");
+        } catch (NullPointerException npe) {
+            // Expected
+        }
+
+        try {
+            new URISyntaxException("str", null, 2);
+            fail("Expected NullPointerException");
+        } catch (NullPointerException npe) {
+            // Expected
+        }
+
+        try {
+            new URISyntaxException("str", "problem", -2);
+            fail("Expected IllegalArgumentException");
+        } catch (IllegalArgumentException iae) {
+            // Expected
+        }
+
+        URISyntaxException e = new URISyntaxException("str", "problem", 2);
+        assertEquals("returned incorrect reason", "problem", e.getReason());
+        assertEquals("returned incorrect input", "str", e.getInput());
+        assertEquals("returned incorrect index", 2, e.getIndex());
+    }
+
+    /**
+     * @tests java.net.URISyntaxException#URISyntaxException(java.lang.String,
+     *        java.lang.String)
+     */
+    public void test_ConstructorLjava_lang_StringLjava_lang_String() {
+        try {
+            new URISyntaxException(null, "problem");
+            fail("Expected NullPointerException");
+        } catch (NullPointerException npe) {
+            // Expected
+        }
+
+        try {
+            new URISyntaxException("str", null);
+            fail("Expected NullPointerException");
+        } catch (NullPointerException npe) {
+            // Expected
+        }
+
+        URISyntaxException e = new URISyntaxException("str", "problem");
+        assertEquals("returned incorrect reason", "problem", e.getReason());
+        assertEquals("returned incorrect input", "str", e.getInput());
+        assertEquals("returned incorrect index", -1, e.getIndex());
+    }
+
+    /**
+     * @tests java.net.URISyntaxException#getIndex()
+     */
+    public void test_getIndex() {
+        // see constructor tests
+    }
+
+    /**
+     * @tests java.net.URISyntaxException#getReason()
+     */
+    public void test_getReason() {
+        // see constructor tests
+    }
+
+    /**
+     * @tests java.net.URISyntaxException#getInput()
+     */
+    public void test_getInput() {
+        // see constructor tests
+    }
+
+    /**
+     * @tests java.net.URISyntaxException#getMessage()
+     */
+    public void test_getMessage() {
+        Locale.setDefault(Locale.US);
+        URISyntaxException e = new URISyntaxException("str", "problem", 3);
+        assertEquals("Returned incorrect message", "problem at index 3: str", e
+                .getMessage());
+
+        e = new URISyntaxException("str", "problem");
+        assertEquals("Returned incorrect message", "problem: str", e
+                .getMessage());
+    }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URITest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URITest.java?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URITest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URITest.java Tue Mar  4 00:02:13 2008
@@ -221,28 +221,30 @@
             fail("Assert 0: URI constructor failed to throw exception on invalid input.");
         } catch (URISyntaxException e) {
             // Expected
-            assertEquals("Assert 1: Wrong index in URISyntaxException.", 0, e.getIndex());
+            assertEquals("Assert 1: Wrong index in URISyntaxException.", 0, e
+                    .getIndex());
         }
-        
+
         // Regression test for HARMONY-25
-        // if port value is negative, the authority should be considered registry-based.
+        // if port value is negative, the authority should be considered
+        // registry-based.
         URI uri = new URI("http://host:-8096/path/index.html");
         assertEquals("Assert 2: returned wrong port value,", -1, uri.getPort());
         assertNull("Assert 3: returned wrong host value,", uri.getHost());
         try {
             uri.parseServerAuthority();
             fail("Assert 4: Expected URISyntaxException");
-        } catch (URISyntaxException e){
+        } catch (URISyntaxException e) {
             // Expected
         }
-        
-        uri = new URI("http","//myhost:-8096", null);
+
+        uri = new URI("http", "//myhost:-8096", null);
         assertEquals("Assert 5: returned wrong port value,", -1, uri.getPort());
         assertNull("Assert 6: returned wrong host value,", uri.getHost());
         try {
             uri.parseServerAuthority();
             fail("Assert 7: Expected URISyntaxException");
-        } catch (URISyntaxException e){
+        } catch (URISyntaxException e) {
             // Expected
         }
     }
@@ -280,7 +282,8 @@
      * @tests java.net.URI#URI(java.lang.String, java.lang.String,
      *        java.lang.String)
      */
-    public void test_ConstructorLjava_lang_StringLjava_lang_StringLjava_lang_String() throws URISyntaxException {
+    public void test_ConstructorLjava_lang_StringLjava_lang_StringLjava_lang_String()
+            throws URISyntaxException {
         URI uri = new URI("mailto", "mduerst@ifi.unizh.ch", null);
         assertNull("wrong userinfo", uri.getUserInfo());
         assertNull("wrong hostname", uri.getHost());
@@ -323,16 +326,11 @@
      *        java.lang.String)
      */
     public void test_ConstructorLjava_lang_StringLjava_lang_StringLjava_lang_StringILjava_lang_StringLjava_lang_StringLjava_lang_String() {
-        // tests for public URI(String scheme, String userinfo, String host, int
-        // port, String path,
-        // String query, String fragment) throws URISyntaxException
-
         // check for URISyntaxException for invalid Server Authority
         construct1("http", "user", "host\u00DFname", -1, "/file", "query",
                 "fragment"); // unicode chars in host name
         // equivalent to construct1("http", "user", "host\u00dfname", -1,
-        // "/file",
-        // "query", "fragment");
+        // "/file", "query", "fragment");
         construct1("http", "user", "host%20name", -1, "/file", "query",
                 "fragment"); // escaped octets in host name
         construct1("http", "user", "host name", -1, "/file", "query",
@@ -602,10 +600,9 @@
             URI b = new URI(compareToData[i][0]);
             URI r = new URI(compareToData[i][1]);
             if (b.compareTo(r) != compareToResults[i]) {
-                fail("Test " + i + ": " + compareToData[i][0]
-                        + " compared to " + compareToData[i][1] + " -> "
-                        + b.compareTo(r) + " rather than "
-                        + compareToResults[i]);
+                fail("Test " + i + ": " + compareToData[i][0] + " compared to "
+                        + compareToData[i][1] + " -> " + b.compareTo(r)
+                        + " rather than " + compareToResults[i]);
             }
         }
     }
@@ -713,9 +710,9 @@
             URI b = new URI(equalsData[i][0]);
             URI r = new URI(equalsData[i][1]);
             if (b.equals(r) != equalsResults[i]) {
-                fail("Error: " + equalsData[i][0] + " == "
-                        + equalsData[i][1] + "? -> " + b.equals(r)
-                        + " expected " + equalsResults[i]);
+                fail("Error: " + equalsData[i][0] + " == " + equalsData[i][1]
+                        + "? -> " + b.equals(r) + " expected "
+                        + equalsResults[i]);
             }
         }
 
@@ -1533,7 +1530,7 @@
         } catch (URISyntaxException e) {
             // Expected
         }
-        
+
         // regression test for HARMONY-1126
         assertNotNull(URI.create("file://C:/1.txt").parseServerAuthority());
     }
@@ -1590,27 +1587,27 @@
                         + relativizeData[i][0] + ", " + relativizeData[i][1]
                         + ": " + e);
             }
-        }    
+        }
 
         URI a = new URI("http://host/dir");
-        URI b = new URI("http://host/dir/file?query");      
-        assertEquals("Assert 0: URI relativized incorrectly,",
-                new URI("file?query"), a.relativize(b));        
-    
+        URI b = new URI("http://host/dir/file?query");
+        assertEquals("Assert 0: URI relativized incorrectly,", new URI(
+                "file?query"), a.relativize(b));
+
         // One URI with empty host
         a = new URI("file:///~/first");
         b = new URI("file://tools/~/first");
-        assertEquals("Assert 1: URI relativized incorrectly,",
-                new URI("file://tools/~/first"), a.relativize(b));      
-        assertEquals("Assert 2: URI relativized incorrectly,",
-                new URI("file:///~/first"), b.relativize(a));       
+        assertEquals("Assert 1: URI relativized incorrectly,", new URI(
+                "file://tools/~/first"), a.relativize(b));
+        assertEquals("Assert 2: URI relativized incorrectly,", new URI(
+                "file:///~/first"), b.relativize(a));
 
         // Both URIs with empty hosts
         b = new URI("file:///~/second");
-        assertEquals("Assert 3: URI relativized incorrectly,",
-                new URI("file:///~/second"), a.relativize(b));
-        assertEquals("Assert 4: URI relativized incorrectly,",
-                new URI("file:///~/first"), b.relativize(a));
+        assertEquals("Assert 3: URI relativized incorrectly,", new URI(
+                "file:///~/second"), a.relativize(b));
+        assertEquals("Assert 4: URI relativized incorrectly,", new URI(
+                "file:///~/first"), b.relativize(a));
     }
 
     /**
@@ -1811,13 +1808,13 @@
      * @tests java.net.URI#toURL()
      */
     public void test_toURL() throws Exception {
-        String absoluteuris[] = new String[] { "mailto:user@ca.ibm.com",
+        String absoluteuris[] = new String[] { "mailto:noreply@apache.org",
                 "urn:isbn:123498989h", "news:software.ibm.com",
-                "http://www.amazon.ca", "file:///d:/temp/results.txt",
+                "http://www.apache.org", "file:///d:/temp/results.txt",
                 "scheme:ssp", };
 
         String relativeuris[] = new String[] { "calculate.pl?isbn=123498989h",
-                "?isbn=123498989h", "//www.amazon.ca", "a.html", "#top",
+                "?isbn=123498989h", "//www.apache.org", "a.html", "#top",
                 "//pc1/", "//user@host/path/file" };
 
         for (int i = 0; i < absoluteuris.length; i++) {

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLClassLoaderTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLClassLoaderTest.java?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLClassLoaderTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLClassLoaderTest.java Tue Mar  4 00:02:13 2008
@@ -21,7 +21,6 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.MalformedURLException;
-import java.net.URI;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.net.URLStreamHandler;
@@ -31,22 +30,15 @@
 import java.util.StringTokenizer;
 import java.util.Vector;
 
+import junit.framework.TestCase;
+
 import org.apache.harmony.luni.util.InvalidJarIndexException;
 
 import tests.support.Support_Configuration;
 import tests.support.resource.Support_Resources;
-import junit.framework.TestSuite;
 
-public class URLClassLoaderTest extends junit.framework.TestCase {
+public class URLClassLoaderTest extends TestCase {
 
-    public URLClassLoaderTest() {
-        super();
-    }
-    
-    public URLClassLoaderTest(String s) {
-        super(s);
-    }
-    
     class BogusClassLoader extends ClassLoader {
         public URL getResource(String res) {
             try {
@@ -67,7 +59,7 @@
             return super.findClass(cl);
         }
     }
-    
+
     URLClassLoader ucl;
 
     /**
@@ -314,7 +306,7 @@
                         + "/JarIndex/hyts_42.jar!/bpack/"));
         assertTrue("Resources not found (2)", resourcesFound);
         assertFalse("No more resources expected", en.hasMoreElements());
-       
+
         // Regression test for HARMONY-2357.
         try {
             URLClassLoaderExt cl = new URLClassLoaderExt(new URL[557]);
@@ -325,7 +317,8 @@
         }
 
         // Regression test for HARMONY-2871.
-        URLClassLoader cl = new URLClassLoader(new URL[] { new URL("file:/foo.jar") });
+        URLClassLoader cl = new URLClassLoader(new URL[] { new URL(
+                "file:/foo.jar") });
 
         try {
             Class.forName("foo.Foo", false, cl);
@@ -369,31 +362,31 @@
         assertTrue("Returned incorrect resource", !sb.toString().equals(
                 "This is a test resource file"));
     }
-    
+
     public void testFindResource_H3461() throws Exception {
         File userDir = new File(System.getProperty("user.dir"));
         File dir = new File(userDir, "encode#me");
         File f, f2;
         URLClassLoader loader;
         URL dirUrl;
-        
+
         if (!dir.exists()) {
             dir.mkdir();
         }
         dir.deleteOnExit();
         dirUrl = dir.toURI().toURL();
-        loader = new URLClassLoader( new URL[] { dirUrl });
+        loader = new URLClassLoader(new URL[] { dirUrl });
 
         f = File.createTempFile("temp", ".dat", dir);
         f.deleteOnExit();
         f2 = File.createTempFile("bad#name#", ".dat", dir);
         f2.deleteOnExit();
-          
-        assertNotNull("Unable to load resource from path with problematic name",
-            loader.getResource(f.getName()));
-        assertEquals("URL was not correctly encoded",
-            f2.toURI().toURL(),    
-            loader.getResource(f2.getName()));
+
+        assertNotNull(
+                "Unable to load resource from path with problematic name",
+                loader.getResource(f.getName()));
+        assertEquals("URL was not correctly encoded", f2.toURI().toURL(),
+                loader.getResource(f2.getName()));
     }
 
     /**
@@ -420,17 +413,17 @@
         assertTrue("too long. UNC path formed? UNC time: " + uncTime
                 + " regular time: " + time, uncTime <= (time * 4));
     }
-    
+
     /**
-	 * Regression for Harmony-2237 
-	 */
-	public void test_getResource() throws Exception {		
-		URLClassLoader urlLoader = getURLClassLoader();
-		assertNull(urlLoader.findResource("XXX")); //$NON-NLS-1$
-	}
+     * Regression for Harmony-2237
+     */
+    public void test_getResource() throws Exception {
+        URLClassLoader urlLoader = getURLClassLoader();
+        assertNull(urlLoader.findResource("XXX")); //$NON-NLS-1$
+    }
 
-	private static URLClassLoader getURLClassLoader() {
-		String classPath = System.getProperty("java.class.path");
+    private static URLClassLoader getURLClassLoader() {
+        String classPath = System.getProperty("java.class.path");
         StringTokenizer tok = new StringTokenizer(classPath, File.pathSeparator);
         Vector<URL> urlVec = new Vector<URL>();
         String resPackage = Support_Resources.RESOURCE_PACKAGE;
@@ -445,15 +438,15 @@
                 urlVec.addElement(new URL(url));
             }
         } catch (MalformedURLException e) {
-        	// do nothing
+            // do nothing
         }
         URL[] urls = new URL[urlVec.size()];
         for (int i = 0; i < urlVec.size(); i++) {
-        	urls[i] = urlVec.elementAt(i);
-        }            
+            urls[i] = urlVec.elementAt(i);
+        }
         URLClassLoader loader = new URLClassLoader(urls, null);
-		return loader;
-	}
+        return loader;
+    }
 
     /**
      * Regression test for HARMONY-2255
@@ -466,12 +459,4 @@
                 "tests/api/java/net/test%25.properties");
         assertNull(in);
     }
-    
-//    public static TestSuite suite() {
-//        TestSuite suite = new TestSuite();
-//        
-//        suite.addTest(new URLClassLoaderTest("testFindResource_H3461"));
-//        suite.addTest(new URLClassLoaderTest("test_getResourceAsStream"));
-//        return suite;
-//    }
 }