Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit485e1ab

Browse files
author
afelisatti
committed
Update Grizzly to latest version and add test case for HTTPS close connection case
1 parent2eca613 commit485e1ab

File tree

4 files changed

+171
-1
lines changed

4 files changed

+171
-1
lines changed

‎pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@
534534
<distMgmtSnapshotsUrl>http://oss.sonatype.org/content/repositories/snapshots</distMgmtSnapshotsUrl>
535535
<surefire.redirectTestOutputToFile>true</surefire.redirectTestOutputToFile>
536536
<netty.version>3.10.5.Final</netty.version>
537-
<grizzly.version>2.3.21</grizzly.version>
537+
<grizzly.version>2.3.26</grizzly.version>
538538
<maven.compiler.source>1.7</maven.compiler.source>
539539
<maven.compiler.target>1.7</maven.compiler.target>
540540
<surefire.version>2.12</surefire.version>
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
/*
2+
* Copyright (c) 2016 AsyncHttpClient Project. All rights reserved.
3+
*
4+
* This program is licensed to you under the Apache License Version 2.0,
5+
* and you may not use this file except in compliance with the Apache License Version 2.0.
6+
* You may obtain a copy of the Apache License Version 2.0 at
7+
* http://www.apache.org/licenses/LICENSE-2.0.
8+
*
9+
* Unless required by applicable law or agreed to in writing,
10+
* software distributed under the Apache License Version 2.0 is distributed on an
11+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
13+
*/
14+
packagecom.ning.http.client.async;
15+
16+
importstaticcom.ning.http.client.async.BasicHttpsTest.createSSLContext;
17+
18+
importcom.ning.http.client.AsyncHttpClient;
19+
importcom.ning.http.client.AsyncHttpClientConfig;
20+
importcom.ning.http.client.AsyncHttpClientConfig.Builder;
21+
importcom.ning.http.client.Request;
22+
importcom.ning.http.client.RequestBuilder;
23+
importcom.ning.http.client.Response;
24+
25+
importjava.io.File;
26+
importjava.io.IOException;
27+
importjava.net.URL;
28+
importjava.util.concurrent.ExecutionException;
29+
importjava.util.concurrent.Future;
30+
importjava.util.concurrent.atomic.AtomicBoolean;
31+
32+
importjavax.servlet.ServletException;
33+
importjavax.servlet.http.HttpServletRequest;
34+
importjavax.servlet.http.HttpServletResponse;
35+
36+
importorg.eclipse.jetty.server.Server;
37+
importorg.eclipse.jetty.server.handler.AbstractHandler;
38+
importorg.eclipse.jetty.server.ssl.SslSocketConnector;
39+
importorg.testng.Assert;
40+
importorg.testng.annotations.AfterClass;
41+
importorg.testng.annotations.BeforeClass;
42+
importorg.testng.annotations.Test;
43+
44+
publicabstractclassConnectionCloseTestextendsAbstractBasicTest {
45+
46+
@BeforeClass(alwaysRun =true)
47+
publicvoidsetUpGlobal()throwsException {
48+
server =newServer();
49+
port1 =findFreePort();
50+
SslSocketConnectorconnector =newSslSocketConnector();
51+
connector.setHost("127.0.0.1");
52+
connector.setPort(port1);
53+
54+
ClassLoadercl =getClass().getClassLoader();
55+
56+
URLcacertsUrl =cl.getResource("ssltest-cacerts.jks");
57+
StringtrustStoreFile =newFile(cacertsUrl.toURI()).getAbsolutePath();
58+
connector.setTruststore(trustStoreFile);
59+
connector.setTrustPassword("changeit");
60+
connector.setTruststoreType("JKS");
61+
62+
URLkeystoreUrl =cl.getResource("ssltest-keystore.jks");
63+
StringkeyStoreFile =newFile(keystoreUrl.toURI()).getAbsolutePath();
64+
connector.setKeystore(keyStoreFile);
65+
connector.setKeyPassword("changeit");
66+
connector.setKeystoreType("JKS");
67+
68+
server.addConnector(connector);
69+
70+
server.setHandler(configureHandler());
71+
server.start();
72+
log.info("Local HTTP server started successfully");
73+
}
74+
75+
@AfterClass(alwaysRun =true)
76+
publicvoidtearDownGlobal()throwsException {
77+
server.stop();
78+
}
79+
80+
publicstaticclassCloseConnectionHandlerextendsAbstractHandler {
81+
82+
@Override
83+
publicvoidhandle(StringpathInContext,org.eclipse.jetty.server.Requestrequest,HttpServletRequesthttpRequest,
84+
HttpServletResponsehttpResponse)throwsIOException,ServletException {
85+
httpResponse.setHeader("Connection","close");
86+
httpResponse.setStatus(200);
87+
httpResponse.getOutputStream().flush();
88+
httpResponse.getOutputStream().close();
89+
}
90+
}
91+
92+
@Override
93+
publicAbstractHandlerconfigureHandler()throwsException {
94+
returnnewCloseConnectionHandler();
95+
}
96+
97+
@Test
98+
publicvoidhandlesCloseResponse()throwsIOException,InterruptedException,ExecutionException {
99+
100+
AsyncHttpClientConfigconfig =newBuilder().setSSLContext(createSSLContext(newAtomicBoolean(true))).build();
101+
102+
try (AsyncHttpClientclient =getAsyncHttpClient(config)) {
103+
Requestrequest =newRequestBuilder("GET").setHeader("Connection","keep-alive").setUrl(getTargetUrl()).build();
104+
Future<Response>responseFuture =client.executeRequest(request);
105+
intstatus =responseFuture.get().getStatusCode();
106+
Assert.assertEquals(status,200);
107+
}
108+
}
109+
110+
protectedStringgetTargetUrl() {
111+
returnString.format("https://127.0.0.1:%d/foo/test",port1);
112+
}
113+
114+
}
115+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright (c) 2016 AsyncHttpClient Project. All rights reserved.
3+
*
4+
* This program is licensed to you under the Apache License Version 2.0,
5+
* and you may not use this file except in compliance with the Apache License Version 2.0.
6+
* You may obtain a copy of the Apache License Version 2.0 at
7+
* http://www.apache.org/licenses/LICENSE-2.0.
8+
*
9+
* Unless required by applicable law or agreed to in writing,
10+
* software distributed under the Apache License Version 2.0 is distributed on an
11+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
13+
*/
14+
packagecom.ning.http.client.async.grizzly;
15+
16+
importcom.ning.http.client.AsyncHttpClient;
17+
importcom.ning.http.client.AsyncHttpClientConfig;
18+
importcom.ning.http.client.async.ConnectionCloseTest;
19+
importcom.ning.http.client.async.ProviderUtil;
20+
21+
publicclassGrizzlyConnectionCloseTestextendsConnectionCloseTest {
22+
23+
@Override
24+
publicAsyncHttpClientgetAsyncHttpClient(AsyncHttpClientConfigconfig) {
25+
returnProviderUtil.grizzlyProvider(config);
26+
}
27+
28+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright (c) 2016 AsyncHttpClient Project. All rights reserved.
3+
*
4+
* This program is licensed to you under the Apache License Version 2.0,
5+
* and you may not use this file except in compliance with the Apache License Version 2.0.
6+
* You may obtain a copy of the Apache License Version 2.0 at
7+
* http://www.apache.org/licenses/LICENSE-2.0.
8+
*
9+
* Unless required by applicable law or agreed to in writing,
10+
* software distributed under the Apache License Version 2.0 is distributed on an
11+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
13+
*/
14+
packagecom.ning.http.client.async.netty;
15+
16+
importcom.ning.http.client.AsyncHttpClient;
17+
importcom.ning.http.client.AsyncHttpClientConfig;
18+
importcom.ning.http.client.async.ConnectionCloseTest;
19+
importcom.ning.http.client.async.ProviderUtil;
20+
21+
publicclassNettyConnectionCloseTestextendsConnectionCloseTest {
22+
23+
@Override
24+
publicAsyncHttpClientgetAsyncHttpClient(AsyncHttpClientConfigconfig) {
25+
returnProviderUtil.nettyProvider(config);
26+
}
27+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp