summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--luni/src/test/java/libcore/java/net/OldSocketTest.java27
-rw-r--r--support/src/test/java/tests/net/StuckServer.java21
-rw-r--r--support/src/test/java/tests/support/Support_Configuration.java10
3 files changed, 24 insertions, 34 deletions
diff --git a/luni/src/test/java/libcore/java/net/OldSocketTest.java b/luni/src/test/java/libcore/java/net/OldSocketTest.java
index b0125ac..6575d8c 100644
--- a/luni/src/test/java/libcore/java/net/OldSocketTest.java
+++ b/luni/src/test/java/libcore/java/net/OldSocketTest.java
@@ -37,6 +37,7 @@ import java.net.UnknownHostException;
import java.nio.channels.IllegalBlockingModeException;
import java.nio.channels.SocketChannel;
import java.security.Permission;
+import tests.net.StuckServer;
import tests.support.Support_Configuration;
public class OldSocketTest extends OldSocketTestCase {
@@ -931,25 +932,15 @@ public class OldSocketTest extends OldSocketTestCase {
}
// start by validating the error checks
- int portNumber = 0;
- Socket theSocket = null;
- ServerSocket serverSocket = null;
- SocketAddress theAddress = null;
- SocketAddress nonConnectableAddress = null;
- SocketAddress nonReachableAddress = null;
- SocketAddress invalidType = null;
- // byte[] theBytes = {-1,-1,-1,-1};
- byte[] theBytes = { 0, 0, 0, 0 };
- theAddress = new InetSocketAddress(InetAddress.getLocalHost(),
- portNumber);
- nonConnectableAddress = new InetSocketAddress(InetAddress
- .getByAddress(theBytes), portNumber);
- nonReachableAddress = new InetSocketAddress(InetAddress
- .getByName(Support_Configuration.ResolvedNotExistingHost),
- portNumber);
- invalidType = new mySocketAddress();
+ byte[] theBytes = { 0, 0, 0, 0 };
+ SocketAddress theAddress = new InetSocketAddress(InetAddress.getLocalHost(), 0);
+ SocketAddress nonConnectableAddress = new InetSocketAddress(InetAddress.getByAddress(theBytes), 0);
+ SocketAddress nonReachableAddress = new InetSocketAddress(StuckServer.UNREACHABLE_ADDRESS, 0);
+ SocketAddress invalidType = new mySocketAddress();
+ Socket theSocket = null;
+ ServerSocket serverSocket = null;
try {
theSocket = new Socket();
theSocket.connect(null);
@@ -1164,7 +1155,7 @@ public class OldSocketTest extends OldSocketTestCase {
byte[] theBytes = { 0, 0, 0, 0 };
SocketAddress theAddress = new InetSocketAddress(InetAddress.getLocalHost(), 0);
SocketAddress nonConnectableAddress = new InetSocketAddress(InetAddress.getByAddress(theBytes), 0);
- SocketAddress nonReachableAddress = new InetSocketAddress(InetAddress.getByName(Support_Configuration.ResolvedNotExistingHost), 0);
+ SocketAddress nonReachableAddress = new InetSocketAddress(StuckServer.UNREACHABLE_ADDRESS, 0);
SocketAddress invalidType = new mySocketAddress();
Socket theSocket = null;
diff --git a/support/src/test/java/tests/net/StuckServer.java b/support/src/test/java/tests/net/StuckServer.java
index f7a3118..d6b038b 100644
--- a/support/src/test/java/tests/net/StuckServer.java
+++ b/support/src/test/java/tests/net/StuckServer.java
@@ -21,6 +21,7 @@ import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
+import java.net.UnknownHostException;
import java.util.ArrayList;
/**
@@ -29,6 +30,19 @@ import java.util.ArrayList;
public final class StuckServer {
private static final boolean DEBUG = false;
+ // RFC 5737 implies this network -- "test net 1" -- will be unreachable.
+ // (There are two other networks to try if we have trouble with this one.)
+ // We've had trouble with 10.* in the past (because test labs running CTS often use
+ // net 10!) but hopefully this network will be better.
+ public static final InetAddress UNREACHABLE_ADDRESS;
+ static {
+ try {
+ UNREACHABLE_ADDRESS = InetAddress.getByAddress(new byte[] { (byte) 192, 0, 2, 0 });
+ } catch (UnknownHostException ex) {
+ throw new AssertionError(ex);
+ }
+ }
+
private ServerSocket serverSocket;
private InetSocketAddress address;
private ArrayList<Socket> clients = new ArrayList<Socket>();
@@ -57,12 +71,7 @@ public final class StuckServer {
}
} else {
// In general, though, you don't want to rely on listen(2) backlog. http://b/6971145.
- // RFC 5737 implies this network will be unreachable. (There are two other networks
- // to try if we have trouble with this one.)
- // We've had trouble with 10.* in the past (because test labs running CTS often use
- // net 10!) but hopefully this network will be better.
- InetAddress testNet1 = InetAddress.getByAddress(new byte[] { (byte) 192, 0, 2, 0 });
- this.address = new InetSocketAddress(testNet1, 80);
+ this.address = new InetSocketAddress(UNREACHABLE_ADDRESS, 80);
}
}
diff --git a/support/src/test/java/tests/support/Support_Configuration.java b/support/src/test/java/tests/support/Support_Configuration.java
index 9cb617d..0658d54 100644
--- a/support/src/test/java/tests/support/Support_Configuration.java
+++ b/support/src/test/java/tests/support/Support_Configuration.java
@@ -75,11 +75,6 @@ public class Support_Configuration {
public static String IPv6GlobalAddressJcl4 = "2001:4860:8004::67"; // ipv6.google.com
- // ip address that resolves to a host that is not present on the local
- // network
- // this allows us to check the timeouts for connect
- public static String ResolvedNotExistingHost = "9.26.194.72";
-
// BEGIN android-changed
/**
* An address that resolves to more than one IP address so that the
@@ -279,11 +274,6 @@ public class Support_Configuration {
URLConnectionDate = Long.parseLong(value);
}
- value = props.get("ResolvedNotExistingHost");
- if (value != null) {
- ResolvedNotExistingHost = value;
- }
-
value = props.get("InetAlias1");
if (value != null) {
InetAlias1 = value;