# HG changeset patch # User chegar # Date 1520676703 0 # Node ID 56e6b3f2e09fb5862fb6fe151d566d8222b996af # Parent 329e410c9a01efbcbf0205acb83757066a216583 http-client-branch: test for default impl of newWebSocketBuilder diff -r 329e410c9a01 -r 56e6b3f2e09f test/jdk/java/net/httpclient/HttpClientBuilderTest.java --- a/test/jdk/java/net/httpclient/HttpClientBuilderTest.java Fri Mar 09 18:01:03 2018 +0000 +++ b/test/jdk/java/net/httpclient/HttpClientBuilderTest.java Sat Mar 10 10:11:43 2018 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2018, 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 @@ -21,6 +21,7 @@ * questions. */ +import java.io.IOException; import java.lang.reflect.Method; import java.net.Authenticator; import java.net.CookieHandler; @@ -31,12 +32,16 @@ import java.net.http.HttpHeaders; import java.net.http.HttpRequest; import java.net.http.HttpRequest.BodyPublishers; +import java.net.http.HttpResponse; +import java.net.http.HttpResponse.BodyHandler; import java.net.http.HttpResponse.BodyHandlers; +import java.net.http.HttpResponse.PushPromiseHandler; import java.time.Duration; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.TreeMap; +import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLParameters; @@ -236,6 +241,8 @@ builder.build(); } + // --- + static final URI uri = URI.create("http://foo.com/"); @Test @@ -282,6 +289,42 @@ } } + // --- + + static final Class UOE = + UnsupportedOperationException.class; + + @Test + static void testUnsupportedWebSocket() throws Exception { + // @implSpec The default implementation of this method throws + // {@code UnsupportedOperationException}. + assertThrows(UOE, () -> (new MockHttpClient()).newWebSocketBuilder()); + } + + static class MockHttpClient extends HttpClient { + @Override public Optional cookieHandler() { return null; } + @Override public Redirect followRedirects() { return null; } + @Override public Optional proxy() { return null; } + @Override public SSLContext sslContext() { return null; } + @Override public SSLParameters sslParameters() { return null; } + @Override public Optional authenticator() { return null; } + @Override public Version version() { return null; } + @Override public Optional executor() { return null; } + @Override public HttpResponse + send(HttpRequest request, BodyHandler responseBodyHandler) + throws IOException, InterruptedException { + return null; + } + @Override public CompletableFuture> + sendAsync(HttpRequest request, BodyHandler responseBodyHandler) { + return null; + } + @Override + public CompletableFuture> + sendAsync(HttpRequest x, BodyHandler y, PushPromiseHandler z) { + return null; + } + } /* ---- standalone entry point ---- */ diff -r 329e410c9a01 -r 56e6b3f2e09f test/jdk/java/net/httpclient/SmallTimeout.java --- a/test/jdk/java/net/httpclient/SmallTimeout.java Fri Mar 09 18:01:03 2018 +0000 +++ b/test/jdk/java/net/httpclient/SmallTimeout.java Sat Mar 10 10:11:43 2018 +0000 @@ -42,7 +42,7 @@ * @test * @bug 8178147 * @summary Ensures that small timeouts do not cause hangs due to race conditions - * @run main/othervm -Djdk.internal.net.http.common.DEBUG=true SmallTimeout + * @run main/othervm -Djdk.internal.httpclient.debug=true SmallTimeout */ // To enable logging use. Not enabled by default as it changes the dynamics