harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r590591 [8/12] - in /harmony/enhanced/classlib/branches/java6: depends/build/platform/ depends/files/ depends/jars/icu4j_3.8/ depends/libs/freebsd.x86/ depends/manifests/icu4j_3.4.4/ depends/manifests/icu4j_3.8/ depends/manifests/icu4j_3.8/...
Date Wed, 31 Oct 2007 08:42:35 GMT
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/net/MulticastSocketTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/net/MulticastSocketTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/net/MulticastSocketTest.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/net/MulticastSocketTest.java
Wed Oct 31 01:42:07 2007
@@ -162,64 +162,61 @@
 	/**
 	 * @tests java.net.MulticastSocket#getInterface()
 	 */
-	public void test_getInterface() {
+	public void test_getInterface() throws Exception {
 		// Test for method java.net.InetAddress
 		// java.net.MulticastSocket.getInterface()
 		assertTrue("Used for testing.", true);
 
 		int groupPort = Support_PortManager.getNextPortForUDP();
-		try {
-			if (atLeastOneInterface) {
-				// validate that we get the expected response when one was not
-				// set
-				mss = new MulticastSocket(groupPort);
-				String preferIPv4StackValue = System
-						.getProperty("java.net.preferIPv4Stack");
-				String preferIPv6AddressesValue = System
-						.getProperty("java.net.preferIPv6Addresses");
-				if (((preferIPv4StackValue == null) || preferIPv4StackValue
-						.equalsIgnoreCase("false"))
-						&& (preferIPv6AddressesValue != null)
-						&& (preferIPv6AddressesValue.equals("true"))) {
-					// we expect an IPv6 ANY in this case
-					assertTrue("inet Address returned when not set:"
-							+ mss.getInterface().toString(), InetAddress
-							.getByName("::0").equals(mss.getInterface()));
-				} else {
-					// we expect an IPv4 ANY in this case
-					assertTrue("inet Address returned when not set:"
-							+ mss.getInterface().toString(), InetAddress
-							.getByName("0.0.0.0").equals(mss.getInterface()));
-				}
-
-				// validate that we get the expected response when we set via
-				// setInterface
-				Enumeration addresses = networkInterface1.getInetAddresses();
-				if (addresses != null) {
-					InetAddress firstAddress = (InetAddress) addresses
-							.nextElement();
-					mss.setInterface(firstAddress);
-					assertTrue(
-							"getNetworkInterface did not return interface set by setInterface.  Expected:"
-									+ firstAddress + " Got:"
-									+ mss.getInterface(), firstAddress
-									.equals(mss.getInterface()));
-
-					groupPort = Support_PortManager.getNextPortForUDP();
-					mss = new MulticastSocket(groupPort);
-					mss.setNetworkInterface(networkInterface1);
-					assertTrue(
-							"getInterface did not return interface set by setNeworkInterface Expected: "
-									+ firstAddress + "Got:"
-									+ mss.getInterface(), NetworkInterface
-									.getByInetAddress(mss.getInterface())
-									.equals(networkInterface1));
-				}
 
-			}
-		} catch (Exception e) {
-			fail("Exception during getInterface test: " + e.toString());
-		}
+                if (atLeastOneInterface) {
+                        // validate that we get the expected response when one was not
+                        // set
+                        mss = new MulticastSocket(groupPort);
+                        String preferIPv4StackValue = System
+                                        .getProperty("java.net.preferIPv4Stack");
+                        String preferIPv6AddressesValue = System
+                                        .getProperty("java.net.preferIPv6Addresses");
+                        if (((preferIPv4StackValue == null) || preferIPv4StackValue
+                                        .equalsIgnoreCase("false"))
+                                        && (preferIPv6AddressesValue != null)
+                                        && (preferIPv6AddressesValue.equals("true")))
{
+                                // we expect an IPv6 ANY in this case
+                                assertTrue("inet Address returned when not set:"
+                                                + mss.getInterface().toString(), InetAddress
+                                                .getByName("::0").equals(mss.getInterface()));
+                        } else {
+                                // we expect an IPv4 ANY in this case
+                                assertTrue("inet Address returned when not set:"
+                                                + mss.getInterface().toString(), InetAddress
+                                                .getByName("0.0.0.0").equals(mss.getInterface()));
+                        }
+
+                        // validate that we get the expected response when we set via
+                        // setInterface
+                        Enumeration addresses = networkInterface1.getInetAddresses();
+                        if (addresses != null) {
+                                InetAddress firstAddress = (InetAddress) addresses
+                                                .nextElement();
+                                mss.setInterface(firstAddress);
+                                assertTrue(
+                                                "getNetworkInterface did not return interface
set by setInterface.  Expected:"
+                                                                + firstAddress + " Got:"
+                                                                + mss.getInterface(), firstAddress
+                                                                .equals(mss.getInterface()));
+
+                                groupPort = Support_PortManager.getNextPortForUDP();
+                                mss = new MulticastSocket(groupPort);
+                                mss.setNetworkInterface(networkInterface1);
+                                assertTrue(
+                                                "getInterface did not return interface set
by setNeworkInterface Expected: "
+                                                                + firstAddress + "Got:"
+                                                                + mss.getInterface(), NetworkInterface
+                                                                .getByInetAddress(mss.getInterface())
+                                                                .equals(networkInterface1));
+                        }
+
+                }
 	}
 
 	/**
@@ -334,28 +331,25 @@
 	/**
 	 * @tests java.net.MulticastSocket#joinGroup(java.net.InetAddress)
 	 */
-	public void test_joinGroupLjava_net_InetAddress() {
+	public void test_joinGroupLjava_net_InetAddress() throws Exception {
 		// Test for method void
 		// java.net.MulticastSocket.joinGroup(java.net.InetAddress)
-        String msg = null;
+                String msg = null;
 		InetAddress group = null;
 		int[] ports = Support_PortManager.getNextPortsForUDP(2);
 		int groupPort = ports[0];
-		try {
-			group = InetAddress.getByName("224.0.0.3");
-			server = new MulticastServer(group, groupPort);
-			server.start();
-			Thread.sleep(1000);
-			msg = "Hello World";
-			mss = new MulticastSocket(ports[1]);
-			DatagramPacket sdp = new DatagramPacket(msg.getBytes(), msg
-					.length(), group, groupPort);
-			mss.send(sdp, (byte) 10);
-			Thread.sleep(1000);
-		} catch (Exception e) {
-			fail("Exception during joinGroup test: " + e.toString());
-		}
-        assertTrue("Group member did not recv data: ", new String(server.rdp
+                group = InetAddress.getByName("224.0.0.3");
+                server = new MulticastServer(group, groupPort);
+                server.start();
+                Thread.sleep(1000);
+                msg = "Hello World";
+                mss = new MulticastSocket(ports[1]);
+                DatagramPacket sdp = new DatagramPacket(msg.getBytes(), msg
+                                .length(), group, groupPort);
+                mss.send(sdp, (byte) 10);
+                Thread.sleep(1000);
+
+                assertTrue("Group member did not recv data: ", new String(server.rdp
 				.getData(), 0, server.rdp.getLength()).equals(msg));
 	}
 
@@ -615,7 +609,7 @@
 	/**
 	 * @tests java.net.MulticastSocket#leaveGroup(java.net.SocketAddress,java.net.NetworkInterface)
 	 */
-	public void test_leaveGroupLjava_net_SocketAddressLjava_net_NetworkInterface() {
+	public void test_leaveGroupLjava_net_SocketAddressLjava_net_NetworkInterface() throws Exception
{
 		// security manager that allows us to check that we only return the
 		// addresses that we should
 		class mySecurityManager extends SecurityManager {
@@ -631,83 +625,80 @@
 		SocketAddress groupSockAddr = null;
 		SocketAddress groupSockAddr2 = null;
 
-		try {
-			Enumeration theInterfaces = NetworkInterface.getNetworkInterfaces();
+                Enumeration theInterfaces = NetworkInterface.getNetworkInterfaces();
 
-			// first validate that we handle a null group ok
-			mss = new MulticastSocket(groupPort);
-			try {
-				mss.leaveGroup(null, null);
-				fail("Did not get exception when group was null");
-			} catch (IllegalArgumentException e) {
-			}
+                // first validate that we handle a null group ok
+                mss = new MulticastSocket(groupPort);
+                try {
+                        mss.leaveGroup(null, null);
+                        fail("Did not get exception when group was null");
+                } catch (IllegalArgumentException e) {
+                }
 
-			// now validate we get the expected error if the address specified
-			// is not a multicast group
-			try {
-				group = InetAddress.getByName("255.255.255.255");
-				groupSockAddr = new InetSocketAddress(group, groupPort);
-				mss.leaveGroup(groupSockAddr, null);
-				fail("Did not get exception when group is not a multicast address");
-			} catch (IOException e) {
-			}
+                // now validate we get the expected error if the address specified
+                // is not a multicast group
+                try {
+                        group = InetAddress.getByName("255.255.255.255");
+                        groupSockAddr = new InetSocketAddress(group, groupPort);
+                        mss.leaveGroup(groupSockAddr, null);
+                        fail("Did not get exception when group is not a multicast address");
+                } catch (IOException e) {
+                }
 
-			// now try to leave a group if we are not authorized
-			// set the security manager that will make the first address not
-			// visible
-			System.setSecurityManager(new mySecurityManager());
-			try {
-				group = InetAddress.getByName("224.0.0.3");
-				groupSockAddr = new InetSocketAddress(group, groupPort);
-				mss.leaveGroup(groupSockAddr, null);
-				fail("Did not get exception when joining group is not allowed");
-			} catch (SecurityException e) {
-			}
-			System.setSecurityManager(null);
+                // now try to leave a group if we are not authorized
+                // set the security manager that will make the first address not
+                // visible
+                System.setSecurityManager(new mySecurityManager());
+                try {
+                        group = InetAddress.getByName("224.0.0.3");
+                        groupSockAddr = new InetSocketAddress(group, groupPort);
+                        mss.leaveGroup(groupSockAddr, null);
+                        fail("Did not get exception when joining group is not allowed");
+                } catch (SecurityException e) {
+                }
+                System.setSecurityManager(null);
 
-			if (atLeastOneInterface) {
+                if (atLeastOneInterface) {
 
-				// now test that we can join and leave a group successfully
-				groupPort = Support_PortManager.getNextPortForUDP();
-				mss = new MulticastSocket(groupPort);
-				groupSockAddr = new InetSocketAddress(group, groupPort);
-				mss.joinGroup(groupSockAddr, null);
-				mss.leaveGroup(groupSockAddr, null);
-				try {
-					mss.leaveGroup(groupSockAddr, null);
-					fail(
-							"Did not get exception when trying to leave group that was allready left");
-				} catch (IOException e) {
-				}
-
-				InetAddress group2 = InetAddress.getByName("224.0.0.4");
-				groupSockAddr2 = new InetSocketAddress(group2, groupPort);
-				mss.joinGroup(groupSockAddr, networkInterface1);
-				try {
-					mss.leaveGroup(groupSockAddr2, networkInterface1);
-					fail(
-							"Did not get exception when trying to leave group that was never joined");
-				} catch (IOException e) {
-				}
-
-				mss.leaveGroup(groupSockAddr, networkInterface1);
-				if (atLeastTwoInterfaces) {
-					mss.joinGroup(groupSockAddr, networkInterface1);
-					try {
-						mss.leaveGroup(groupSockAddr, networkInterface2);
-						fail(
-								"Did not get exception when trying to leave group on wrong interface joined on ["
-										+ networkInterface1
-										+ "] left on ["
-										+ networkInterface2 + "]");
-					} catch (IOException e) {
-					}
-				}
-			}
-		} catch (Exception e) {
-			fail("Exception during leaveGroup test: " + e.toString());
-		}
-		System.setSecurityManager(null);
+                        // now test that we can join and leave a group successfully
+                        groupPort = Support_PortManager.getNextPortForUDP();
+                        mss = new MulticastSocket(groupPort);
+                        groupSockAddr = new InetSocketAddress(group, groupPort);
+                        mss.joinGroup(groupSockAddr, null);
+                        mss.leaveGroup(groupSockAddr, null);
+                        try {
+                                mss.leaveGroup(groupSockAddr, null);
+                                fail(
+                                                "Did not get exception when trying to leave
group that was allready left");
+                        } catch (IOException e) {
+                        }
+
+                        InetAddress group2 = InetAddress.getByName("224.0.0.4");
+                        groupSockAddr2 = new InetSocketAddress(group2, groupPort);
+                        mss.joinGroup(groupSockAddr, networkInterface1);
+                        try {
+                                mss.leaveGroup(groupSockAddr2, networkInterface1);
+                                fail(
+                                                "Did not get exception when trying to leave
group that was never joined");
+                        } catch (IOException e) {
+                        }
+
+                        mss.leaveGroup(groupSockAddr, networkInterface1);
+                        if (atLeastTwoInterfaces) {
+                                mss.joinGroup(groupSockAddr, networkInterface1);
+                                try {
+                                        mss.leaveGroup(groupSockAddr, networkInterface2);
+                                        fail(
+                                                        "Did not get exception when trying
to leave group on wrong interface joined on ["
+                                                                        + networkInterface1
+                                                                        + "] left on ["
+                                                                        + networkInterface2
+ "]");
+                                } catch (IOException e) {
+                                }
+                        }
+                }
+
+                System.setSecurityManager(null);
 	}
 
 	/**
@@ -1040,7 +1031,7 @@
 	/**
 	 * @tests java.net.MulticastSocket#setReuseAddress(boolean)
 	 */
-	public void test_setReuseAddressZ() {
+	public void test_setReuseAddressZ() throws Exception {
 		try {
 			// test case were we set it to false
 			MulticastSocket theSocket1 = null;
@@ -1066,21 +1057,17 @@
 				theSocket2.close();
 
 			// test case were we set it to true
-			try {
-				InetSocketAddress theAddress = new InetSocketAddress(
-						InetAddress.getLocalHost(), Support_PortManager
-								.getNextPortForUDP());
-				theSocket1 = new MulticastSocket(null);
-				theSocket2 = new MulticastSocket(null);
-				theSocket1.setReuseAddress(true);
-				theSocket2.setReuseAddress(true);
-				theSocket1.bind(theAddress);
-				theSocket2.bind(theAddress);
-			} catch (Exception e) {
-				fail(
-						"unexpected exception when trying to connect to do duplicate socket bind with re-useaddr
set to true");
-			}
-			if (theSocket1 != null)
+                        InetSocketAddress theAddress = new InetSocketAddress(
+                                        InetAddress.getLocalHost(), Support_PortManager
+                                                        .getNextPortForUDP());
+                        theSocket1 = new MulticastSocket(null);
+                        theSocket2 = new MulticastSocket(null);
+                        theSocket1.setReuseAddress(true);
+                        theSocket2.setReuseAddress(true);
+                        theSocket1.bind(theAddress);
+                        theSocket2.bind(theAddress);
+
+                        if (theSocket1 != null)
 				theSocket1.close();
 			if (theSocket2 != null)
 				theSocket2.close();
@@ -1088,9 +1075,9 @@
 			// test the default case which we expect to be the same on all
 			// platforms
 			try {
-				InetSocketAddress theAddress = new InetSocketAddress(
-						InetAddress.getLocalHost(), Support_PortManager
-								.getNextPortForUDP());
+				theAddress = new InetSocketAddress(
+					InetAddress.getLocalHost(), Support_PortManager
+							.getNextPortForUDP());
 				theSocket1 = new MulticastSocket(null);
 				theSocket2 = new MulticastSocket(null);
 				theSocket1.bind(theAddress);

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/net/ServerSocketTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/net/ServerSocketTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/net/ServerSocketTest.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/net/ServerSocketTest.java
Wed Oct 31 01:42:07 2007
@@ -323,14 +323,8 @@
             s.setSoTimeout(100);
             s.accept();
         } catch (InterruptedIOException e) {
-            try {
-                assertEquals("Set incorrect sotimeout", 100, s.getSoTimeout());
-                return;
-            } catch (Exception x) {
-                fail("Exception during setSOTimeout: " + e.toString());
-            }
-        } catch (IOException iox) {
-            fail("IOException during setSotimeout: " + iox.toString());
+            assertEquals("Set incorrect sotimeout", 100, s.getSoTimeout());
+            return;
         }
 
         // Timeout should not trigger in this case
@@ -551,41 +545,37 @@
     /**
      * @tests java.net.ServerSocket#getLocalSocketAddress()
      */
-    public void test_getLocalSocketAddress() {
+    public void test_getLocalSocketAddress() throws Exception {
         // set up server connect and then validate that we get the right
         // response for the local address
-        try {
-            ServerSocket theSocket = new ServerSocket(0, 5, InetAddress
-                    .getLocalHost());
-            int portNumber = theSocket.getLocalPort();
-            assertTrue("Returned incorrect InetSocketAddress(1):"
-                    + theSocket.getLocalSocketAddress().toString()
-                    + "Expected: "
-                    + (new InetSocketAddress(InetAddress.getLocalHost(),
-                            portNumber)).toString(), theSocket
-                    .getLocalSocketAddress().equals(
-                            new InetSocketAddress(InetAddress.getLocalHost(),
-                                    portNumber)));
-            theSocket.close();
-
-            // now create a socket that is not bound and validate we get the
-            // right answer
-            theSocket = new ServerSocket();
-            assertNull(
-                    "Returned incorrect InetSocketAddress -unbound socket- Expected null",
-                    theSocket.getLocalSocketAddress());
-
-            // now bind the socket and make sure we get the right answer
-            theSocket
-                    .bind(new InetSocketAddress(InetAddress.getLocalHost(), 0));
-            int localPort = theSocket.getLocalPort();
-            assertEquals("Returned incorrect InetSocketAddress(2):", theSocket
-                    .getLocalSocketAddress(), new InetSocketAddress(InetAddress
-                    .getLocalHost(), localPort));
-            theSocket.close();
-        } catch (Exception e) {
-            fail("Exception during getLocalSocketAddress test: " + e);
-        }
+        ServerSocket theSocket = new ServerSocket(0, 5, InetAddress
+                .getLocalHost());
+        int portNumber = theSocket.getLocalPort();
+        assertTrue("Returned incorrect InetSocketAddress(1):"
+                + theSocket.getLocalSocketAddress().toString()
+                + "Expected: "
+                + (new InetSocketAddress(InetAddress.getLocalHost(),
+                        portNumber)).toString(), theSocket
+                .getLocalSocketAddress().equals(
+                        new InetSocketAddress(InetAddress.getLocalHost(),
+                                portNumber)));
+        theSocket.close();
+
+        // now create a socket that is not bound and validate we get the
+        // right answer
+        theSocket = new ServerSocket();
+        assertNull(
+                "Returned incorrect InetSocketAddress -unbound socket- Expected null",
+                theSocket.getLocalSocketAddress());
+
+        // now bind the socket and make sure we get the right answer
+        theSocket
+                .bind(new InetSocketAddress(InetAddress.getLocalHost(), 0));
+        int localPort = theSocket.getLocalPort();
+        assertEquals("Returned incorrect InetSocketAddress(2):", theSocket
+                .getLocalSocketAddress(), new InetSocketAddress(InetAddress
+                .getLocalHost(), localPort));
+        theSocket.close();
     }
 
     /**

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/net/SocketTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/net/SocketTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/net/SocketTest.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/net/SocketTest.java
Wed Oct 31 01:42:07 2007
@@ -1335,30 +1335,24 @@
 			theSocket = new Socket();
 			theSocket.connect(null);
 			fail("No exception after null address passed in");
-		} catch (Exception e) {
-			assertTrue("Wrong exception null address passed in: "
-					+ e.toString(), (e instanceof IllegalArgumentException));
+		} catch (IllegalArgumentException e) {
+			// Expected
 		}
 
 		try {
 			theSocket = new Socket();
 			theSocket.connect(invalidType);
 			fail("No exception when invalid socket address type passed in: ");
-		} catch (Exception e) {
-			assertTrue(
-					"Wrong exception when when invalid socket address type passed in: "
-							+ e.toString(),
-					(e instanceof IllegalArgumentException));
+		} catch (IllegalArgumentException e) {
+			// Expected
 		}
 
 		try {
 			theSocket = new Socket();
 			theSocket.connect(nonConnectableAddress);
 			fail("No exception when non Connectable Address passed in: ");
-		} catch (Exception e) {
-			assertTrue(
-					"Wrong exception when non Connectable Address passed in: "
-							+ e.toString(), (e instanceof ConnectException));
+		} catch (ConnectException e) {
+			//Expected
 		}
 
 		// now validate that we get a connect exception if we try to connect to
@@ -1368,10 +1362,8 @@
 			theSocket.connect(theAddress);
 			theSocket.close();
 			fail("No exception when connecting to address nobody listening on: ");
-		} catch (Exception e) {
-			assertTrue(
-					"Wrong exception when connecting to address nobody listening on: "
-							+ e.toString(), (e instanceof ConnectException));
+		} catch (ConnectException e) {
+			// Expected
 		}
 
 		// now validate that we can acutally connect when sombody is listening
@@ -1574,39 +1566,32 @@
 			theSocket = new Socket();
 			theSocket.connect(theAddress, -100);
 			fail("No exception after negative timeout passed in");
-		} catch (Exception e) {
-			assertTrue("Wrong exception when negative timeout passed in: "
-					+ e.toString(), (e instanceof IllegalArgumentException));
+		} catch (IllegalArgumentException e) {
+			// Expected
 		}
 
 		try {
 			theSocket = new Socket();
 			theSocket.connect(null, 0);
 			fail("No exception after null address passed in");
-		} catch (Exception e) {
-			assertTrue("Wrong exception null address passed in: "
-					+ e.toString(), (e instanceof IllegalArgumentException));
+		} catch (IllegalArgumentException e) {
+			// Expected
 		}
 
 		try {
 			theSocket = new Socket();
 			theSocket.connect(invalidType, 100000);
 			fail("No exception when invalid socket address type passed in: ");
-		} catch (Exception e) {
-			assertTrue(
-					"Wrong exception when when invalid socket address type passed in: "
-							+ e.toString(),
-					(e instanceof IllegalArgumentException));
+		} catch (IllegalArgumentException e) {
+			// Expected
 		}
 
 		try {
 			theSocket = new Socket();
 			theSocket.connect(nonConnectableAddress, 100000);
 			fail("No exception when non Connectable Address passed in: ");
-		} catch (Exception e) {
-			assertTrue(
-					"Wrong exception when non Connectable Address passed in: "
-							+ e.toString(), (e instanceof SocketException));
+		} catch (SocketException e) {
+			// Expected
 		}
 
 		// now validate that we get a connect exception if we try to connect to
@@ -1616,10 +1601,8 @@
 			theSocket.connect(theAddress, 0);
 			theSocket.close();
 			fail("No timeout:No exception when connecting to address nobody listening on: ");
-		} catch (Exception e) {
-			assertTrue(
-					"No timeout:Wrong exception when connecting to address nobody listening on: "
-							+ e.toString(), (e instanceof ConnectException));
+		} catch (ConnectException e) {
+			// Expected
 		}
 
 		// now validate that we can acutally connect when sombody is listening
@@ -1637,10 +1620,8 @@
 			theSocket.connect(nonListeningAddress, 100000);
 			theSocket.close();
 			fail("No exception when connecting to address nobody listening on: ");
-		} catch (Exception e) {
-			assertTrue(
-					"Wrong exception when connecting to address nobody listening on: "
-							+ e.toString(), (e instanceof ConnectException));
+		} catch (ConnectException e) {
+			// Expected
 		}
 
 		// now validate that we get a interrupted exception if we try to connect
@@ -1651,11 +1632,8 @@
 			theSocket.connect(nonReachableAddress, 200);
 			theSocket.close();
 			fail("No interrupted exception when connecting to address nobody listening on with short
timeout 200: ");
-		} catch (Exception e) {
-			assertTrue(
-					"Wrong exception when connecting to address nobody listening on with short timeout 200:
"
-							+ e.toString(),
-					(e instanceof SocketTimeoutException));
+		} catch (SocketTimeoutException e) {
+			// Expected
 		}
 
 		// now validate that we get a interrupted exception if we try to connect
@@ -1666,11 +1644,8 @@
 			theSocket.connect(nonReachableAddress, 40);
 			theSocket.close();
 			fail("No interrupted exception when connecting to address nobody listening on with short
timeout 40: ");
-		} catch (Exception e) {
-			assertTrue(
-					"Wrong exception when connecting to address nobody listening on with short timeout 40:
"
-							+ e.toString(),
-					(e instanceof SocketTimeoutException));
+		} catch (SocketTimeoutException e) {
+			// Expected
 		}
 
 		// now validate that we can acutally connect when sombody is listening

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/net/URITest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/net/URITest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/net/URITest.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/net/URITest.java
Wed Oct 31 01:42:07 2007
@@ -511,7 +511,7 @@
     /**
      * @tests java.net.URI#compareTo(java.lang.Object)
      */
-    public void test_compareToLjava_lang_Object() {
+    public void test_compareToLjava_lang_Object() throws Exception {
         // compareTo tests
 
         String[][] compareToData = new String[][] {
@@ -573,18 +573,13 @@
 
         // test compareTo functionality
         for (int i = 0; i < compareToResults.length; i++) {
-            try {
-                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]);
-                }
-            } catch (Exception e) {
-                fail("Error in compareTo test of " + compareToData[i][0]
-                        + " compared to " + compareToData[i][1] + ": " + e);
+            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]);
             }
         }
     }
@@ -630,7 +625,7 @@
     /**
      * @tests java.net.URI#equals(java.lang.Object)
      */
-    public void test_equalsLjava_lang_Object() {
+    public void test_equalsLjava_lang_Object() throws Exception {
         String[][] equalsData = new String[][] {
                 { "", "" }, // null frags
                 { "/path", "/path#frag" },
@@ -689,17 +684,12 @@
 
         // test equals functionality
         for (int i = 0; i < equalsResults.length; i++) {
-            try {
-                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]);
-                }
-            } catch (Exception e) {
-                fail("Exception during equals testing data " + equalsData[i][0]
-                        + " == " + equalsData[i][1] + "? " + e);
+            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]);
             }
         }
 

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/net/URLConnectionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/net/URLConnectionTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/net/URLConnectionTest.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/net/URLConnectionTest.java
Wed Oct 31 01:42:07 2007
@@ -212,26 +212,21 @@
 	 * @tests java.net.URLConnection#getDefaultRequestProperty(java.lang.String)
 	 */
 	public void test_getDefaultRequestPropertyLjava_lang_String() {
-		try {
-			URLConnection.setDefaultRequestProperty("Shmoo", "Blah");
-			assertNull(
-					"setDefaultRequestProperty should have returned: null, but returned: "
-							+ URLConnection.getDefaultRequestProperty("Shmoo"),
-					URLConnection.getDefaultRequestProperty("Shmoo"));
-			URLConnection.setDefaultRequestProperty("Shmoo", "Boom");
-			assertNull(
-					"setDefaultRequestProperty should have returned: null, but returned: "
-							+ URLConnection.getDefaultRequestProperty("Shmoo"),
-					URLConnection.getDefaultRequestProperty("Shmoo"));
-			assertNull(
-					"setDefaultRequestProperty should have returned: null, but returned: "
-							+ URLConnection.getDefaultRequestProperty("Kapow"),
-					URLConnection.getDefaultRequestProperty("Kapow"));
-			URLConnection.setDefaultRequestProperty("Shmoo", null);
-		} catch (Exception e) {
-			fail("Exception during test : " + e.getMessage());
-		}
-
+                URLConnection.setDefaultRequestProperty("Shmoo", "Blah");
+                assertNull(
+                                "setDefaultRequestProperty should have returned: null, but
returned: "
+                                                + URLConnection.getDefaultRequestProperty("Shmoo"),
+                                URLConnection.getDefaultRequestProperty("Shmoo"));
+                URLConnection.setDefaultRequestProperty("Shmoo", "Boom");
+                assertNull(
+                                "setDefaultRequestProperty should have returned: null, but
returned: "
+                                                + URLConnection.getDefaultRequestProperty("Shmoo"),
+                                URLConnection.getDefaultRequestProperty("Shmoo"));
+                assertNull(
+                                "setDefaultRequestProperty should have returned: null, but
returned: "
+                                                + URLConnection.getDefaultRequestProperty("Kapow"),
+                                URLConnection.getDefaultRequestProperty("Kapow"));
+                URLConnection.setDefaultRequestProperty("Shmoo", null);
 	}
 
 	/**
@@ -630,29 +625,24 @@
 				+ Support_HttpServer.AUTHTEST;
 
 		// Authentication test
-		try {
-			// set up a very simple authenticator
-			Authenticator.setDefault(new Authenticator() {
-				public PasswordAuthentication getPasswordAuthentication() {
-					return new PasswordAuthentication("test", "password"
-							.toCharArray());
-				}
-			});
-			try {
-				client.open(authTestUrl);
-				is = client.getInputStream();
-				int c = is.read();
-				while (c > 0)
-					c = is.read();
-				c = is.read();
-				is.close();
-			} catch (FileNotFoundException e) {
-				fail("Error performing authentication test: " + e);
-			}
-		} catch (Exception e) {
-			fail("Exception during test3: " + e);
-			e.printStackTrace();
-		}
+                // set up a very simple authenticator
+                Authenticator.setDefault(new Authenticator() {
+                        public PasswordAuthentication getPasswordAuthentication() {
+                                return new PasswordAuthentication("test", "password"
+                                                .toCharArray());
+                        }
+                });
+                try {
+                        client.open(authTestUrl);
+                        is = client.getInputStream();
+                        int c = is.read();
+                        while (c > 0)
+                                c = is.read();
+                        c = is.read();
+                        is.close();
+                } catch (FileNotFoundException e) {
+                        fail("Error performing authentication test: " + e);
+                }
 
 		final String invalidLocation = "/missingFile.htm";
 		final String redirectTestUrl = "http://localhost:" + server.getPort()
@@ -673,11 +663,7 @@
 			is.close();
 			fail("Incorrect data returned on redirect to non-existent file.");
 		} catch (FileNotFoundException e) {
-		} catch (Exception e) {
-
-			e.printStackTrace();
-			fail("Exception during test4: " + e);
-		}
+		} 
 		server.stopServer();
 
 	}
@@ -807,58 +793,53 @@
 	/**
 	 * @tests java.net.URLConnection#getPermission()
 	 */
-	public void test_getPermission() {
-		try {
-			java.security.Permission p = uc.getPermission();
-			assertTrue("Permission of wrong type: " + p.toString(),
-					p instanceof java.net.SocketPermission);
-			assertTrue("Permission has wrong name: " + p.getName(), p.getName()
-					.contains("localhost:"+port));
-
-			URL fileUrl = new URL("file:myfile");
-			Permission perm = new FilePermission("myfile", "read");
-			Permission result = fileUrl.openConnection().getPermission();
-			assertTrue("Wrong file: permission 1:" + perm + " , " + result,
-					result.equals(perm));
-
-			fileUrl = new URL("file:/myfile/");
-			perm = new FilePermission("/myfile", "read");
-			result = fileUrl.openConnection().getPermission();
-			assertTrue("Wrong file: permission 2:" + perm + " , " + result,
-					result.equals(perm));
-
-			fileUrl = new URL("file:///host/volume/file");
-			perm = new FilePermission("/host/volume/file", "read");
-			result = fileUrl.openConnection().getPermission();
-			assertTrue("Wrong file: permission 3:" + perm + " , " + result,
-					result.equals(perm));
-
-			URL httpUrl = new URL("http://home/myfile/");
-			assertTrue("Wrong http: permission", httpUrl.openConnection()
-					.getPermission().equals(
-							new SocketPermission("home:80", "connect")));
-			httpUrl = new URL("http://home2:8080/myfile/");
-			assertTrue("Wrong http: permission", httpUrl.openConnection()
-					.getPermission().equals(
-							new SocketPermission("home2:8080", "connect")));
-			URL ftpUrl = new URL("ftp://home/myfile/");
-			assertTrue("Wrong ftp: permission", ftpUrl.openConnection()
-					.getPermission().equals(
-							new SocketPermission("home:21", "connect")));
-			ftpUrl = new URL("ftp://home2:22/myfile/");
-			assertTrue("Wrong ftp: permission", ftpUrl.openConnection()
-					.getPermission().equals(
-							new SocketPermission("home2:22", "connect")));
-
-			URL jarUrl = new URL("jar:file:myfile!/");
-			perm = new FilePermission("myfile", "read");
-			result = jarUrl.openConnection().getPermission();
-			assertTrue("Wrong jar: permission:" + perm + " , " + result, result
-					.equals(new FilePermission("myfile", "read")));
-		} catch (Exception e) {
-			fail("Exception during test : " + e.getMessage());
-		}
-
+	public void test_getPermission() throws Exception {
+                java.security.Permission p = uc.getPermission();
+                assertTrue("Permission of wrong type: " + p.toString(),
+                                p instanceof java.net.SocketPermission);
+                assertTrue("Permission has wrong name: " + p.getName(), p.getName()
+                                .contains("localhost:"+port));
+
+                URL fileUrl = new URL("file:myfile");
+                Permission perm = new FilePermission("myfile", "read");
+                Permission result = fileUrl.openConnection().getPermission();
+                assertTrue("Wrong file: permission 1:" + perm + " , " + result,
+                                result.equals(perm));
+
+                fileUrl = new URL("file:/myfile/");
+                perm = new FilePermission("/myfile", "read");
+                result = fileUrl.openConnection().getPermission();
+                assertTrue("Wrong file: permission 2:" + perm + " , " + result,
+                                result.equals(perm));
+
+                fileUrl = new URL("file:///host/volume/file");
+                perm = new FilePermission("/host/volume/file", "read");
+                result = fileUrl.openConnection().getPermission();
+                assertTrue("Wrong file: permission 3:" + perm + " , " + result,
+                                result.equals(perm));
+
+                URL httpUrl = new URL("http://home/myfile/");
+                assertTrue("Wrong http: permission", httpUrl.openConnection()
+                                .getPermission().equals(
+                                                new SocketPermission("home:80", "connect")));
+                httpUrl = new URL("http://home2:8080/myfile/");
+                assertTrue("Wrong http: permission", httpUrl.openConnection()
+                                .getPermission().equals(
+                                                new SocketPermission("home2:8080", "connect")));
+                URL ftpUrl = new URL("ftp://home/myfile/");
+                assertTrue("Wrong ftp: permission", ftpUrl.openConnection()
+                                .getPermission().equals(
+                                                new SocketPermission("home:21", "connect")));
+                ftpUrl = new URL("ftp://home2:22/myfile/");
+                assertTrue("Wrong ftp: permission", ftpUrl.openConnection()
+                                .getPermission().equals(
+                                                new SocketPermission("home2:22", "connect")));
+
+                URL jarUrl = new URL("jar:file:myfile!/");
+                perm = new FilePermission("myfile", "read");
+                result = jarUrl.openConnection().getPermission();
+                assertTrue("Wrong jar: permission:" + perm + " , " + result, result
+                                .equals(new FilePermission("myfile", "read")));
 	}
 
 	/**

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/net/URLEncoderTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/net/URLEncoderTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/net/URLEncoderTest.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/net/URLEncoderTest.java
Wed Oct 31 01:42:07 2007
@@ -33,16 +33,13 @@
 		final String URL = "http://" + Support_Configuration.HomeAddress;
 		final String URL2 = "telnet://justWantToHaveFun.com:400";
 		final String URL3 = "file://myServer.org/a file with spaces.jpg";
-		try {
-			assertTrue("1. Incorrect encoding/decoding", URLDecoder.decode(
-					URLEncoder.encode(URL)).equals(URL));
-			assertTrue("2. Incorrect encoding/decoding", URLDecoder.decode(
-					URLEncoder.encode(URL2)).equals(URL2));
-			assertTrue("3. Incorrect encoding/decoding", URLDecoder.decode(
-					URLEncoder.encode(URL3)).equals(URL3));
-		} catch (Exception e) {
-			fail("Exception during test : " + e.getMessage());
-		}
+
+                assertTrue("1. Incorrect encoding/decoding", URLDecoder.decode(
+                                URLEncoder.encode(URL)).equals(URL));
+                assertTrue("2. Incorrect encoding/decoding", URLDecoder.decode(
+                                URLEncoder.encode(URL2)).equals(URL2));
+                assertTrue("3. Incorrect encoding/decoding", URLDecoder.decode(
+                                URLEncoder.encode(URL3)).equals(URL3));
 	}
 
 	/**



Mime
View raw message