harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ghar...@apache.org
Subject svn commit: r415394 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/net/Socket.java test/java/tests/api/java/net/SocketTest.java
Date Mon, 19 Jun 2006 19:37:01 GMT
Author: gharley
Date: Mon Jun 19 12:37:01 2006
New Revision: 415394

URL: http://svn.apache.org/viewvc?rev=415394&view=rev
Log:
HARMONY-600 : java.net.Socket.connect(SocketAddress) throws a different exception from RI

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

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Socket.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Socket.java?rev=415394&r1=415393&r2=415394&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Socket.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Socket.java
Mon Jun 19 12:37:01 2006
@@ -957,8 +957,7 @@
 		InetSocketAddress inetAddr = (InetSocketAddress) remoteAddr;
 		InetAddress addr;
 		if ((addr = inetAddr.getAddress()) == null) {
-            throw new SocketException(Msg.getString(
-					"K0317", inetAddr.getHostName())); //$NON-NLS-1$
+            throw new UnknownHostException(Msg.getString("K0317"));//$NON-NLS-1$
         }
 		int port = inetAddr.getPort();
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/SocketTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/SocketTest.java?rev=415394&r1=415393&r2=415394&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/SocketTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/SocketTest.java
Mon Jun 19 12:37:01 2006
@@ -30,6 +30,7 @@
 import java.net.SocketAddress;
 import java.net.SocketException;
 import java.net.SocketTimeoutException;
+import java.net.UnknownHostException;
 import java.security.Permission;
 
 import tests.support.Support_Configuration;
@@ -2352,6 +2353,50 @@
 		}
 
 	}
+    
+    /**
+     * @tests Socket#connect(SocketAddress) try an unknownhost
+     */
+    public void test_connect_unknownhost() throws Exception {
+        Socket socket = new Socket();
+        try {
+            socket.connect(new InetSocketAddress("unknownhost", 12345));
+            fail("Should throw UnknownHostException");
+        } catch (UnknownHostException e) {
+            // expected
+        }
+    }
+
+    /**
+     * @tests Socket#connect(SocketAddress) try an unknownhost created by
+     *        createUnresolved()
+     */
+    public void test_connect_unresolved_unknown() throws Exception {
+        Socket socket = new Socket();
+        try {
+            socket.connect(InetSocketAddress.createUnresolved("unknownhost",
+                    12345));
+            fail("Should throw UnknownHostException");
+        } catch (UnknownHostException e) {
+            // expected
+        }
+    }
+
+    /**
+     * @tests Socket#connect(SocketAddress) try a known host created by
+     *        createUnresolved()
+     */
+    public void test_connect_unresolved() throws Exception {
+        Socket socket = new Socket();
+        try {
+            socket.connect(InetSocketAddress.createUnresolved(
+                    Support_Configuration.SocksServerTestHost,
+                    Support_Configuration.SocksServerTestPort));
+            fail("Should throw UnknownHostException");
+        } catch (UnknownHostException e) {
+            // expected
+        }
+    }
 
 	/**
 	 * Sets up the fixture, for example, open a network connection. This method



Mime
View raw message