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

Commit8b58fe1

Browse files
author
Stephane Landelle
committed
Move tests to Netty specific class, Grizzly don't care about ConnectionPool
1 parent754bdbf commit8b58fe1

File tree

3 files changed

+106
-182
lines changed

3 files changed

+106
-182
lines changed

‎src/test/java/com/ning/http/client/async/ConnectionPoolTest.java‎

Lines changed: 14 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,10 @@
1515
*/
1616
packagecom.ning.http.client.async;
1717

18-
importcom.ning.http.client.AsyncCompletionHandler;
19-
importcom.ning.http.client.AsyncCompletionHandlerBase;
20-
importcom.ning.http.client.AsyncHttpClient;
21-
importcom.ning.http.client.AsyncHttpClientConfig;
22-
importcom.ning.http.client.ConnectionsPool;
23-
importcom.ning.http.client.Response;
24-
importorg.jboss.netty.channel.Channel;
25-
importorg.slf4j.Logger;
26-
importorg.slf4j.LoggerFactory;
27-
importorg.testng.Assert;
28-
importorg.testng.annotations.Test;
18+
importstaticorg.testng.Assert.assertEquals;
19+
importstaticorg.testng.Assert.assertNotNull;
20+
importstaticorg.testng.Assert.assertNull;
21+
importstaticorg.testng.Assert.fail;
2922

3023
importjava.io.IOException;
3124
importjava.util.Map;
@@ -35,10 +28,16 @@
3528
importjava.util.concurrent.TimeUnit;
3629
importjava.util.concurrent.atomic.AtomicInteger;
3730

38-
importstaticorg.testng.Assert.assertEquals;
39-
importstaticorg.testng.Assert.assertNotNull;
40-
importstaticorg.testng.Assert.assertNull;
41-
importstaticorg.testng.Assert.fail;
31+
importorg.slf4j.Logger;
32+
importorg.slf4j.LoggerFactory;
33+
importorg.testng.Assert;
34+
importorg.testng.annotations.Test;
35+
36+
importcom.ning.http.client.AsyncCompletionHandler;
37+
importcom.ning.http.client.AsyncCompletionHandlerBase;
38+
importcom.ning.http.client.AsyncHttpClient;
39+
importcom.ning.http.client.AsyncHttpClientConfig;
40+
importcom.ning.http.client.Response;
4241

4342
publicabstractclassConnectionPoolTestextendsAbstractBasicTest {
4443
protectedfinalLoggerlog =LoggerFactory.getLogger(AbstractBasicTest.class);
@@ -133,89 +132,6 @@ public Response onCompleted(Response response) throws Exception {
133132
}
134133
}
135134

136-
@Test(groups = {"standalone","default_provider" })
137-
publicvoidtestInvalidConnectionsPool() {
138-
139-
ConnectionsPool<String,Channel>cp =newConnectionsPool<String,Channel>() {
140-
141-
publicbooleanoffer(Stringkey,Channelconnection) {
142-
returnfalse;
143-
}
144-
145-
publicChannelpoll(Stringconnection) {
146-
returnnull;
147-
}
148-
149-
publicbooleanremoveAll(Channelconnection) {
150-
returnfalse;
151-
}
152-
153-
publicbooleancanCacheConnection() {
154-
returnfalse;
155-
}
156-
157-
publicvoiddestroy() {
158-
159-
}
160-
};
161-
162-
AsyncHttpClientclient =getAsyncHttpClient(newAsyncHttpClientConfig.Builder().setConnectionsPool(cp).build());
163-
try {
164-
Exceptionexception =null;
165-
try {
166-
client.prepareGet(getTargetUrl()).execute().get(TIMEOUT,TimeUnit.SECONDS);
167-
}catch (Exceptionex) {
168-
ex.printStackTrace();
169-
exception =ex;
170-
}
171-
assertNotNull(exception);
172-
assertEquals(exception.getMessage(),"Too many connections -1");
173-
}finally {
174-
client.close();
175-
}
176-
}
177-
178-
@Test(groups = {"standalone","default_provider" })
179-
publicvoidtestValidConnectionsPool() {
180-
181-
ConnectionsPool<String,Channel>cp =newConnectionsPool<String,Channel>() {
182-
183-
publicbooleanoffer(Stringkey,Channelconnection) {
184-
returntrue;
185-
}
186-
187-
publicChannelpoll(Stringconnection) {
188-
returnnull;
189-
}
190-
191-
publicbooleanremoveAll(Channelconnection) {
192-
returnfalse;
193-
}
194-
195-
publicbooleancanCacheConnection() {
196-
returntrue;
197-
}
198-
199-
publicvoiddestroy() {
200-
201-
}
202-
};
203-
204-
AsyncHttpClientclient =getAsyncHttpClient(newAsyncHttpClientConfig.Builder().setConnectionsPool(cp).build());
205-
try {
206-
Exceptionexception =null;
207-
try {
208-
client.prepareGet(getTargetUrl()).execute().get(TIMEOUT,TimeUnit.SECONDS);
209-
}catch (Exceptionex) {
210-
ex.printStackTrace();
211-
exception =ex;
212-
}
213-
assertNull(exception);
214-
}finally {
215-
client.close();
216-
}
217-
}
218-
219135
@Test(groups = {"standalone","default_provider" })
220136
publicvoidmultipleMaxConnectionOpenTest()throwsThrowable {
221137
AsyncHttpClientConfigcg =newAsyncHttpClientConfig.Builder().setAllowPoolingConnection(true).setConnectionTimeoutInMs(5000).setMaximumConnectionsTotal(1).build();

‎src/test/java/com/ning/http/client/async/grizzly/GrizzlyConnectionPoolTest.java‎

Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,14 @@
1515

1616
importstaticorg.testng.Assert.assertEquals;
1717
importstaticorg.testng.Assert.assertNotNull;
18-
importstaticorg.testng.Assert.assertNull;
1918
importstaticorg.testng.Assert.fail;
2019

2120
importjava.util.concurrent.TimeUnit;
2221

23-
importorg.glassfish.grizzly.Connection;
2422
importorg.testng.annotations.Test;
2523

2624
importcom.ning.http.client.AsyncHttpClient;
2725
importcom.ning.http.client.AsyncHttpClientConfig;
28-
importcom.ning.http.client.ConnectionsPool;
2926
importcom.ning.http.client.Response;
3027
importcom.ning.http.client.async.ConnectionPoolTest;
3128
importcom.ning.http.client.async.ProviderUtil;
@@ -66,87 +63,6 @@ public void testMaxTotalConnectionsException() {
6663
}
6764
}
6865

69-
@Override
70-
publicvoidtestValidConnectionsPool() {
71-
ConnectionsPool<String,Connection>cp =newConnectionsPool<String,Connection>() {
72-
73-
publicbooleanoffer(Stringkey,Connectionconnection) {
74-
returntrue;
75-
}
76-
77-
publicConnectionpoll(Stringconnection) {
78-
returnnull;
79-
}
80-
81-
publicbooleanremoveAll(Connectionconnection) {
82-
returnfalse;
83-
}
84-
85-
publicbooleancanCacheConnection() {
86-
returntrue;
87-
}
88-
89-
publicvoiddestroy() {
90-
91-
}
92-
};
93-
94-
AsyncHttpClientclient =getAsyncHttpClient(newAsyncHttpClientConfig.Builder().setConnectionsPool(cp).build());
95-
try {
96-
Exceptionexception =null;
97-
try {
98-
client.prepareGet(getTargetUrl()).execute().get(TIMEOUT,TimeUnit.SECONDS);
99-
}catch (Exceptionex) {
100-
ex.printStackTrace();
101-
exception =ex;
102-
}
103-
assertNull(exception);
104-
}finally {
105-
client.close();
106-
}
107-
}
108-
109-
@Test(groups = {"standalone","default_provider" })
110-
publicvoidtestInvalidConnectionsPool() {
111-
112-
ConnectionsPool<String,Connection>cp =newConnectionsPool<String,Connection>() {
113-
114-
publicbooleanoffer(Stringkey,Connectionconnection) {
115-
returnfalse;
116-
}
117-
118-
publicConnectionpoll(Stringconnection) {
119-
returnnull;
120-
}
121-
122-
publicbooleanremoveAll(Connectionconnection) {
123-
returnfalse;
124-
}
125-
126-
publicbooleancanCacheConnection() {
127-
returnfalse;
128-
}
129-
130-
publicvoiddestroy() {
131-
132-
}
133-
};
134-
135-
AsyncHttpClientclient =getAsyncHttpClient(newAsyncHttpClientConfig.Builder().setConnectionsPool(cp).build());
136-
try {
137-
Exceptionexception =null;
138-
try {
139-
client.prepareGet(getTargetUrl()).execute().get(TIMEOUT,TimeUnit.SECONDS);
140-
}catch (Exceptionex) {
141-
ex.printStackTrace();
142-
exception =ex;
143-
}
144-
assertNotNull(exception);
145-
}finally {
146-
client.close();
147-
}
148-
}
149-
15066
@Override
15167
@Test
15268
publicvoidmultipleMaxConnectionOpenTest()throwsThrowable {

‎src/test/java/com/ning/http/client/async/netty/NettyConnectionPoolTest.java‎

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,18 @@
1212
*/
1313
packagecom.ning.http.client.async.netty;
1414

15+
importstaticorg.testng.Assert.assertEquals;
16+
importstaticorg.testng.Assert.assertNotNull;
17+
importstaticorg.testng.Assert.assertNull;
18+
19+
importjava.util.concurrent.TimeUnit;
20+
21+
importorg.jboss.netty.channel.Channel;
22+
importorg.testng.annotations.Test;
23+
1524
importcom.ning.http.client.AsyncHttpClient;
1625
importcom.ning.http.client.AsyncHttpClientConfig;
26+
importcom.ning.http.client.ConnectionsPool;
1727
importcom.ning.http.client.async.ConnectionPoolTest;
1828
importcom.ning.http.client.async.ProviderUtil;
1929

@@ -24,4 +34,86 @@ public AsyncHttpClient getAsyncHttpClient(AsyncHttpClientConfig config) {
2434
returnProviderUtil.nettyProvider(config);
2535
}
2636

37+
@Test(groups = {"standalone","default_provider" })
38+
publicvoidtestInvalidConnectionsPool() {
39+
40+
ConnectionsPool<String,Channel>cp =newConnectionsPool<String,Channel>() {
41+
42+
publicbooleanoffer(Stringkey,Channelconnection) {
43+
returnfalse;
44+
}
45+
46+
publicChannelpoll(Stringconnection) {
47+
returnnull;
48+
}
49+
50+
publicbooleanremoveAll(Channelconnection) {
51+
returnfalse;
52+
}
53+
54+
publicbooleancanCacheConnection() {
55+
returnfalse;
56+
}
57+
58+
publicvoiddestroy() {
59+
60+
}
61+
};
62+
63+
AsyncHttpClientclient =getAsyncHttpClient(newAsyncHttpClientConfig.Builder().setConnectionsPool(cp).build());
64+
try {
65+
Exceptionexception =null;
66+
try {
67+
client.prepareGet(getTargetUrl()).execute().get(TIMEOUT,TimeUnit.SECONDS);
68+
}catch (Exceptionex) {
69+
ex.printStackTrace();
70+
exception =ex;
71+
}
72+
assertNotNull(exception);
73+
assertEquals(exception.getMessage(),"Too many connections -1");
74+
}finally {
75+
client.close();
76+
}
77+
}
78+
79+
@Test(groups = {"standalone","default_provider" })
80+
publicvoidtestValidConnectionsPool() {
81+
82+
ConnectionsPool<String,Channel>cp =newConnectionsPool<String,Channel>() {
83+
84+
publicbooleanoffer(Stringkey,Channelconnection) {
85+
returntrue;
86+
}
87+
88+
publicChannelpoll(Stringconnection) {
89+
returnnull;
90+
}
91+
92+
publicbooleanremoveAll(Channelconnection) {
93+
returnfalse;
94+
}
95+
96+
publicbooleancanCacheConnection() {
97+
returntrue;
98+
}
99+
100+
publicvoiddestroy() {
101+
102+
}
103+
};
104+
105+
AsyncHttpClientclient =getAsyncHttpClient(newAsyncHttpClientConfig.Builder().setConnectionsPool(cp).build());
106+
try {
107+
Exceptionexception =null;
108+
try {
109+
client.prepareGet(getTargetUrl()).execute().get(TIMEOUT,TimeUnit.SECONDS);
110+
}catch (Exceptionex) {
111+
ex.printStackTrace();
112+
exception =ex;
113+
}
114+
assertNull(exception);
115+
}finally {
116+
client.close();
117+
}
118+
}
27119
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp