diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/HttpIntegrationTests.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/HttpIntegrationTests.java
new file mode 100644
index 000000000..639b0c063
--- /dev/null
+++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/HttpIntegrationTests.java
@@ -0,0 +1,115 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ *
+ */
+package org.apache.hc.client5.testing.sync;
+
+import org.apache.hc.core5.http.URIScheme;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Nested;
+
+public class HttpIntegrationTests {
+
+ @Nested
+ @DisplayName("Request execution (HTTP/1.1)")
+ public class RequestExecution extends TestClientRequestExecution {
+
+ public RequestExecution() throws Exception {
+ super(URIScheme.HTTP);
+ }
+
+ }
+
+ @Nested
+ @DisplayName("Request execution (HTTP/1.1, TLS)")
+ public class RequestExecutionTls extends TestClientRequestExecution {
+
+ public RequestExecutionTls() throws Exception {
+ super(URIScheme.HTTPS);
+ }
+
+ }
+
+ @Nested
+ @DisplayName("Authentication (HTTP/1.1)")
+ public class Authentication extends TestClientAuthentication {
+
+ public Authentication() throws Exception {
+ super(URIScheme.HTTP);
+ }
+
+ }
+
+ @Nested
+ @DisplayName("Authentication (HTTP/1.1, TLS)")
+ public class AuthenticationTls extends TestClientAuthentication {
+
+ public AuthenticationTls() throws Exception {
+ super(URIScheme.HTTPS);
+ }
+
+ }
+
+ @Nested
+ @DisplayName("Content coding (HTTP/1.1)")
+ public class ContentCoding extends TestContentCodings {
+
+ public ContentCoding() throws Exception {
+ super(URIScheme.HTTP);
+ }
+
+ }
+
+ @Nested
+ @DisplayName("Content coding (HTTP/1.1, TLS)")
+ public class ContentCodingTls extends TestContentCodings {
+
+ public ContentCodingTls() throws Exception {
+ super(URIScheme.HTTPS);
+ }
+
+ }
+
+ @Nested
+ @DisplayName("Redirects (HTTP/1.1)")
+ public class Redirects extends TestRedirects {
+
+ public Redirects() throws Exception {
+ super(URIScheme.HTTP);
+ }
+
+ }
+
+ @Nested
+ @DisplayName("Redirects (HTTP/1.1, TLS)")
+ public class RedirectsTls extends TestRedirects {
+
+ public RedirectsTls() throws Exception {
+ super(URIScheme.HTTPS);
+ }
+
+ }
+
+}
\ No newline at end of file
diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/HttpMinimalIntegrationTests.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/HttpMinimalIntegrationTests.java
new file mode 100644
index 000000000..6ba2fdac6
--- /dev/null
+++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/HttpMinimalIntegrationTests.java
@@ -0,0 +1,55 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ *
+ */
+package org.apache.hc.client5.testing.sync;
+
+import org.apache.hc.core5.http.URIScheme;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Nested;
+
+public class HttpMinimalIntegrationTests {
+
+ @Nested
+ @DisplayName("Request execution (HTTP/1.1)")
+ public class RequestExecution extends TestMinimalClientRequestExecution {
+
+ public RequestExecution() throws Exception {
+ super(URIScheme.HTTP);
+ }
+
+ }
+
+ @Nested
+ @DisplayName("Request execution (HTTP/1.1, TLS)")
+ public class RequestExecutionTls extends TestMinimalClientRequestExecution {
+
+ public RequestExecutionTls() throws Exception {
+ super(URIScheme.HTTPS);
+ }
+
+ }
+
+}
\ No newline at end of file
diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestClientAuthentication.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestClientAuthentication.java
index 27f2a3f03..97596a7f1 100644
--- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestClientAuthentication.java
+++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestClientAuthentication.java
@@ -99,12 +99,20 @@ import org.mockito.Mockito;
/**
* Unit tests for automatic client authentication.
*/
-public class TestClientAuthentication {
+public abstract class TestClientAuthentication {
public static final Timeout TIMEOUT = Timeout.ofMinutes(1);
@RegisterExtension
- private TestClientResources testResources = new TestClientResources(URIScheme.HTTP, TIMEOUT);
+ private TestClientResources testResources;
+
+ protected TestClientAuthentication(final URIScheme scheme) {
+ this.testResources = new TestClientResources(scheme, TIMEOUT);
+ }
+
+ public URIScheme scheme() {
+ return testResources.scheme();
+ }
public ClassicTestServer startServer(final Authenticator authenticator) throws IOException {
return testResources.startServer(
@@ -117,11 +125,11 @@ public class TestClientAuthentication {
return startServer(new BasicTestAuthenticator("test:test", "test realm"));
}
- public CloseableHttpClient startClient(final Consumer clientCustomizer) {
+ public CloseableHttpClient startClient(final Consumer clientCustomizer) throws Exception {
return testResources.startClient(clientCustomizer);
}
- public CloseableHttpClient startClient() {
+ public CloseableHttpClient startClient() throws Exception {
return testResources.startClient(builder -> {});
}
diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestClientRequestExecution.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestClientRequestExecution.java
index 5f1fdeb2d..dce158a99 100644
--- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestClientRequestExecution.java
+++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestClientRequestExecution.java
@@ -74,22 +74,30 @@ import org.junit.jupiter.api.extension.RegisterExtension;
/**
* Client protocol handling tests.
*/
-public class TestClientRequestExecution {
+public abstract class TestClientRequestExecution {
public static final Timeout TIMEOUT = Timeout.ofMinutes(1);
@RegisterExtension
- private TestClientResources testResources = new TestClientResources(URIScheme.HTTP, TIMEOUT);
+ private TestClientResources testResources;
+
+ protected TestClientRequestExecution(final URIScheme scheme) {
+ this.testResources = new TestClientResources(scheme, TIMEOUT);
+ }
+
+ public URIScheme scheme() {
+ return testResources.scheme();
+ }
public ClassicTestServer startServer() throws IOException {
return testResources.startServer(null, null, null);
}
- public CloseableHttpClient startClient(final Consumer clientCustomizer) {
+ public CloseableHttpClient startClient(final Consumer clientCustomizer) throws Exception {
return testResources.startClient(clientCustomizer);
}
- public CloseableHttpClient startClient() {
+ public CloseableHttpClient startClient() throws Exception {
return testResources.startClient(builder -> {});
}
diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestConnectionManagement.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestConnectionManagement.java
index 37f8c46d2..ff1f8d0a2 100644
--- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestConnectionManagement.java
+++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestConnectionManagement.java
@@ -76,7 +76,7 @@ public class TestConnectionManagement {
return testResources.startServer(null, null, null);
}
- public CloseableHttpClient startClient() {
+ public CloseableHttpClient startClient() throws Exception {
return testResources.startClient(b -> {}, b -> {});
}
diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestContentCodings.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestContentCodings.java
index 633670f70..6d99a84f9 100644
--- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestContentCodings.java
+++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestContentCodings.java
@@ -72,22 +72,30 @@ import org.junit.jupiter.api.extension.RegisterExtension;
* require no intervention from the user of HttpClient, but we still want to let clients do their
* own thing if they so wish.
*/
-public class TestContentCodings {
+public abstract class TestContentCodings {
public static final Timeout TIMEOUT = Timeout.ofMinutes(1);
@RegisterExtension
- private TestClientResources testResources = new TestClientResources(URIScheme.HTTP, TIMEOUT);
+ private TestClientResources testResources;
+
+ protected TestContentCodings(final URIScheme scheme) {
+ this.testResources = new TestClientResources(scheme, TIMEOUT);
+ }
+
+ public URIScheme scheme() {
+ return testResources.scheme();
+ }
public ClassicTestServer startServer() throws IOException {
return testResources.startServer(null, null, null);
}
- public CloseableHttpClient startClient(final Consumer clientCustomizer) {
+ public CloseableHttpClient startClient(final Consumer clientCustomizer) throws Exception {
return testResources.startClient(clientCustomizer);
}
- public CloseableHttpClient startClient() {
+ public CloseableHttpClient startClient() throws Exception {
return testResources.startClient(builder -> {});
}
diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestMinimalClientRequestExecution.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestMinimalClientRequestExecution.java
index 47bbfb1f4..1681a4bdc 100644
--- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestMinimalClientRequestExecution.java
+++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestMinimalClientRequestExecution.java
@@ -56,13 +56,20 @@ import org.junit.jupiter.api.extension.RegisterExtension;
/**
* Client protocol handling tests.
*/
-public class TestMinimalClientRequestExecution {
+public abstract class TestMinimalClientRequestExecution {
public static final Timeout TIMEOUT = Timeout.ofMinutes(1);
@RegisterExtension
- private TestClientResources testResources = new TestClientResources(URIScheme.HTTP, TIMEOUT);
+ private TestClientResources testResources;
+ protected TestMinimalClientRequestExecution(final URIScheme scheme) {
+ this.testResources = new TestClientResources(scheme, TIMEOUT);
+ }
+
+ public URIScheme scheme() {
+ return testResources.scheme();
+ }
private static class SimpleService implements HttpRequestHandler {
public SimpleService() {
diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestRedirects.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestRedirects.java
index 2499f4798..a881d1750 100644
--- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestRedirects.java
+++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestRedirects.java
@@ -81,23 +81,31 @@ import org.junit.jupiter.api.extension.RegisterExtension;
/**
* Redirection test cases.
*/
-public class TestRedirects {
+public abstract class TestRedirects {
public static final Timeout TIMEOUT = Timeout.ofMinutes(1);
@RegisterExtension
- private TestClientResources testResources = new TestClientResources(URIScheme.HTTP, TIMEOUT);
+ private TestClientResources testResources;
+
+ protected TestRedirects(final URIScheme scheme) {
+ this.testResources = new TestClientResources(scheme, TIMEOUT);
+ }
+
+ public URIScheme scheme() {
+ return testResources.scheme();
+ }
public ClassicTestServer startServer(final HttpProcessor httpProcessor,
final Decorator handlerDecorator) throws IOException {
return testResources.startServer(null, httpProcessor, handlerDecorator);
}
- public CloseableHttpClient startClient(final Consumer clientCustomizer) {
+ public CloseableHttpClient startClient(final Consumer clientCustomizer) throws Exception {
return testResources.startClient(clientCustomizer);
}
- public CloseableHttpClient startClient() {
+ public CloseableHttpClient startClient() throws Exception {
return testResources.startClient(builder -> {});
}
diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/extension/TestClientResources.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/extension/TestClientResources.java
index 083a5f25d..fd79bed3e 100644
--- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/extension/TestClientResources.java
+++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/extension/TestClientResources.java
@@ -37,6 +37,7 @@ import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.apache.hc.client5.http.impl.classic.MinimalHttpClient;
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder;
+import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory;
import org.apache.hc.client5.testing.SSLTestContexts;
import org.apache.hc.core5.function.Decorator;
import org.apache.hc.core5.http.HttpHost;
@@ -98,6 +99,10 @@ public class TestClientResources implements BeforeEachCallback, AfterEachCallbac
}
}
+ public URIScheme scheme() {
+ return this.scheme;
+ }
+
public ClassicTestServer startServer(
final Http1Config http1Config,
final HttpProcessor httpProcessor,
@@ -114,11 +119,12 @@ public class TestClientResources implements BeforeEachCallback, AfterEachCallbac
public CloseableHttpClient startClient(
final Consumer connManagerCustomizer,
- final Consumer clientCustomizer) {
+ final Consumer clientCustomizer) throws Exception {
Assertions.assertNull(connManager);
Assertions.assertNull(client);
final PoolingHttpClientConnectionManagerBuilder connManagerBuilder = PoolingHttpClientConnectionManagerBuilder.create();
+ connManagerBuilder.setSSLSocketFactory(new SSLConnectionSocketFactory(SSLTestContexts.createClientSSLContext()));
connManagerBuilder.setDefaultSocketConfig(SocketConfig.custom()
.setSoTimeout(timeout)
.build());
@@ -136,11 +142,12 @@ public class TestClientResources implements BeforeEachCallback, AfterEachCallbac
return client;
}
- public MinimalHttpClient startMinimalClient() {
+ public MinimalHttpClient startMinimalClient() throws Exception {
Assertions.assertNull(connManager);
Assertions.assertNull(client);
final PoolingHttpClientConnectionManagerBuilder connManagerBuilder = PoolingHttpClientConnectionManagerBuilder.create();
+ connManagerBuilder.setSSLSocketFactory(new SSLConnectionSocketFactory(SSLTestContexts.createClientSSLContext()));
connManagerBuilder.setDefaultSocketConfig(SocketConfig.custom()
.setSoTimeout(timeout)
.build());
@@ -155,7 +162,7 @@ public class TestClientResources implements BeforeEachCallback, AfterEachCallbac
}
public CloseableHttpClient startClient(
- final Consumer clientCustomizer) {
+ final Consumer clientCustomizer) throws Exception {
return startClient(b -> {}, clientCustomizer);
}