changeset 6091:0bb10924802a

7183800: TEST_BUG: Update tests to run on Ubuntu 12.04 (localhost is 127.0.1.1) Reviewed-by: alanb, chegar Contributed-by: yiming.wang@oracle.com
author alanb
date Thu, 14 Mar 2013 16:59:06 +0000
parents a13d508c69a8
children bc8119b0f297
files test/java/nio/channels/DatagramChannel/Connect.java test/java/nio/channels/DatagramChannel/ConnectedSend.java test/java/nio/channels/spi/SelectorProvider/inheritedChannel/Launcher.java test/javax/management/remote/mandatory/connection/RMIConnectionIdTest.java
diffstat 4 files changed, 24 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/test/java/nio/channels/DatagramChannel/Connect.java	Mon May 20 15:35:37 2013 +0400
+++ b/test/java/nio/channels/DatagramChannel/Connect.java	Thu Mar 14 16:59:06 2013 +0000
@@ -22,6 +22,7 @@
  */
 
 /* @test
+ * @bug 4313882 7183800
  * @summary Test DatagramChannel's send and receive methods
  * @author Mike McCloskey
  */
@@ -88,6 +89,9 @@
                 bb.put("hello".getBytes());
                 bb.flip();
                 InetAddress address = InetAddress.getLocalHost();
+                if (address.isLoopbackAddress()) {
+                    address = InetAddress.getLoopbackAddress();
+                }
                 InetSocketAddress isa = new InetSocketAddress(address, port);
                 dc.connect(isa);
                 dc.write(bb);
--- a/test/java/nio/channels/DatagramChannel/ConnectedSend.java	Mon May 20 15:35:37 2013 +0400
+++ b/test/java/nio/channels/DatagramChannel/ConnectedSend.java	Thu Mar 14 16:59:06 2013 +0000
@@ -22,7 +22,7 @@
  */
 
 /* @test
- * @bug 4849277
+ * @bug 4849277 7183800
  * @summary Test DatagramChannel send while connected
  * @author Mike McCloskey
  */
@@ -46,14 +46,18 @@
 
         DatagramChannel sndChannel = DatagramChannel.open();
         sndChannel.socket().bind(null);
+        InetAddress address = InetAddress.getLocalHost();
+        if (address.isLoopbackAddress()) {
+            address = InetAddress.getLoopbackAddress();
+        }
         InetSocketAddress sender = new InetSocketAddress(
-            InetAddress.getLocalHost(),
+            address,
             sndChannel.socket().getLocalPort());
 
         DatagramChannel rcvChannel = DatagramChannel.open();
         rcvChannel.socket().bind(null);
         InetSocketAddress receiver = new InetSocketAddress(
-            InetAddress.getLocalHost(),
+            address,
             rcvChannel.socket().getLocalPort());
 
         rcvChannel.connect(sender);
@@ -80,14 +84,18 @@
     private static void test2() throws Exception {
         DatagramChannel sndChannel = DatagramChannel.open();
         sndChannel.socket().bind(null);
+        InetAddress address = InetAddress.getLocalHost();
+        if (address.isLoopbackAddress()) {
+            address = InetAddress.getLoopbackAddress();
+        }
         InetSocketAddress sender = new InetSocketAddress(
-            InetAddress.getLocalHost(),
+            address,
             sndChannel.socket().getLocalPort());
 
         DatagramChannel rcvChannel = DatagramChannel.open();
         rcvChannel.socket().bind(null);
         InetSocketAddress receiver = new InetSocketAddress(
-            InetAddress.getLocalHost(),
+            address,
             rcvChannel.socket().getLocalPort());
 
         rcvChannel.connect(sender);
--- a/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/Launcher.java	Mon May 20 15:35:37 2013 +0400
+++ b/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/Launcher.java	Thu Mar 14 16:59:06 2013 +0000
@@ -133,8 +133,11 @@
         dc.close();
 
         dc = DatagramChannel.open();
-
-        InetSocketAddress isa = new InetSocketAddress(InetAddress.getLocalHost(), port);
+        InetAddress address = InetAddress.getLocalHost();
+        if (address.isLoopbackAddress()) {
+            address = InetAddress.getLoopbackAddress();
+        }
+        InetSocketAddress isa = new InetSocketAddress(address, port);
 
         dc.connect(isa);
         return dc;
--- a/test/javax/management/remote/mandatory/connection/RMIConnectionIdTest.java	Mon May 20 15:35:37 2013 +0400
+++ b/test/javax/management/remote/mandatory/connection/RMIConnectionIdTest.java	Thu Mar 14 16:59:06 2013 +0000
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 4901808
+ * @bug 4901808 7183800
  * @summary Check that RMI connection ids include client host name
  * @author Eamonn McManus
  * @run clean RMIConnectionIdTest
@@ -60,7 +60,7 @@
         }
         String clientAddr = rest.substring(0, spaceIndex);
         InetAddress clientInetAddr = InetAddress.getByName(clientAddr);
-        InetAddress localAddr = InetAddress.getLocalHost();
+        InetAddress localAddr = clientInetAddr.isLoopbackAddress() ? InetAddress.getLoopbackAddress() : InetAddress.getLocalHost();
         System.out.println("InetAddresses: local=" + localAddr + "; " +
                            "connectionId=" + clientInetAddr);
         if (!localAddr.equals(clientInetAddr)) {