harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r431541 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/net/MulticastSocket.java test/java/tests/api/java/net/MulticastSocketTest.java
Date Tue, 15 Aug 2006 06:21:13 GMT
Author: pyang
Date: Mon Aug 14 23:21:12 2006
New Revision: 431541

URL: http://svn.apache.org/viewvc?rev=431541&view=rev
Log:
Patch applied for HARMONY-1162 ([classlib][luni] java.net.MulticastSocket constructor doesn't
call DatagramSocket.setReuseAddress(boolean) as spec requires.)

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

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/MulticastSocket.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/MulticastSocket.java?rev=431541&r1=431540&r2=431541&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/MulticastSocket.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/MulticastSocket.java
Mon Aug 14 23:21:12 2006
@@ -43,6 +43,7 @@
 	 */
 	public MulticastSocket() throws IOException {
 		super();
+        setReuseAddress(true);
 	}
 
 	/**
@@ -56,6 +57,7 @@
 	 */
 	public MulticastSocket(int aPort) throws IOException {
 		super(aPort);
+        setReuseAddress(true);
 	}
 
 	/**
@@ -580,6 +582,7 @@
 	 */
 	public MulticastSocket(SocketAddress localAddr) throws IOException {
 		super(localAddr);
+        setReuseAddress(true);
 	}
 
 	/**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/MulticastSocketTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/MulticastSocketTest.java?rev=431541&r1=431540&r2=431541&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/MulticastSocketTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/MulticastSocketTest.java
Mon Aug 14 23:21:12 2006
@@ -116,7 +116,9 @@
 	 */
 	public void test_Constructor() throws IOException {
 		// regression test for 497
-        new MulticastSocket();
+        MulticastSocket s = new MulticastSocket();
+        // regression test for Harmony-1162
+        assertTrue(s.getReuseAddress());
 	}
 
 	/**
@@ -130,6 +132,8 @@
 			mss = new MulticastSocket();
 			int port = mss.getLocalPort();
 			dup = new MulticastSocket(port);
+            // regression test for Harmony-1162
+            assertTrue(dup.getReuseAddress());
 		} catch (IOException e) {
 			fail("duplicate binding not allowed: " + e);
 		}
@@ -921,40 +925,41 @@
 	/**
 	 * @tests java.net.MulticastSocket#MulticastSocket(java.net.SocketAddress)
 	 */
-	public void test_ConstructorLjava_net_SocketAddress() {
-		try {
-			MulticastSocket ms = new MulticastSocket((SocketAddress) null);
-			assertTrue("should not be bound", !ms.isBound() && !ms.isClosed()
-					&& !ms.isConnected());
-			ms.bind(new InetSocketAddress(InetAddress.getLocalHost(),
-					Support_PortManager.getNextPort()));
-			assertTrue("should be bound", ms.isBound() && !ms.isClosed()
-					&& !ms.isConnected());
-			ms.close();
-			assertTrue("should be closed", ms.isClosed());
-			ms = new MulticastSocket(new InetSocketAddress(InetAddress
-					.getLocalHost(), Support_PortManager.getNextPort()));
-			assertTrue("should be bound", ms.isBound() && !ms.isClosed()
-					&& !ms.isConnected());
-			ms.close();
-			assertTrue("should be closed", ms.isClosed());
-			ms = new MulticastSocket(new InetSocketAddress("localhost",
-					Support_PortManager.getNextPort()));
-			assertTrue("should be bound", ms.isBound() && !ms.isClosed()
-					&& !ms.isConnected());
-			ms.close();
-			assertTrue("should be closed", ms.isClosed());
-			boolean exception = false;
-			try {
-				ms = new MulticastSocket(new InetSocketAddress(
-						"unresolvedname", Support_PortManager.getNextPort()));
-			} catch (IOException e) {
-				exception = true;
-			}
-			assertTrue("Expected IOException", exception);
-		} catch (IOException e) {
-			fail("Unexpected: " + e);
-		}
+	public void test_ConstructorLjava_net_SocketAddress() throws Exception {	
+		MulticastSocket ms = new MulticastSocket((SocketAddress) null);
+        assertTrue("should not be bound", !ms.isBound() && !ms.isClosed()
+                && !ms.isConnected());
+        ms.bind(new InetSocketAddress(InetAddress.getLocalHost(),
+                Support_PortManager.getNextPort()));
+        assertTrue("should be bound", ms.isBound() && !ms.isClosed()
+                && !ms.isConnected());
+        ms.close();
+        assertTrue("should be closed", ms.isClosed());
+        ms = new MulticastSocket(new InetSocketAddress(InetAddress
+                .getLocalHost(), Support_PortManager.getNextPort()));
+        assertTrue("should be bound", ms.isBound() && !ms.isClosed()
+                && !ms.isConnected());
+        ms.close();
+        assertTrue("should be closed", ms.isClosed());
+        ms = new MulticastSocket(new InetSocketAddress("localhost",
+                Support_PortManager.getNextPort()));
+        assertTrue("should be bound", ms.isBound() && !ms.isClosed()
+                && !ms.isConnected());
+        ms.close();
+        assertTrue("should be closed", ms.isClosed());
+        boolean exception = false;
+        try {
+            ms = new MulticastSocket(new InetSocketAddress("unresolvedname",
+                    Support_PortManager.getNextPort()));
+        } catch (IOException e) {
+            exception = true;
+        }
+        assertTrue("Expected IOException", exception);
+
+        // regression test for Harmony-1162
+        InetSocketAddress addr = new InetSocketAddress("0.0.0.0", 0);
+        MulticastSocket s = new MulticastSocket(addr);
+        assertTrue(s.getReuseAddress()); 
 	}
 
 	/**



Mime
View raw message