--- old/test/java/nio/channels/SocketChannel/Connect.java 2012-11-06 16:48:37.000000000 +0100 +++ new/test/java/nio/channels/SocketChannel/Connect.java 2012-11-06 16:48:37.000000000 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,9 +27,9 @@ * @library .. */ +import java.net.*; import java.nio.*; import java.nio.channels.*; -import java.net.*; import java.util.*; public class Connect { @@ -37,21 +37,26 @@ private static final long INCREMENTAL_DELAY = 30L * 1000L; public static void main(String args[]) throws Exception { - test1(TestUtil.HOST); + try (TestClass.EchoServer echoServer + = TestClass.EchoServer.startNewServer(1000)) { + test1(echoServer); + } try { - test1(TestUtil.REFUSING_HOST); + TestClass.RefusingServer refusingServer + = TestClass.RefusingServer.startNewServer(); + test1(refusingServer); throw new Exception("Refused connection throws no exception"); } catch (ConnectException ce) { // Correct result } } - static void test1(String hostname) throws Exception { + static void test1(TestClass.AbstractServer server) throws Exception { Selector selector; SocketChannel sc; SelectionKey sk; InetSocketAddress isa = new InetSocketAddress( - InetAddress.getByName (hostname), 80); + server.getAddress(), server.getPort()); sc = SocketChannel.open(); sc.configureBlocking(false);