8000 Fix test: should define a provider · cloudxia/async-http-client@51f6ec2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 51f6ec2

Browse files
author
Stephane Landelle
committed
Fix test: should define a provider
1 parent e67638f commit 51f6ec2

File tree

4 files changed

+67
-23
lines changed

4 files changed

+67
-23
lines changed

api/src/test/java/org/asynchttpclient/async/SimpleAsyncClientErrorBehaviourTest.java

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,24 @@
2222
import javax.servlet.http.HttpServletRequest;
2323
import javax.servlet.http.HttpServletResponse;
2424

25-
import org.eclipse.jetty.server.handler.AbstractHandler;
26-
import org.testng.annotations.Test;
27-
28-
import org.asynchttpclient.AsyncHttpClient;
29-
import org.asynchttpclient.AsyncHttpClientConfig;
3025
import org.asynchttpclient.Response;
3126
import org.asynchttpclient.SimpleAsyncHttpClient;
3227
import org.asynchttpclient.SimpleAsyncHttpClient.ErrorDocumentBehaviour;
3328
import org.asynchttpclient.consumers.OutputStreamBodyConsumer;
29+
import org.eclipse.jetty.server.handler.AbstractHandler;
30+
import org.testng.annotations.Test;
3431

3532
/**
3633
* @author Benjamin Hanzelmann
3734
*
3835
*/
39-
public class SimpleAsyncClientErrorBehaviourTest extends AbstractBasicTest {
36+
public abstract class SimpleAsyncClientErrorBehaviourTest extends AbstractBasicTest {
37+
38+
public abstract String getProviderClass();
4039

4140
@Test(groups = { "standalone", "default_provider" })
4241
public void testAccumulateErrorBody() throws Exception {
43-
SimpleAsyncHttpClient client = new SimpleAsyncHttpClient.Builder().setUrl(getTargetUrl() + "/nonexistent").setErrorDocumentBehaviour(ErrorDocumentBehaviour.ACCUMULATE).build();
42+
SimpleAsyncHttpClient client = new SimpleAsyncHttpClient.Builder().setProviderClass(getProviderClass()).setUrl(getTargetUrl() + "/nonexistent").setErrorDocumentBehaviour(ErrorDocumentBehaviour.ACCUMULATE).build();
4443
try {
4544
ByteArrayOutputStream o = new ByteArrayOutputStream(10);
4645
Future<Response> future = client.get(new OutputStreamBodyConsumer(o));
@@ -57,7 +56,7 @@ public void testAccumulateErrorBody() throws Exception {
5756

5857
@Test(groups = { "standalone", "default_provider" })
5958
public void testOmitErrorBody() throws Exception {
60-
SimpleAsyncHttpClient client = new SimpleAsyncHttpClient.Builder().setUrl(getTargetUrl() + "/nonexistent").setErrorDocumentBehaviour(ErrorDocumentBehaviour.OMIT).build();
59+
SimpleAsyncHttpClient client = new SimpleAsyncHttpClient.Builder().setProviderClass(getProviderClass()).setUrl(getTargetUrl() + "/nonexistent").setErrorDocumentBehaviour(ErrorDocumentBehaviour.OMIT).build();
6160
try {
6261
ByteArrayOutputStream o = new ByteArrayOutputStream(10);
6362
Future<Response> future = client.get(new OutputStreamBodyConsumer(o));
@@ -72,12 +71,6 @@ public void testOmitErrorBody() throws Exception {
7271
}
7372
}
7473

75-
@Override
76-
public AsyncHttpClient getAsyncHttpClient(AsyncHttpClientConfig config) {
77-
// disabled
78-
return null;
79-
}
80-
8174
@Override
8275
public AbstractHandler configureHandler() throws Exception {
8376
return new AbstractHandler() {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2012 Sonatype, Inc. 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 http://www.apache.org/licenses/LICENSE-2.0.
7+
*
8+
* Unless required by applicable law or agreed to in writing,
9+
* software distributed under the Apache License Version 2.0 is distributed on an
10+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
12+
*/
13+
14+
package org.asynchttpclient.providers.grizzly;
15+
16+
import org.asynchttpclient.AsyncHttpClient;
17+
import org.asynchttpclie 8000 nt.AsyncHttpClientConfig;
18+
import org.asynchttpclient.async.SimpleAsyncClientErrorBehaviourTest;
19+
20+
public class GrizzlySimpleAsyncClientErrorBehaviourTest extends SimpleAsyncClientErrorBehaviourTest {
21+
22+
@Override
23+
public AsyncHttpClient getAsyncHttpClient(AsyncHttpClientConfig config) {
24+
return GrizzlyProviderUtil.grizzlyProvider(config);
25+
}
26+
27+
public String getProviderClass() {
28+
return GrizzlyAsyncHttpProvider.class.getName();
29+
}
30+
}

providers/grizzly/src/test/java/org/asynchttpclient/providers/grizzly/GrizzlySimpleAsyncHttpClientTest.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,10 @@
1313

1414
package org.asynchttpclient.providers.grizzly;
1515

16-
import org.asynchttpclient.AsyncCompletionHandler;
17-
import org.asynchttpclient.AsyncHandler;
1816
import org.asynchttpclient.AsyncHttpClient;
1917
import org.asynchttpclient.AsyncHttpClientConfig;
20-
import org.asynchttpclient.Request;
21-
import org.asynchttpclient.RequestBuilder;
22-
import org.asynchttpclient.Response;
2318
import org.asynchttpclient.async.SimpleAsyncHttpClientTest;
2419

25-
import java.io.IOException;
26-
import java.util.concurrent.Future;
27-
2820
public class GrizzlySimpleAsyncHttpClientTest extends SimpleAsyncHttpClientTest {
2921

3022
@Override
@@ -35,5 +27,4 @@ public AsyncHttpClient getAsyncHttpClient(AsyncHttpClientConfig config) {
3527
public String getProviderClass() {
3628
return GrizzlyAsyncHttpProvider.class.getName();
3729
}
38-
3930
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2012 Sonatype, Inc. 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 http://www.apache.org/licenses/LICENSE-2.0.
7+
*
8+
* Unless required by applicable law or agreed to in writing,
9+
* software distributed under the Apache License Version 2.0 is distributed on an
10+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
12+
*/
13+
14+
package org.asynchttpclient.providers.netty;
15+
16+
import org.asynchttpclient.AsyncHttpClient;
17+
import org.asynchttpclient.AsyncHttpClientConfig;
18+
import org.asynchttpclient.async.SimpleAsyncClientErrorBehaviourTest;
19+
20+
public class NettySimpleAsyncClientErrorBehaviourTest extends SimpleAsyncClientErrorBehaviourTest {
21+
22+
@Override
23+
public AsyncHttpClient getAsyncHttpClient(AsyncHttpClientConfig config) {
24+
return NettyProviderUtil.nettyProvider(config);
25+
}
26+
27+
public String getProviderClass() {
28+
return NettyProviderUtil.class.getName();
29+
}
30+
}

0 commit comments

Comments
 (0)
0