Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions test/jdk/java/net/httpclient/ALPNProxyFailureTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2025, 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
Expand Down Expand Up @@ -44,14 +44,9 @@

public class ALPNProxyFailureTest extends ALPNFailureTest {

static final SSLContext context;
private static final SSLContext context = SimpleSSLContext.findSSLContext();
static {
try {
context = new SimpleSSLContext().get();
SSLContext.setDefault(context);
} catch (Exception x) {
throw new ExceptionInInitializerError(x);
}
SSLContext.setDefault(context);
}

public static void main(String[] args) throws Exception{
Expand Down
5 changes: 1 addition & 4 deletions test/jdk/java/net/httpclient/AbstractNoBody.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

public abstract class AbstractNoBody implements HttpServerAdapters {

SSLContext sslContext;
private static final SSLContext sslContext = SimpleSSLContext.findSSLContext();
HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ]
HttpTestServer httpsTestServer; // HTTPS/1.1
HttpTestServer http2TestServer; // HTTP/2 ( h2c )
Expand Down Expand Up @@ -154,9 +154,6 @@ public void close() {
public void setup() throws Exception {
printStamp(START, "setup");
HttpServerAdapters.enableServerLogging();
sslContext = new SimpleSSLContext().get();
if (sslContext == null)
throw new AssertionError("Unexpected null sslContext");

// HTTP/1.1
HttpTestHandler h1_fixedLengthNoBodyHandler = new FixedLengthNoBodyHandler();
Expand Down
6 changes: 1 addition & 5 deletions test/jdk/java/net/httpclient/AbstractThrowingPublishers.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@

public abstract class AbstractThrowingPublishers implements HttpServerAdapters {

static SSLContext sslContext;
private static final SSLContext sslContext = SimpleSSLContext.findSSLContext();
static HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ]
static HttpTestServer httpsTestServer; // HTTPS/1.1
static HttpTestServer http2TestServer; // HTTP/2 ( h2c )
Expand Down Expand Up @@ -693,10 +693,6 @@ public static void setup() throws Exception {
System.out.println(now() + "setup");
System.err.println(now() + "setup");

sslContext = new SimpleSSLContext().get();
if (sslContext == null)
throw new AssertionError("Unexpected null sslContext");

// HTTP/1.1
HttpTestHandler h1_fixedLengthHandler = new HTTP_FixedLengthHandler();
HttpTestHandler h1_chunkHandler = new HTTP_ChunkedHandler();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@

import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.extension.BeforeEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
Expand All @@ -103,7 +102,7 @@
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public abstract class AbstractThrowingPushPromises implements HttpServerAdapters {

static SSLContext sslContext;
private static final SSLContext sslContext = SimpleSSLContext.findSSLContext();
static HttpTestServer http2TestServer; // HTTP/2 ( h2c )
static HttpTestServer https2TestServer; // HTTP/2 ( h2 )
static String http2URI_fixed;
Expand Down Expand Up @@ -732,10 +731,6 @@ public CompletionStage<T> getBody() {

@BeforeAll
public static void setup() throws Exception {
sslContext = new SimpleSSLContext().get();
if (sslContext == null)
throw new AssertionError("Unexpected null sslContext");

// HTTP/2
HttpTestHandler h2_fixedLengthHandler = new HTTP_FixedLengthHandler();
HttpTestHandler h2_chunkedHandler = new HTTP_ChunkedHandler();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@

public abstract class AbstractThrowingSubscribers implements HttpServerAdapters {

static SSLContext sslContext;
private static final SSLContext sslContext = SimpleSSLContext.findSSLContext();
static HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ]
static HttpTestServer httpsTestServer; // HTTPS/1.1
static HttpTestServer http2TestServer; // HTTP/2 ( h2c )
Expand Down Expand Up @@ -759,10 +759,6 @@ public static void setup() throws Exception {
System.out.println(now() + "setup");
System.err.println(now() + "setup");

sslContext = new SimpleSSLContext().get();
if (sslContext == null)
throw new AssertionError("Unexpected null sslContext");

// HTTP/1.1
HttpTestHandler h1_fixedLengthHandler = new HTTP_FixedLengthHandler();
HttpTestHandler h1_chunkHandler = new HTTP_ChunkedHandler();
Expand Down
6 changes: 1 addition & 5 deletions test/jdk/java/net/httpclient/AggregateRequestBodyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@

public class AggregateRequestBodyTest implements HttpServerAdapters {

SSLContext sslContext;
private static final SSLContext sslContext = SimpleSSLContext.findSSLContext();
HttpTestServer http1TestServer; // HTTP/1.1 ( http )
HttpTestServer https1TestServer; // HTTPS/1.1 ( https )
HttpTestServer http2TestServer; // HTTP/2 ( h2c )
Expand Down Expand Up @@ -831,10 +831,6 @@ public void test(String uri, boolean sameClient) throws Exception {

@BeforeTest
public void setup() throws Exception {
sslContext = new SimpleSSLContext().get();
if (sslContext == null)
throw new AssertionError("Unexpected null sslContext");

HttpTestHandler handler = new HttpTestEchoHandler();
http1TestServer = HttpTestServer.create(HTTP_1_1);
http1TestServer.addHandler(handler, "/http1/echo/");
Expand Down
6 changes: 1 addition & 5 deletions test/jdk/java/net/httpclient/AsFileDownloadTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
*/
public class AsFileDownloadTest {

SSLContext sslContext;
private static final SSLContext sslContext = SimpleSSLContext.findSSLContext();
HttpServer httpTestServer; // HTTP/1.1 [ 4 servers ]
HttpsServer httpsTestServer; // HTTPS/1.1
Http2TestServer http2TestServer; // HTTP/2 ( h2c )
Expand Down Expand Up @@ -317,10 +317,6 @@ public void setup() throws Exception {
//ch.setLevel(Level.ALL);
//logger.addHandler(ch);

sslContext = new SimpleSSLContext().get();
if (sslContext == null)
throw new AssertionError("Unexpected null sslContext");

InetSocketAddress sa = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0);
httpTestServer = HttpServer.create(sa, 0);
httpTestServer.createContext("/http1/afdt", new Http1FileDispoHandler());
Expand Down
5 changes: 1 addition & 4 deletions test/jdk/java/net/httpclient/AsyncExecutorShutdown.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public class AsyncExecutorShutdown implements HttpServerAdapters {
}
static final Random RANDOM = RandomFactory.getRandom();

SSLContext sslContext;
private static final SSLContext sslContext = SimpleSSLContext.findSSLContext();
HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ]
HttpTestServer httpsTestServer; // HTTPS/1.1
HttpTestServer http2TestServer; // HTTP/2 ( h2c )
Expand Down Expand Up @@ -314,9 +314,6 @@ void testSequential(String uriString) throws Exception {
@BeforeTest
public void setup() throws Exception {
out.println("\n**** Setup ****\n");
sslContext = new SimpleSSLContext().get();
if (sslContext == null)
throw new AssertionError("Unexpected null sslContext");

httpTestServer = HttpTestServer.create(HTTP_1_1);
httpTestServer.addHandler(new ServerRequestHandler(), "/http1/exec/");
Expand Down
5 changes: 1 addition & 4 deletions test/jdk/java/net/httpclient/AsyncShutdownNow.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public class AsyncShutdownNow implements HttpServerAdapters {
static final Random RANDOM = RandomFactory.getRandom();

ExecutorService readerService;
SSLContext sslContext;
private static final SSLContext sslContext = SimpleSSLContext.findSSLContext();
HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ]
HttpTestServer httpsTestServer; // HTTPS/1.1
HttpTestServer http2TestServer; // HTTP/2 ( h2c )
Expand Down Expand Up @@ -343,9 +343,6 @@ void testSequential(String uriString) throws Exception {
@BeforeTest
public void setup() throws Exception {
out.println("\n**** Setup ****\n");
sslContext = new SimpleSSLContext().get();
if (sslContext == null)
throw new AssertionError("Unexpected null sslContext");
readerService = Executors.newCachedThreadPool();

httpTestServer = HttpTestServer.create(HTTP_1_1);
Expand Down
9 changes: 2 additions & 7 deletions test/jdk/java/net/httpclient/AuthFilterCacheTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,10 @@ public class AuthFilterCacheTest implements HttpServerAdapters {
static final int REQUEST_COUNT = 5;
static final int URI_COUNT = 6;
static final CyclicBarrier barrier = new CyclicBarrier(REQUEST_COUNT * URI_COUNT);
static final SSLContext context;
private static final SSLContext context = jdk.test.lib.net.SimpleSSLContext.findSSLContext();

static {
try {
context = new jdk.test.lib.net.SimpleSSLContext().get();
SSLContext.setDefault(context);
} catch (Exception x) {
throw new ExceptionInInitializerError(x);
}
SSLContext.setDefault(context);
}

HttpTestServer http1Server;
Expand Down
2 changes: 1 addition & 1 deletion test/jdk/java/net/httpclient/BasicAuthTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static void test(Version version, boolean secure) throws Exception {

ExecutorService e = Executors.newCachedThreadPool();
Handler h = new Handler();
SSLContext sslContext = secure ? new SimpleSSLContext().get() : null;
SSLContext sslContext = secure ? SimpleSSLContext.findSSLContext() : null;
HttpTestServer server = HttpTestServer.create(version, sslContext, e);
HttpTestContext serverContext = server.addHandler(h,"/test/");
ServerAuth sa = new ServerAuth("foo realm");
Expand Down
6 changes: 1 addition & 5 deletions test/jdk/java/net/httpclient/BasicRedirectTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@

public class BasicRedirectTest implements HttpServerAdapters {

SSLContext sslContext;
private static final SSLContext sslContext = SimpleSSLContext.findSSLContext();
HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ]
HttpTestServer httpsTestServer; // HTTPS/1.1
HttpTestServer http2TestServer; // HTTP/2 ( h2c )
Expand Down Expand Up @@ -207,10 +207,6 @@ void testNegatives(String uriString,Redirect redirectPolicy) throws Exception {

@BeforeTest
public void setup() throws Exception {
sslContext = new SimpleSSLContext().get();
if (sslContext == null)
throw new AssertionError("Unexpected null sslContext");

httpTestServer = HttpTestServer.create(HTTP_1_1);
httpTestServer.addHandler(new BasicHttpRedirectHandler(), "/http1/same/");
httpURI = "http://" + httpTestServer.serverAuthority() + "/http1/same/redirect";
Expand Down
6 changes: 1 addition & 5 deletions test/jdk/java/net/httpclient/CancelRequestTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public class CancelRequestTest implements HttpServerAdapters {

private static final Random random = RandomFactory.getRandom();

SSLContext sslContext;
private static final SSLContext sslContext = SimpleSSLContext.findSSLContext();
HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ]
HttpTestServer httpsTestServer; // HTTPS/1.1
HttpTestServer http2TestServer; // HTTP/2 ( h2c )
Expand Down Expand Up @@ -592,10 +592,6 @@ public void testPostInterrupt(String uri, boolean sameClient)

@BeforeTest
public void setup() throws Exception {
sslContext = new SimpleSSLContext().get();
if (sslContext == null)
throw new AssertionError("Unexpected null sslContext");

// HTTP/1.1
HttpTestHandler h1_chunkHandler = new HTTPSlowHandler();
httpTestServer = HttpTestServer.create(HTTP_1_1);
Expand Down
6 changes: 1 addition & 5 deletions test/jdk/java/net/httpclient/CancelStreamedBodyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@

public class CancelStreamedBodyTest implements HttpServerAdapters {

SSLContext sslContext;
private static final SSLContext sslContext = SimpleSSLContext.findSSLContext();
HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ]
HttpTestServer httpsTestServer; // HTTPS/1.1
HttpTestServer http2TestServer; // HTTP/2 ( h2c )
Expand Down Expand Up @@ -339,10 +339,6 @@ public void testInputStream(String uri, boolean sameClient)

@BeforeTest
public void setup() throws Exception {
sslContext = new SimpleSSLContext().get();
if (sslContext == null)
throw new AssertionError("Unexpected null sslContext");

// HTTP/1.1
HttpTestHandler h1_chunkHandler = new HTTPSlowHandler();
httpTestServer = HttpTestServer.create(HTTP_1_1);
Expand Down
3 changes: 1 addition & 2 deletions test/jdk/java/net/httpclient/CancelledResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,10 @@ static String response(String body, boolean serverKeepalive) {

static final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE;
final ServerSocketFactory factory;
final SSLContext context;
private static final SSLContext context = SimpleSSLContext.findSSLContext();
final boolean useSSL;
CancelledResponse(boolean useSSL) throws IOException {
this.useSSL = useSSL;
context = new SimpleSSLContext().get();
SSLContext.setDefault(context);
factory = useSSL ? SSLServerSocketFactory.getDefault()
: ServerSocketFactory.getDefault();
Expand Down
3 changes: 1 addition & 2 deletions test/jdk/java/net/httpclient/CancelledResponse2.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public class CancelledResponse2 {

HttpTestServer h2TestServer;
URI h2TestServerURI;
private SSLContext sslContext;
private static final SSLContext sslContext = SimpleSSLContext.findSSLContext();
private static final Random random = RandomFactory.getRandom();
private static final int MAX_CLIENT_DELAY = 160;

Expand Down Expand Up @@ -113,7 +113,6 @@ public void test(Version version, URI uri) throws Exception {

@BeforeTest
public void setup() throws IOException {
sslContext = new SimpleSSLContext().get();
h2TestServer = HttpTestServer.create(HTTP_2, sslContext);
h2TestServer.addHandler(new CancelledResponseHandler(), "/h2");
h2TestServerURI = URI.create("https://" + h2TestServer.serverAuthority() + "/h2");
Expand Down
6 changes: 1 addition & 5 deletions test/jdk/java/net/httpclient/ConcurrentResponses.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@

public class ConcurrentResponses {

SSLContext sslContext;
private static final SSLContext sslContext = SimpleSSLContext.findSSLContext();
HttpServer httpTestServer; // HTTP/1.1 [ 4 servers ]
HttpsServer httpsTestServer; // HTTPS/1.1
Http2TestServer http2TestServer; // HTTP/2 ( h2c )
Expand Down Expand Up @@ -280,10 +280,6 @@ static String serverAuthority(HttpServer server) {

@BeforeTest
public void setup() throws Exception {
sslContext = new SimpleSSLContext().get();
if (sslContext == null)
throw new AssertionError("Unexpected null sslContext");

InetSocketAddress sa = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0);
httpTestServer = HttpServer.create(sa, 0);
httpTestServer.createContext("/http1/fixed", new Http1FixedHandler());
Expand Down
3 changes: 1 addition & 2 deletions test/jdk/java/net/httpclient/ContentLengthHeaderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,14 @@ public class ContentLengthHeaderTest implements HttpServerAdapters {
static HttpTestServer testContentLengthServerH1;
static HttpTestServer testContentLengthServerH2;
static PrintStream testLog = System.err;
static SSLContext sslContext;
private static final SSLContext sslContext = SimpleSSLContext.findSSLContext();

HttpClient hc;
URI testContentLengthURIH1;
URI testContentLengthURIH2;

@BeforeTest
public void setup() throws IOException, URISyntaxException {
sslContext = new SimpleSSLContext().get();
testContentLengthServerH1 = HttpTestServer.create(HTTP_1_1);
testContentLengthServerH2 = HttpTestServer.create(HTTP_2, sslContext);

Expand Down
6 changes: 1 addition & 5 deletions test/jdk/java/net/httpclient/CookieHeaderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@

public class CookieHeaderTest implements HttpServerAdapters {

SSLContext sslContext;
private static final SSLContext sslContext = SimpleSSLContext.findSSLContext();
HttpTestServer httpTestServer; // HTTP/1.1 [ 6 servers ]
HttpTestServer httpsTestServer; // HTTPS/1.1
HttpTestServer http2TestServer; // HTTP/2 ( h2c )
Expand Down Expand Up @@ -179,10 +179,6 @@ void test(String uriString, HttpClient.Version version) throws Exception {

@BeforeTest
public void setup() throws Exception {
sslContext = new SimpleSSLContext().get();
if (sslContext == null)
throw new AssertionError("Unexpected null sslContext");

httpTestServer = HttpTestServer.create(HTTP_1_1);
httpTestServer.addHandler(new CookieValidationHandler(), "/http1/cookie/");
httpURI = "http://" + httpTestServer.serverAuthority() + "/http1/cookie/retry";
Expand Down
8 changes: 2 additions & 6 deletions test/jdk/java/net/httpclient/CustomRequestPublisher.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2025, 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
Expand Down Expand Up @@ -65,7 +65,7 @@

public class CustomRequestPublisher implements HttpServerAdapters {

SSLContext sslContext;
private static final SSLContext sslContext = SimpleSSLContext.findSSLContext();
HttpTestServer httpTestServer; // HTTP/1.1 [ 4 servers ]
HttpTestServer httpsTestServer; // HTTPS/1.1
HttpTestServer http2TestServer; // HTTP/2 ( h2c )
Expand Down Expand Up @@ -304,10 +304,6 @@ public void cancel() {

@BeforeTest
public void setup() throws Exception {
sslContext = new SimpleSSLContext().get();
if (sslContext == null)
throw new AssertionError("Unexpected null sslContext");

InetSocketAddress sa = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0);
httpTestServer = HttpTestServer.create(HTTP_1_1);
httpTestServer.addHandler(new HttpTestEchoHandler(), "/http1/echo");
Expand Down
Loading