Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ClientInvoker.invoke() catches ResponseProcessingException and closes connection. [RESTEASY-1932] Added integration test. [RESTEASY-1932] Cleaned up test.
- Loading branch information
Showing
5 changed files
with
145 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
...est/java/org/jboss/resteasy/test/core/interceptors/ClientResponseFilterExceptionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package org.jboss.resteasy.test.core.interceptors; | ||
|
||
import javax.ws.rs.InternalServerErrorException; | ||
import javax.ws.rs.client.ResponseProcessingException; | ||
|
||
import org.apache.http.client.config.RequestConfig; | ||
import org.apache.http.impl.client.HttpClientBuilder; | ||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.arquillian.container.test.api.RunAsClient; | ||
import org.jboss.arquillian.junit.Arquillian; | ||
import org.jboss.resteasy.client.jaxrs.ClientHttpEngine; | ||
import org.jboss.resteasy.client.jaxrs.ResteasyClient; | ||
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; | ||
import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget; | ||
import org.jboss.resteasy.client.jaxrs.engines.factory.ApacheHttpClient4EngineFactory; | ||
import org.jboss.resteasy.test.core.interceptors.resource.ClientResponseFilterExceptionFilter; | ||
import org.jboss.resteasy.test.core.interceptors.resource.ClientResponseFilterExceptionResource; | ||
import org.jboss.resteasy.test.core.interceptors.resource.ClientResponseFilterExceptionResourceImpl; | ||
import org.jboss.resteasy.utils.PortProviderUtil; | ||
import org.jboss.resteasy.utils.TestUtil; | ||
import org.jboss.shrinkwrap.api.Archive; | ||
import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
/** | ||
* @tpSubChapter Interceptors | ||
* @tpChapter Integration tests | ||
* @tpTestCaseDetails Regression test for RESTEASY-1932 | ||
* @tpSince RESTEasy 3.0.26 | ||
*/ | ||
@RunWith(Arquillian.class) | ||
@RunAsClient | ||
public class ClientResponseFilterExceptionTest { | ||
|
||
@Deployment | ||
public static Archive<?> deploySimpleResource() { | ||
WebArchive war = TestUtil.prepareArchive(ClientResponseFilterExceptionTest.class.getSimpleName()); | ||
war.addClass(ClientResponseFilterExceptionResource.class); | ||
war.addClass(ClientResponseFilterExceptionFilter.class); | ||
return TestUtil.finishContainerPrepare(war, null, ClientResponseFilterExceptionResourceImpl.class); | ||
} | ||
|
||
private String generateURL(String path) { | ||
return PortProviderUtil.generateURL(path, ClientResponseFilterExceptionTest.class.getSimpleName()); | ||
} | ||
|
||
/** | ||
* @tpTestDetails Generate PreProcessorExceptionMapperCandlepinUnauthorizedException | ||
* @tpPassCrit SC_PRECONDITION_FAILED (412) HTTP code is excepted | ||
* @tpSince RESTEasy 3.0.26 | ||
*/ | ||
@Test | ||
public void testMapper() throws Exception { | ||
RequestConfig requestConfig = RequestConfig.custom() | ||
.setConnectionRequestTimeout(1000) | ||
.setSocketTimeout(1000) | ||
.setConnectTimeout(1000) | ||
.build(); | ||
|
||
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create() | ||
.setDefaultRequestConfig(requestConfig) | ||
.setMaxConnPerRoute(2) | ||
.setMaxConnTotal(2); | ||
|
||
ClientHttpEngine engine = ApacheHttpClient4EngineFactory.create(httpClientBuilder.build(), true); | ||
|
||
ResteasyClientBuilder clientBuilder = new ResteasyClientBuilder().httpEngine(engine) | ||
.register(ClientResponseFilterExceptionFilter.class) | ||
; | ||
|
||
ResteasyClient client = clientBuilder.build(); | ||
|
||
ResteasyWebTarget target = client.target(generateURL("")); | ||
ClientResponseFilterExceptionResource service = target.proxy(ClientResponseFilterExceptionResource.class); | ||
|
||
int i = 0; | ||
for (; i < 10; i++) { | ||
try { | ||
service.dummy(); | ||
} catch (InternalServerErrorException e) { | ||
//do nothing | ||
} catch (ResponseProcessingException e) { | ||
//do nothing | ||
} | ||
} | ||
Assert.assertEquals(10, i); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...g/jboss/resteasy/test/core/interceptors/resource/ClientResponseFilterExceptionFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.jboss.resteasy.test.core.interceptors.resource; | ||
|
||
import javax.ws.rs.client.ClientRequestContext; | ||
import javax.ws.rs.client.ClientResponseContext; | ||
import javax.ws.rs.client.ClientResponseFilter; | ||
import javax.ws.rs.ext.Provider; | ||
|
||
@Provider | ||
public class ClientResponseFilterExceptionFilter implements ClientResponseFilter { | ||
|
||
@Override | ||
public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) { | ||
throw new RuntimeException(); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...jboss/resteasy/test/core/interceptors/resource/ClientResponseFilterExceptionResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.jboss.resteasy.test.core.interceptors.resource; | ||
|
||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
|
||
@Path("dummyservice") | ||
public interface ClientResponseFilterExceptionResource { | ||
|
||
@Path("dummy") | ||
@GET | ||
public String dummy(); | ||
} |
14 changes: 14 additions & 0 deletions
14
...s/resteasy/test/core/interceptors/resource/ClientResponseFilterExceptionResourceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.jboss.resteasy.test.core.interceptors.resource; | ||
|
||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
|
||
@Path("dummyservice") | ||
public class ClientResponseFilterExceptionResourceImpl { | ||
|
||
@Path("dummy") | ||
@GET | ||
public String dummy() { | ||
return "dummy"; | ||
} | ||
} |