test/jdk/java/net/httpclient/websocket/WSHandshakeExceptionTest.java
branchhttp-client-branch
changeset 56265 ec34ae013fbe
parent 56256 0fe17c3f9b4f
child 56324 3edf200fff01
equal deleted inserted replaced
56264:c012b93297b0 56265:ec34ae013fbe
    31  * @run testng/othervm -Djdk.internal.httpclient.debug=true WSHandshakeExceptionTest
    31  * @run testng/othervm -Djdk.internal.httpclient.debug=true WSHandshakeExceptionTest
    32  */
    32  */
    33 import com.sun.net.httpserver.HttpServer;
    33 import com.sun.net.httpserver.HttpServer;
    34 import com.sun.net.httpserver.HttpsConfigurator;
    34 import com.sun.net.httpserver.HttpsConfigurator;
    35 import com.sun.net.httpserver.HttpsServer;
    35 import com.sun.net.httpserver.HttpsServer;
       
    36 
       
    37 import java.net.InetAddress;
    36 import java.net.http.HttpClient;
    38 import java.net.http.HttpClient;
    37 import java.net.http.WebSocket;
    39 import java.net.http.WebSocket;
    38 import java.net.http.WebSocketHandshakeException;
    40 import java.net.http.WebSocketHandshakeException;
    39 import jdk.testlibrary.SimpleSSLContext;
    41 import jdk.testlibrary.SimpleSSLContext;
    40 import org.testng.annotations.AfterTest;
    42 import org.testng.annotations.AfterTest;
   111         sslContext = new SimpleSSLContext().get();
   113         sslContext = new SimpleSSLContext().get();
   112         if (sslContext == null)
   114         if (sslContext == null)
   113             throw new AssertionError("Unexpected null sslContext");
   115             throw new AssertionError("Unexpected null sslContext");
   114 
   116 
   115         // HTTP/1.1
   117         // HTTP/1.1
   116         InetSocketAddress sa = new InetSocketAddress("localhost", 0);
   118         InetSocketAddress sa = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0);
   117         httpTestServer = HttpServer.create(sa, 0);
   119         httpTestServer = HttpServer.create(sa, 0);
   118         httpURI = "ws://127.0.0.1:" + httpTestServer.getAddress().getPort() + "/";
   120         httpURI = "ws://localhost:" + httpTestServer.getAddress().getPort() + "/";
   119 
   121 
   120         httpsTestServer = HttpsServer.create(sa, 0);
   122         httpsTestServer = HttpsServer.create(sa, 0);
   121         httpsTestServer.setHttpsConfigurator(new HttpsConfigurator(sslContext));
   123         httpsTestServer.setHttpsConfigurator(new HttpsConfigurator(sslContext));
   122         httpsURI = "wss://127.0.0.1:" + httpsTestServer.getAddress().getPort() + "/";
   124         httpsURI = "wss://localhost:" + httpsTestServer.getAddress().getPort() + "/";
   123 
   125 
   124         httpTestServer.start();
   126         httpTestServer.start();
   125         httpsTestServer.start();
   127         httpsTestServer.start();
   126     }
   128     }
   127 
   129