use of org.jboss.additional.testsuite.jdkall.present.jaxrs.client.resource.ApacheHttpClient43Resource in project eap-additional-testsuite by jboss-set.
the class ApacheHttpClient432TestCase method apacheHttpClient4EngineServletTest.
@Test
@OperateOnDeployment(DEPLOYMENT)
public void apacheHttpClient4EngineServletTest(@ArquillianResource URL url) throws Exception {
SocketConfig socketConfig = SocketConfig.custom().setTcpNoDelay(true).setSoKeepAlive(true).setSoReuseAddress(true).build();
PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager();
connManager.setMaxTotal(100);
connManager.setDefaultMaxPerRoute(100);
connManager.setDefaultSocketConfig(socketConfig);
RequestConfig defaultRequestConfig = RequestConfig.custom().setSocketTimeout(2000).setConnectTimeout(100).setConnectionRequestTimeout(3000).setStaleConnectionCheckEnabled(true).build();
CloseableHttpClient httpClient = HttpClients.custom().setDefaultRequestConfig(defaultRequestConfig).setConnectionManager(connManager).build();
final ClientHttpEngine executor;
executor = new ApacheHttpClient43Engine(httpClient);
ResteasyClient client = new ResteasyClientBuilder().httpEngine(executor).build();
final ApacheHttpClient43Resource proxy = client.target("http://127.0.0.1:8080/" + ApacheHttpClient432TestCase.class.getSimpleName()).proxy(ApacheHttpClient43Resource.class);
WebTarget target = client.target("http://127.0.0.1:8080/" + ApacheHttpClient432TestCase.class.getSimpleName() + "/test2");
Response response = target.request().get();
Assert.assertEquals(HttpResponseCodes.SC_OK, response.getStatus());
try {
Response s = proxy.get();
assertEquals(200, s.getStatus());
} catch (ProcessingException e) {
logger.warn("Exception occured." + e);
} finally {
if (response != null) {
response.close();
}
}
}
Aggregations