Skip to content

Commit efe2598

Browse files
committed
Classic test suits to execute in plain and TLS modes
1 parent 9ec6347 commit efe2598

9 files changed

Lines changed: 238 additions & 22 deletions
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
/*
2+
* ====================================================================
3+
* Licensed to the Apache Software Foundation (ASF) under one
4+
* or more contributor license agreements. See the NOTICE file
5+
* distributed with this work for additional information
6+
* regarding copyright ownership. The ASF licenses this file
7+
* to you under the Apache License, Version 2.0 (the
8+
* "License"); you may not use this file except in compliance
9+
* with the License. You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing,
14+
* software distributed under the License is distributed on an
15+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
* KIND, either express or implied. See the License for the
17+
* specific language governing permissions and limitations
18+
* under the License.
19+
* ====================================================================
20+
*
21+
* This software consists of voluntary contributions made by many
22+
* individuals on behalf of the Apache Software Foundation. For more
23+
* information on the Apache Software Foundation, please see
24+
* <http://www.apache.org/>.
25+
*
26+
*/
27+
package org.apache.hc.client5.testing.sync;
28+
29+
import org.apache.hc.core5.http.URIScheme;
30+
import org.junit.jupiter.api.DisplayName;
31+
import org.junit.jupiter.api.Nested;
32+
33+
public class HttpIntegrationTests {
34+
35+
@Nested
36+
@DisplayName("Request execution (HTTP/1.1)")
37+
public class RequestExecution extends TestClientRequestExecution {
38+
39+
public RequestExecution() throws Exception {
40+
super(URIScheme.HTTP);
41+
}
42+
43+
}
44+
45+
@Nested
46+
@DisplayName("Request execution (HTTP/1.1, TLS)")
47+
public class RequestExecutionTls extends TestClientRequestExecution {
48+
49+
public RequestExecutionTls() throws Exception {
50+
super(URIScheme.HTTPS);
51+
}
52+
53+
}
54+
55+
@Nested
56+
@DisplayName("Authentication (HTTP/1.1)")
57+
public class Authentication extends TestClientAuthentication {
58+
59+
public Authentication() throws Exception {
60+
super(URIScheme.HTTP);
61+
}
62+
63+
}
64+
65+
@Nested
66+
@DisplayName("Authentication (HTTP/1.1, TLS)")
67+
public class AuthenticationTls extends TestClientAuthentication {
68+
69+
public AuthenticationTls() throws Exception {
70+
super(URIScheme.HTTPS);
71+
}
72+
73+
}
74+
75+
@Nested
76+
@DisplayName("Content coding (HTTP/1.1)")
77+
public class ContentCoding extends TestContentCodings {
78+
79+
public ContentCoding() throws Exception {
80+
super(URIScheme.HTTP);
81+
}
82+
83+
}
84+
85+
@Nested
86+
@DisplayName("Content coding (HTTP/1.1, TLS)")
87+
public class ContentCodingTls extends TestContentCodings {
88+
89+
public ContentCodingTls() throws Exception {
90+
super(URIScheme.HTTPS);
91+
}
92+
93+
}
94+
95+
@Nested
96+
@DisplayName("Redirects (HTTP/1.1)")
97+
public class Redirects extends TestRedirects {
98+
99+
public Redirects() throws Exception {
100+
super(URIScheme.HTTP);
101+
}
102+
103+
}
104+
105+
@Nested
106+
@DisplayName("Redirects (HTTP/1.1, TLS)")
107+
public class RedirectsTls extends TestRedirects {
108+
109+
public RedirectsTls() throws Exception {
110+
super(URIScheme.HTTPS);
111+
}
112+
113+
}
114+
115+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* ====================================================================
3+
* Licensed to the Apache Software Foundation (ASF) under one
4+
* or more contributor license agreements. See the NOTICE file
5+
* distributed with this work for additional information
6+
* regarding copyright ownership. The ASF licenses this file
7+
* to you under the Apache License, Version 2.0 (the
8+
* "License"); you may not use this file except in compliance
9+
* with the License. You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing,
14+
* software distributed under the License is distributed on an
15+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
* KIND, either express or implied. See the License for the
17+
* specific language governing permissions and limitations
18+
* under the License.
19+
* ====================================================================
20+
*
21+
* This software consists of voluntary contributions made by many
22+
* individuals on behalf of the Apache Software Foundation. For more
23+
* information on the Apache Software Foundation, please see
24+
* <http://www.apache.org/>.
25+
*
26+
*/
27+
package org.apache.hc.client5.testing.sync;
28+
29+
import org.apache.hc.core5.http.URIScheme;
30+
import org.junit.jupiter.api.DisplayName;
31+
import org.junit.jupiter.api.Nested;
32+
33+
public class HttpMinimalIntegrationTests {
34+
35+
@Nested
36+
@DisplayName("Request execution (HTTP/1.1)")
37+
public class RequestExecution extends TestMinimalClientRequestExecution {
38+
39+
public RequestExecution() throws Exception {
40+
super(URIScheme.HTTP);
41+
}
42+
43+
}
44+
45+
@Nested
46+
@DisplayName("Request execution (HTTP/1.1, TLS)")
47+
public class RequestExecutionTls extends TestMinimalClientRequestExecution {
48+
49+
public RequestExecutionTls() throws Exception {
50+
super(URIScheme.HTTPS);
51+
}
52+
53+
}
54+
55+
}

httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestClientAuthentication.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,20 @@
9999
/**
100100
* Unit tests for automatic client authentication.
101101
*/
102-
public class TestClientAuthentication {
102+
public abstract class TestClientAuthentication {
103103

104104
public static final Timeout TIMEOUT = Timeout.ofMinutes(1);
105105

106106
@RegisterExtension
107-
private TestClientResources testResources = new TestClientResources(URIScheme.HTTP, TIMEOUT);
107+
private TestClientResources testResources;
108+
109+
protected TestClientAuthentication(final URIScheme scheme) {
110+
this.testResources = new TestClientResources(scheme, TIMEOUT);
111+
}
112+
113+
public URIScheme scheme() {
114+
return testResources.scheme();
115+
}
108116

109117
public ClassicTestServer startServer(final Authenticator authenticator) throws IOException {
110118
return testResources.startServer(
@@ -117,11 +125,11 @@ public ClassicTestServer startServer() throws IOException {
117125
return startServer(new BasicTestAuthenticator("test:test", "test realm"));
118126
}
119127

120-
public CloseableHttpClient startClient(final Consumer<HttpClientBuilder> clientCustomizer) {
128+
public CloseableHttpClient startClient(final Consumer<HttpClientBuilder> clientCustomizer) throws Exception {
121129
return testResources.startClient(clientCustomizer);
122130
}
123131

124-
public CloseableHttpClient startClient() {
132+
public CloseableHttpClient startClient() throws Exception {
125133
return testResources.startClient(builder -> {});
126134
}
127135

httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestClientRequestExecution.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,22 +74,30 @@
7474
/**
7575
* Client protocol handling tests.
7676
*/
77-
public class TestClientRequestExecution {
77+
public abstract class TestClientRequestExecution {
7878

7979
public static final Timeout TIMEOUT = Timeout.ofMinutes(1);
8080

8181
@RegisterExtension
82-
private TestClientResources testResources = new TestClientResources(URIScheme.HTTP, TIMEOUT);
82+
private TestClientResources testResources;
83+
84+
protected TestClientRequestExecution(final URIScheme scheme) {
85+
this.testResources = new TestClientResources(scheme, TIMEOUT);
86+
}
87+
88+
public URIScheme scheme() {
89+
return testResources.scheme();
90+
}
8391

8492
public ClassicTestServer startServer() throws IOException {
8593
return testResources.startServer(null, null, null);
8694
}
8795

88-
public CloseableHttpClient startClient(final Consumer<HttpClientBuilder> clientCustomizer) {
96+
public CloseableHttpClient startClient(final Consumer<HttpClientBuilder> clientCustomizer) throws Exception {
8997
return testResources.startClient(clientCustomizer);
9098
}
9199

92-
public CloseableHttpClient startClient() {
100+
public CloseableHttpClient startClient() throws Exception {
93101
return testResources.startClient(builder -> {});
94102
}
95103

httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestConnectionManagement.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public ClassicTestServer startServer() throws IOException {
7676
return testResources.startServer(null, null, null);
7777
}
7878

79-
public CloseableHttpClient startClient() {
79+
public CloseableHttpClient startClient() throws Exception {
8080
return testResources.startClient(b -> {}, b -> {});
8181
}
8282

httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestContentCodings.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,22 +72,30 @@
7272
* require no intervention from the user of HttpClient, but we still want to let clients do their
7373
* own thing if they so wish.
7474
*/
75-
public class TestContentCodings {
75+
public abstract class TestContentCodings {
7676

7777
public static final Timeout TIMEOUT = Timeout.ofMinutes(1);
7878

7979
@RegisterExtension
80-
private TestClientResources testResources = new TestClientResources(URIScheme.HTTP, TIMEOUT);
80+
private TestClientResources testResources;
81+
82+
protected TestContentCodings(final URIScheme scheme) {
83+
this.testResources = new TestClientResources(scheme, TIMEOUT);
84+
}
85+
86+
public URIScheme scheme() {
87+
return testResources.scheme();
88+
}
8189

8290
public ClassicTestServer startServer() throws IOException {
8391
return testResources.startServer(null, null, null);
8492
}
8593

86-
public CloseableHttpClient startClient(final Consumer<HttpClientBuilder> clientCustomizer) {
94+
public CloseableHttpClient startClient(final Consumer<HttpClientBuilder> clientCustomizer) throws Exception {
8795
return testResources.startClient(clientCustomizer);
8896
}
8997

90-
public CloseableHttpClient startClient() {
98+
public CloseableHttpClient startClient() throws Exception {
9199
return testResources.startClient(builder -> {});
92100
}
93101

httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestMinimalClientRequestExecution.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,20 @@
5656
/**
5757
* Client protocol handling tests.
5858
*/
59-
public class TestMinimalClientRequestExecution {
59+
public abstract class TestMinimalClientRequestExecution {
6060

6161
public static final Timeout TIMEOUT = Timeout.ofMinutes(1);
6262

6363
@RegisterExtension
64-
private TestClientResources testResources = new TestClientResources(URIScheme.HTTP, TIMEOUT);
64+
private TestClientResources testResources;
6565

66+
protected TestMinimalClientRequestExecution(final URIScheme scheme) {
67+
this.testResources = new TestClientResources(scheme, TIMEOUT);
68+
}
69+
70+
public URIScheme scheme() {
71+
return testResources.scheme();
72+
}
6673
private static class SimpleService implements HttpRequestHandler {
6774

6875
public SimpleService() {

httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestRedirects.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,23 +81,31 @@
8181
/**
8282
* Redirection test cases.
8383
*/
84-
public class TestRedirects {
84+
public abstract class TestRedirects {
8585

8686
public static final Timeout TIMEOUT = Timeout.ofMinutes(1);
8787

8888
@RegisterExtension
89-
private TestClientResources testResources = new TestClientResources(URIScheme.HTTP, TIMEOUT);
89+
private TestClientResources testResources;
90+
91+
protected TestRedirects(final URIScheme scheme) {
92+
this.testResources = new TestClientResources(scheme, TIMEOUT);
93+
}
94+
95+
public URIScheme scheme() {
96+
return testResources.scheme();
97+
}
9098

9199
public ClassicTestServer startServer(final HttpProcessor httpProcessor,
92100
final Decorator<HttpServerRequestHandler> handlerDecorator) throws IOException {
93101
return testResources.startServer(null, httpProcessor, handlerDecorator);
94102
}
95103

96-
public CloseableHttpClient startClient(final Consumer<HttpClientBuilder> clientCustomizer) {
104+
public CloseableHttpClient startClient(final Consumer<HttpClientBuilder> clientCustomizer) throws Exception {
97105
return testResources.startClient(clientCustomizer);
98106
}
99107

100-
public CloseableHttpClient startClient() {
108+
public CloseableHttpClient startClient() throws Exception {
101109
return testResources.startClient(builder -> {});
102110
}
103111

0 commit comments

Comments
 (0)