test/jdk/java/net/httpclient/SmallTimeout.java
branchhttp-client-branch
changeset 56265 ec34ae013fbe
parent 56233 1753108d07b9
child 56274 56e6b3f2e09f
equal deleted inserted replaced
56264:c012b93297b0 56265:ec34ae013fbe
    20  * or visit www.oracle.com if you need additional information or have any
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    21  * questions.
    22  */
    22  */
    23 
    23 
    24 import java.io.IOException;
    24 import java.io.IOException;
       
    25 import java.net.InetAddress;
    25 import java.net.InetSocketAddress;
    26 import java.net.InetSocketAddress;
    26 import java.net.ServerSocket;
    27 import java.net.ServerSocket;
    27 import java.net.URI;
    28 import java.net.URI;
    28 import java.net.http.HttpClient;
    29 import java.net.http.HttpClient;
    29 import java.net.http.HttpRequest;
    30 import java.net.http.HttpRequest;
    78     public static void main(String[] args) throws Exception {
    79     public static void main(String[] args) throws Exception {
    79         HttpClient client = HttpClient.newHttpClient();
    80         HttpClient client = HttpClient.newHttpClient();
    80 
    81 
    81         try (ServerSocket ss = new ServerSocket()) {
    82         try (ServerSocket ss = new ServerSocket()) {
    82             ss.setReuseAddress(false);
    83             ss.setReuseAddress(false);
    83             ss.bind(new InetSocketAddress(0));
    84             ss.bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0));
    84             int port = ss.getLocalPort();
    85             int port = ss.getLocalPort();
    85             URI uri = new URI("http://127.0.0.1:" + port + "/");
    86             URI uri = new URI("http://localhost:" + port + "/");
    86 
    87 
    87             HttpRequest[] requests = new HttpRequest[TIMEOUTS.length];
    88             HttpRequest[] requests = new HttpRequest[TIMEOUTS.length];
    88 
    89 
    89             out.println("--- TESTING Async");
    90             out.println("--- TESTING Async");
    90             for (int i = 0; i < TIMEOUTS.length; i++) {
    91             for (int i = 0; i < TIMEOUTS.length; i++) {