Search in sources :

Example 1 with ApacheHttpClient4Resource

use of org.jboss.additional.testsuite.jdkall.present.jaxrs.client.resource.ApacheHttpClient4Resource in project eap-additional-testsuite by jboss-set.

the class ApacheHttpClient43TestCase method testConnectionCleanupProxy.

public void testConnectionCleanupProxy(Class engine) throws Exception {
    final ResteasyClient client = createEngine(engine);
    final ApacheHttpClient4Resource proxy = client.target("http://127.0.0.1:8080/" + ApacheHttpClient43TestCase.class.getSimpleName()).proxy(ApacheHttpClient4Resource.class);
    counter.set(0);
    Thread[] threads = new Thread[3];
    for (int i = 0; i < 3; i++) {
        threads[i] = new Thread() {

            @Override
            public void run() {
                for (int j = 0; j < 10; j++) {
                    String str = proxy.get();
                    Assert.assertEquals("Wrong response", "hello world", str);
                    counter.incrementAndGet();
                }
            }
        };
    }
    for (int i = 0; i < 3; i++) {
        threads[i].start();
    }
    for (int i = 0; i < 3; i++) {
        threads[i].join();
    }
    Assert.assertEquals("Wrong count of requests", 30L, counter.get());
}
Also used : ResteasyClient(org.jboss.resteasy.client.jaxrs.ResteasyClient) ApacheHttpClient4Resource(org.jboss.additional.testsuite.jdkall.present.jaxrs.client.resource.ApacheHttpClient4Resource)

Example 2 with ApacheHttpClient4Resource

use of org.jboss.additional.testsuite.jdkall.present.jaxrs.client.resource.ApacheHttpClient4Resource in project eap-additional-testsuite by jboss-set.

the class ApacheHttpClient43TestCase method testConnectionCleanupErrorGC.

/**
 * This is regression test for RESTEASY-1273
 */
public void testConnectionCleanupErrorGC(Class engine) throws Exception {
    final ResteasyClient client = createEngine(engine);
    final ApacheHttpClient4Resource proxy = client.target("http://127.0.0.1:8080/" + ApacheHttpClient43TestCase.class.getSimpleName()).proxy(ApacheHttpClient4Resource.class);
    counter.set(0);
    Thread[] threads = new Thread[3];
    for (int i = 0; i < 3; i++) {
        threads[i] = new Thread() {

            @Override
            public void run() {
                for (int j = 0; j < 10; j++) {
                    callProxy(proxy);
                    System.gc();
                }
            }
        };
    }
    for (int i = 0; i < 3; i++) {
        threads[i].start();
    }
    for (int i = 0; i < 3; i++) {
        threads[i].join();
    }
    Assert.assertEquals("Wrong count of requests", 30L, counter.get());
}
Also used : ResteasyClient(org.jboss.resteasy.client.jaxrs.ResteasyClient) ApacheHttpClient4Resource(org.jboss.additional.testsuite.jdkall.present.jaxrs.client.resource.ApacheHttpClient4Resource)

Example 3 with ApacheHttpClient4Resource

use of org.jboss.additional.testsuite.jdkall.present.jaxrs.client.resource.ApacheHttpClient4Resource in project eap-additional-testsuite by jboss-set.

the class ApacheHttpClient43TestCase method testConnectionCleanupErrorNoGC.

/**
 * This is regression test for RESTEASY-1273
 */
public void testConnectionCleanupErrorNoGC(Class engine) throws Exception {
    final ResteasyClient client = createEngine(engine);
    final ApacheHttpClient4Resource proxy = client.target("http://127.0.0.1:8080/" + ApacheHttpClient43TestCase.class.getSimpleName()).proxy(ApacheHttpClient4Resource.class);
    counter.set(0);
    Thread[] threads = new Thread[3];
    for (int i = 0; i < 3; i++) {
        threads[i] = new Thread() {

            @Override
            public void run() {
                for (int j = 0; j < 10; j++) {
                    try {
                        proxy.error();
                    } catch (NotFoundException e) {
                        Assert.assertEquals(e.getResponse().getStatus(), 404);
                        e.getResponse().close();
                        counter.incrementAndGet();
                    }
                }
            }
        };
    }
    for (int i = 0; i < 3; i++) {
        threads[i].start();
    }
    for (int i = 0; i < 3; i++) {
        threads[i].join();
    }
    Assert.assertEquals("Wrong count of requests", 30L, counter.get());
}
Also used : ResteasyClient(org.jboss.resteasy.client.jaxrs.ResteasyClient) NotFoundException(javax.ws.rs.NotFoundException) ApacheHttpClient4Resource(org.jboss.additional.testsuite.jdkall.present.jaxrs.client.resource.ApacheHttpClient4Resource)

Example 4 with ApacheHttpClient4Resource

use of org.jboss.additional.testsuite.jdkall.present.jaxrs.client.resource.ApacheHttpClient4Resource in project eap-additional-testsuite by jboss-set.

the class ApacheHttpClient43TestCase method testConnectionWithRequestBody.

public void testConnectionWithRequestBody(Class engine) throws InterruptedException {
    final ResteasyClient client = createEngine(engine);
    final ApacheHttpClient4Resource proxy = client.target("http://127.0.0.1:8080/" + ApacheHttpClient43TestCase.class.getSimpleName()).proxy(ApacheHttpClient4Resource.class);
    counter.set(0);
    Thread[] threads = new Thread[3];
    for (int i = 0; i < 3; i++) {
        threads[i] = new Thread() {

            @Override
            public void run() {
                for (int j = 0; j < 10; j++) {
                    String res = proxy.getData(String.valueOf(j));
                    Assert.assertNotNull("Response should not be null", res);
                    counter.incrementAndGet();
                }
            }
        };
    }
    for (int i = 0; i < 3; i++) {
        threads[i].start();
    }
    for (int i = 0; i < 3; i++) {
        threads[i].join();
    }
    Assert.assertEquals("Wrong count of requests", 30L, counter.get());
}
Also used : ResteasyClient(org.jboss.resteasy.client.jaxrs.ResteasyClient) ApacheHttpClient4Resource(org.jboss.additional.testsuite.jdkall.present.jaxrs.client.resource.ApacheHttpClient4Resource)

Aggregations

ApacheHttpClient4Resource (org.jboss.additional.testsuite.jdkall.present.jaxrs.client.resource.ApacheHttpClient4Resource)4 ResteasyClient (org.jboss.resteasy.client.jaxrs.ResteasyClient)4 NotFoundException (javax.ws.rs.NotFoundException)1