提交 5b2c05ff 编写于 作者: A alanb

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
上级 0c5454bf
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
*/ */
/* @test /* @test
* @bug 4313882 7183800
* @summary Test DatagramChannel's send and receive methods * @summary Test DatagramChannel's send and receive methods
* @author Mike McCloskey * @author Mike McCloskey
*/ */
...@@ -88,6 +89,9 @@ public class Connect { ...@@ -88,6 +89,9 @@ public class Connect {
bb.put("hello".getBytes()); bb.put("hello".getBytes());
bb.flip(); bb.flip();
InetAddress address = InetAddress.getLocalHost(); InetAddress address = InetAddress.getLocalHost();
if (address.isLoopbackAddress()) {
address = InetAddress.getLoopbackAddress();
}
InetSocketAddress isa = new InetSocketAddress(address, port); InetSocketAddress isa = new InetSocketAddress(address, port);
dc.connect(isa); dc.connect(isa);
dc.write(bb); dc.write(bb);
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
*/ */
/* @test /* @test
* @bug 4849277 * @bug 4849277 7183800
* @summary Test DatagramChannel send while connected * @summary Test DatagramChannel send while connected
* @author Mike McCloskey * @author Mike McCloskey
*/ */
...@@ -46,14 +46,18 @@ public class ConnectedSend { ...@@ -46,14 +46,18 @@ public class ConnectedSend {
DatagramChannel sndChannel = DatagramChannel.open(); DatagramChannel sndChannel = DatagramChannel.open();
sndChannel.socket().bind(null); sndChannel.socket().bind(null);
InetAddress address = InetAddress.getLocalHost();
if (address.isLoopbackAddress()) {
address = InetAddress.getLoopbackAddress();
}
InetSocketAddress sender = new InetSocketAddress( InetSocketAddress sender = new InetSocketAddress(
InetAddress.getLocalHost(), address,
sndChannel.socket().getLocalPort()); sndChannel.socket().getLocalPort());
DatagramChannel rcvChannel = DatagramChannel.open(); DatagramChannel rcvChannel = DatagramChannel.open();
rcvChannel.socket().bind(null); rcvChannel.socket().bind(null);
InetSocketAddress receiver = new InetSocketAddress( InetSocketAddress receiver = new InetSocketAddress(
InetAddress.getLocalHost(), address,
rcvChannel.socket().getLocalPort()); rcvChannel.socket().getLocalPort());
rcvChannel.connect(sender); rcvChannel.connect(sender);
...@@ -80,14 +84,18 @@ public class ConnectedSend { ...@@ -80,14 +84,18 @@ public class ConnectedSend {
private static void test2() throws Exception { private static void test2() throws Exception {
DatagramChannel sndChannel = DatagramChannel.open(); DatagramChannel sndChannel = DatagramChannel.open();
sndChannel.socket().bind(null); sndChannel.socket().bind(null);
InetAddress address = InetAddress.getLocalHost();
if (address.isLoopbackAddress()) {
address = InetAddress.getLoopbackAddress();
}
InetSocketAddress sender = new InetSocketAddress( InetSocketAddress sender = new InetSocketAddress(
InetAddress.getLocalHost(), address,
sndChannel.socket().getLocalPort()); sndChannel.socket().getLocalPort());
DatagramChannel rcvChannel = DatagramChannel.open(); DatagramChannel rcvChannel = DatagramChannel.open();
rcvChannel.socket().bind(null); rcvChannel.socket().bind(null);
InetSocketAddress receiver = new InetSocketAddress( InetSocketAddress receiver = new InetSocketAddress(
InetAddress.getLocalHost(), address,
rcvChannel.socket().getLocalPort()); rcvChannel.socket().getLocalPort());
rcvChannel.connect(sender); rcvChannel.connect(sender);
......
...@@ -133,8 +133,11 @@ public class Launcher { ...@@ -133,8 +133,11 @@ public class Launcher {
dc.close(); dc.close();
dc = DatagramChannel.open(); dc = DatagramChannel.open();
InetAddress address = InetAddress.getLocalHost();
InetSocketAddress isa = new InetSocketAddress(InetAddress.getLocalHost(), port); if (address.isLoopbackAddress()) {
address = InetAddress.getLoopbackAddress();
}
InetSocketAddress isa = new InetSocketAddress(address, port);
dc.connect(isa); dc.connect(isa);
return dc; return dc;
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
/* /*
* @test * @test
* @bug 4901808 * @bug 4901808 7183800
* @summary Check that RMI connection ids include client host name * @summary Check that RMI connection ids include client host name
* @author Eamonn McManus * @author Eamonn McManus
* @run clean RMIConnectionIdTest * @run clean RMIConnectionIdTest
...@@ -60,7 +60,7 @@ public class RMIConnectionIdTest { ...@@ -60,7 +60,7 @@ public class RMIConnectionIdTest {
} }
String clientAddr = rest.substring(0, spaceIndex); String clientAddr = rest.substring(0, spaceIndex);
InetAddress clientInetAddr = InetAddress.getByName(clientAddr); InetAddress clientInetAddr = InetAddress.getByName(clientAddr);
InetAddress localAddr = InetAddress.getLocalHost(); InetAddress localAddr = clientInetAddr.isLoopbackAddress() ? InetAddress.getLoopbackAddress() : InetAddress.getLocalHost();
System.out.println("InetAddresses: local=" + localAddr + "; " + System.out.println("InetAddresses: local=" + localAddr + "; " +
"connectionId=" + clientInetAddr); "connectionId=" + clientInetAddr);
if (!localAddr.equals(clientInetAddr)) { if (!localAddr.equals(clientInetAddr)) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册