8004925: java/net/Socks/SocksV4Test.java failing on all platforms
Reviewed-by: alanb, dsamersoff
This commit is contained in:
parent
e57799bc0e
commit
2f8cd2937d
@ -26,20 +26,26 @@
|
|||||||
* @bug 4727547
|
* @bug 4727547
|
||||||
* @summary SocksSocketImpl throws NullPointerException
|
* @summary SocksSocketImpl throws NullPointerException
|
||||||
* @build SocksServer
|
* @build SocksServer
|
||||||
* @run main SocksV4Test
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.net.*;
|
import java.net.*;
|
||||||
|
|
||||||
public class SocksV4Test {
|
public class SocksV4Test {
|
||||||
|
|
||||||
|
// An unresolvable host
|
||||||
|
static final String HOSTNAME = "doesnot.exist.invalid";
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
// sanity before running the test
|
||||||
|
assertUnresolvableHost(HOSTNAME);
|
||||||
|
|
||||||
// Create a SOCKS V4 proxy
|
// Create a SOCKS V4 proxy
|
||||||
SocksServer srvr = new SocksServer(0, true);
|
SocksServer srvr = new SocksServer(0, true);
|
||||||
srvr.start();
|
srvr.start();
|
||||||
Proxy sp = new Proxy(Proxy.Type.SOCKS,
|
Proxy sp = new Proxy(Proxy.Type.SOCKS,
|
||||||
new InetSocketAddress("localhost", srvr.getPort()));
|
new InetSocketAddress("localhost", srvr.getPort()));
|
||||||
// Let's create an unresolved address
|
// Let's create an unresolved address
|
||||||
InetSocketAddress ad = new InetSocketAddress("doesnt.exist.name", 1234);
|
InetSocketAddress ad = new InetSocketAddress(HOSTNAME, 1234);
|
||||||
try (Socket s = new Socket(sp)) {
|
try (Socket s = new Socket(sp)) {
|
||||||
s.connect(ad, 10000);
|
s.connect(ad, 10000);
|
||||||
} catch (UnknownHostException ex) {
|
} catch (UnknownHostException ex) {
|
||||||
@ -51,4 +57,15 @@ public class SocksV4Test {
|
|||||||
srvr.terminate();
|
srvr.terminate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void assertUnresolvableHost(String host) {
|
||||||
|
InetAddress addr = null;
|
||||||
|
try {
|
||||||
|
addr = InetAddress.getByName(host);
|
||||||
|
} catch (UnknownHostException x) {
|
||||||
|
// OK, expected
|
||||||
|
}
|
||||||
|
if (addr != null)
|
||||||
|
throw new RuntimeException("Test cannot run. resolvable address:" + addr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user