harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ghar...@apache.org
Subject svn commit: r416477 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni: ./ src/main/java/java/net/ src/test/java/tests/api/java/net/
Date Thu, 22 Jun 2006 21:36:25 GMT
Author: gharley
Date: Thu Jun 22 14:36:24 2006
New Revision: 416477

URL: http://svn.apache.org/viewvc?rev=416477&view=rev
Log:
Liberate ServerSocketTest, InetAddressTest and SocketPermissionTest from the excludes list.
Fix up a couple of bugs in InetAddressTest. Remove a couple of duplicate entries in tests.api.java.net.AllTests
suite. 

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/build.xml
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ServerSocket.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/AllTests.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/InetAddressTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/ServerSocketTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/build.xml
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/build.xml?rev=416477&r1=416476&r2=416477&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/build.xml (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/build.xml Thu Jun 22 14:36:24 2006
@@ -213,12 +213,9 @@
                     <exclude name="tests/api/java/lang/StringTest.java" />
                     <exclude name="tests/api/java/net/DatagramSocketTest.java" />
                     <exclude name="tests/api/java/net/HttpURLConnectionTest.java" />
-                    <exclude name="tests/api/java/net/InetAddressTest.java" />
                     <exclude name="tests/api/java/net/JarURLConnectionTest.java" />
                     <exclude name="tests/api/java/net/MulticastSocketTest.java" />
-                    <exclude name="tests/api/java/net/ServerSocketTest.java" />
                     <exclude name="tests/api/java/net/SocketImplTest.java" />
-                    <exclude name="tests/api/java/net/SocketPermissionTest.java" />
                     <exclude name="tests/api/java/net/SocketTest.java" />
                     <exclude name="tests/api/java/net/URLClassLoaderTest.java" />
                     <exclude name="tests/api/java/net/URLConnectionTest.java" />

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ServerSocket.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ServerSocket.java?rev=416477&r1=416476&r2=416477&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ServerSocket.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ServerSocket.java
Thu Jun 22 14:36:24 2006
@@ -300,15 +300,18 @@
 	 * @return String the description
 	 */
 	public String toString() {
-		StringBuffer result = new StringBuffer(64);
-		result.append("ServerSocket["); //$NON-NLS-1$
-		if (!isBound())
-			return result.append("unbound]").toString(); //$NON-NLS-1$
-		return result.append("addr="). //$NON-NLS-1$
-				append(getInetAddress()).append(",port=0,localport="). //$NON-NLS-1$
-				append(getLocalPort()).append("]"). //$NON-NLS-1$
-				toString();
-	}
+        StringBuffer result = new StringBuffer(64);
+        result.append("ServerSocket["); //$NON-NLS-1$
+        if (!isBound()) {
+            return result.append("unbound]").toString(); //$NON-NLS-1$
+        }
+        return result
+                .append("addr="). //$NON-NLS-1$
+                append(getInetAddress().getHostName())
+                .append("/").append(getInetAddress().getHostAddress()).append(",port=0,localport=").
//$NON-NLS-1$
+                append(getLocalPort()).append("]"). //$NON-NLS-1$
+                toString();
+    }
 
 	/**
 	 * Bind the ServerSocket to the nominated local host/port. The default

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/AllTests.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/AllTests.java?rev=416477&r1=416476&r2=416477&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/AllTests.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/AllTests.java
Thu Jun 22 14:36:24 2006
@@ -67,8 +67,6 @@
 		suite.addTestSuite(URLDecoderTest.class);
 		suite.addTestSuite(URLEncoderTest.class);
         suite.addTestSuite(HttpRetryExceptionTest.class);
-        suite.addTestSuite(Inet4AddressTest.class);
-        suite.addTestSuite(InetAddressTest.class);
 		// $JUnit-END$
 		return suite;
 	}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/InetAddressTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/InetAddressTest.java?rev=416477&r1=416476&r2=416477&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/InetAddressTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/InetAddressTest.java
Thu Jun 22 14:36:24 2006
@@ -228,98 +228,86 @@
 		}
 	}
 
-	/**
-	 * @tests java.net.InetAddress#getHostName()
-	 */
-	public void test_getHostName() {
-		// Test for method java.lang.String java.net.InetAddress.getHostName()
-		try {
-			InetAddress ia = InetAddress
-					.getByName(Support_Configuration.InetTestIP);
-			assertTrue("Incorrect host name returned: " + ia.getHostName()
-					+ " != " + Support_Configuration.InetTestAddress, ia
-					.getHostName()
-					.equals(Support_Configuration.InetTestAddress));
-		} catch (Exception e) {
-			fail("Exception during getHostName : " + e.getMessage());
-		}
+    /**
+     * @tests java.net.InetAddress#getHostName()
+     */
+    public void test_getHostName() throws Exception {
+        // Test for method java.lang.String java.net.InetAddress.getHostName()
+        InetAddress ia = InetAddress
+                .getByName(Support_Configuration.InetTestIP);
+        assertTrue("Incorrect host name returned: " + ia.getHostName() + " != "
+                + Support_Configuration.InetTestAddress, ia.getHostName()
+                .equals(Support_Configuration.InetTestAddress));
 
-		// Test for any of the host lookups, where the default SecurityManager
-		// is installed.
+        // Test for any of the host lookups, where the default SecurityManager
+        // is installed.
 
         SecurityManager oldman = System.getSecurityManager();
-		try {
-			String exp = Support_Configuration.InetTestIP;
-			System.setSecurityManager(new MockSecurityManager());
-			InetAddress ia = InetAddress.getByName(exp);
-			String ans = ia.getHostName();
-			assertTrue("usingSecurityManager failed, ans: " + ans + " exp: "
-					+ Support_Configuration.InetTestAddress, ans
-					.equals(Support_Configuration.InetTestAddress));
-		} catch (Exception e) {
-			fail("Exception during usingSecurityManager test : "
-					+ e.getMessage());
-		} finally {
-			System.setSecurityManager(oldman);
-		}
-
-		// Make sure there is no caching
-		String originalPropertyValue = System
-				.getProperty("networkaddress.cache.ttl");
-		System.setProperty("networkaddress.cache.ttl", "0");
-
-		// Test for threadsafety
-		try {
-			System.out
-					.println("\nTesting the threadsafety of getHostName.  This test could produce unpredictable
results if getHostName is not threadsafe.");
-			InetAddress lookup1 = InetAddress
-					.getByName(Support_Configuration.InetTestAddress);
-			assertTrue(lookup1 + " expected "
-					+ Support_Configuration.InetTestIP,
-					Support_Configuration.InetTestIP.equals(lookup1
-							.getHostAddress()));
-			InetAddress lookup2 = InetAddress
-					.getByName(Support_Configuration.InetTestAddress2);
-			assertTrue(lookup2 + " expected "
-					+ Support_Configuration.InetTestIP2,
-					Support_Configuration.InetTestIP2.equals(lookup2
-							.getHostAddress()));
-			threadsafeTestThread thread1 = new threadsafeTestThread("1",
-					lookup1.getHostName(), lookup1, 0);
-			threadsafeTestThread thread2 = new threadsafeTestThread("2",
-					lookup2.getHostName(), lookup2, 0);
-			threadsafeTestThread thread3 = new threadsafeTestThread("3",
-					lookup1.getHostAddress(), lookup1, 1);
-			threadsafeTestThread thread4 = new threadsafeTestThread("4",
-					lookup2.getHostAddress(), lookup2, 1);
-
-			// initialize the flags
-			threadedTestSucceeded = true;
-			synchronized (someoneDone) {
-				thread1.start();
-				thread2.start();
-				thread3.start();
-				thread4.start();
-			}
-			System.out.println("Started threads, joining...");
-			thread1.join();
-			thread2.join();
-			thread3.join();
-			thread4.join();
-			assertTrue(threadedTestErrorString, threadedTestSucceeded);
-		} catch (Exception e) {
-			fail("Exception during threadsafe test : " + e.getMessage());
-		} finally {
-			// restore the old value of the property
-			if (originalPropertyValue == null)
-				// setting the property to -1 has the same effect as having the
-				// property be null
-				System.setProperty("networkaddress.cache.ttl", "-1");
-			else
-				System.setProperty("networkaddress.cache.ttl",
-						originalPropertyValue);
-		}
-	}
+        try {
+            String exp = Support_Configuration.InetTestIP;
+            System.setSecurityManager(new MockSecurityManager());
+            ia = InetAddress.getByName(exp);
+            String ans = ia.getHostName();
+            assertEquals(Support_Configuration.InetTestIP, ans);
+        } finally {
+            System.setSecurityManager(oldman);
+        }
+
+        // Make sure there is no caching
+        String originalPropertyValue = System
+                .getProperty("networkaddress.cache.ttl");
+        System.setProperty("networkaddress.cache.ttl", "0");
+
+        // Test for threadsafety
+        try {
+            System.out
+                    .println("\nTesting the threadsafety of getHostName.  This test could
produce unpredictable results if getHostName is not threadsafe.");
+            InetAddress lookup1 = InetAddress
+                    .getByName(Support_Configuration.InetTestAddress);
+            assertTrue(lookup1 + " expected "
+                    + Support_Configuration.InetTestIP,
+                    Support_Configuration.InetTestIP.equals(lookup1
+                            .getHostAddress()));
+            InetAddress lookup2 = InetAddress
+                    .getByName(Support_Configuration.InetTestAddress2);
+            assertTrue(lookup2 + " expected "
+                    + Support_Configuration.InetTestIP2,
+                    Support_Configuration.InetTestIP2.equals(lookup2
+                            .getHostAddress()));
+            threadsafeTestThread thread1 = new threadsafeTestThread("1",
+                    lookup1.getHostName(), lookup1, 0);
+            threadsafeTestThread thread2 = new threadsafeTestThread("2",
+                    lookup2.getHostName(), lookup2, 0);
+            threadsafeTestThread thread3 = new threadsafeTestThread("3",
+                    lookup1.getHostAddress(), lookup1, 1);
+            threadsafeTestThread thread4 = new threadsafeTestThread("4",
+                    lookup2.getHostAddress(), lookup2, 1);
+
+            // initialize the flags
+            threadedTestSucceeded = true;
+            synchronized (someoneDone) {
+                thread1.start();
+                thread2.start();
+                thread3.start();
+                thread4.start();
+            }
+            System.out.println("Started threads, joining...");
+            thread1.join();
+            thread2.join();
+            thread3.join();
+            thread4.join();
+            assertTrue(threadedTestErrorString, threadedTestSucceeded);
+        } finally {
+            // restore the old value of the property
+            if (originalPropertyValue == null)
+                // setting the property to -1 has the same effect as having the
+                // property be null
+                System.setProperty("networkaddress.cache.ttl", "-1");
+            else
+                System.setProperty("networkaddress.cache.ttl",
+                        originalPropertyValue);
+        }
+    }
 
 	/**
 	 * @tests java.net.InetAddress#getLocalHost()
@@ -373,19 +361,12 @@
 	/**
 	 * @tests java.net.InetAddress#toString()
 	 */
-	public void test_toString() {
-		// Test for method java.lang.String java.net.InetAddress.toString()
-		try {
-			InetAddress ia2 = InetAddress
-					.getByName(Support_Configuration.InetTestIP);
-			assertTrue("toString returned incorrect result", ia2.toString()
-					.equals(
-							Support_Configuration.InetTestAddress + "/"
-									+ Support_Configuration.InetTestIP));
-		} catch (Exception e) {
-			fail("Exception duruing equals test : " + e.getMessage());
-		}
-	}
+	public void test_toString() throws Exception {
+        // Test for method java.lang.String java.net.InetAddress.toString()
+        InetAddress ia2 = InetAddress
+                .getByName(Support_Configuration.InetTestIP);
+        assertEquals("/" + Support_Configuration.InetTestIP, ia2.toString());
+    }
 
 	/**
 	 * @tests java.net.InetAddress#getByAddress(java.lang.String, byte[])

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/ServerSocketTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/ServerSocketTest.java?rev=416477&r1=416476&r2=416477&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/ServerSocketTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/ServerSocketTest.java
Thu Jun 22 14:36:24 2006
@@ -371,18 +371,13 @@
 	/**
 	 * @tests java.net.ServerSocket#toString()
 	 */
-	public void test_toString() {
-		// Test for method java.lang.String java.net.ServerSocket.toString()
-		int portNumber = Support_PortManager.getNextPort();
-		try {
-			s = new ServerSocket(portNumber);
-		} catch (Exception e) {
-			fail("Exception during toString test : " + e.getMessage());
-		}
-
+	public void test_toString() throws Exception {
+        // Test for method java.lang.String java.net.ServerSocket.toString()
+        int portNumber = Support_PortManager.getNextPort();
+        s = new ServerSocket(portNumber);
         assertEquals("ServerSocket[addr=0.0.0.0/0.0.0.0,port=0,localport="
-                        + portNumber + "]", s);
-	}
+                + portNumber + "]", s.toString());
+    }
 
 	/**
 	 * @tests java.net.ServerSocket#bind(java.net.SocketAddress)



Mime
View raw message