Search in sources :

Example 6 with AsyncInvoker

use of javax.ws.rs.client.AsyncInvoker in project jersey by jersey.

the class ClientInvocationTest method testMultipleAsyncInvokerCallsAsGenericTypeWithEntity.

@Test
public void testMultipleAsyncInvokerCallsAsGenericTypeWithEntity() throws Exception {
    final AsyncInvoker request = target().request().async();
    for (int i = 0; i < INVOCATIONS; i++) {
        final String entity = "Message: " + i;
        assertThat(request.post(Entity.text(entity), new GenericType<String>() {
        }).get(), is(entity));
    }
}
Also used : AsyncInvoker(javax.ws.rs.client.AsyncInvoker) Test(org.junit.Test) JerseyTest(org.glassfish.jersey.test.JerseyTest)

Example 7 with AsyncInvoker

use of javax.ws.rs.client.AsyncInvoker in project jersey by jersey.

the class ClientInvocationTest method testMultipleAsyncInvokerCallsAsStringWithEntity.

@Test
public void testMultipleAsyncInvokerCallsAsStringWithEntity() throws Exception {
    final AsyncInvoker request = target().request().async();
    for (int i = 0; i < INVOCATIONS; i++) {
        final String entity = "Message: " + i;
        assertThat(request.post(Entity.text(entity), String.class).get(), is(entity));
    }
}
Also used : AsyncInvoker(javax.ws.rs.client.AsyncInvoker) Test(org.junit.Test) JerseyTest(org.glassfish.jersey.test.JerseyTest)

Example 8 with AsyncInvoker

use of javax.ws.rs.client.AsyncInvoker in project jersey by jersey.

the class ClientInvocationTest method testMultipleAsyncInvokerCallsWithEntity.

@Test
public void testMultipleAsyncInvokerCallsWithEntity() throws Exception {
    final AsyncInvoker request = target().request().async();
    for (int i = 0; i < INVOCATIONS; i++) {
        final String entity = "Message: " + i;
        assertThat(request.post(Entity.text(entity)).get().readEntity(String.class), is(entity));
    }
}
Also used : AsyncInvoker(javax.ws.rs.client.AsyncInvoker) Test(org.junit.Test) JerseyTest(org.glassfish.jersey.test.JerseyTest)

Example 9 with AsyncInvoker

use of javax.ws.rs.client.AsyncInvoker in project jersey by jersey.

the class RequestHeaderModificationsTest method testWarningLoggedAsync.

@Test
public void testWarningLoggedAsync() throws Exception {
    AsyncInvoker asyncInvoker = requestBuilder().async();
    Future<Response> responseFuture = asyncInvoker.post(requestEntity());
    Response response = responseFuture.get();
    assertResponse(response);
}
Also used : Response(javax.ws.rs.core.Response) AsyncInvoker(javax.ws.rs.client.AsyncInvoker) JerseyTest(org.glassfish.jersey.test.JerseyTest) Test(org.junit.Test)

Aggregations

AsyncInvoker (javax.ws.rs.client.AsyncInvoker)9 Test (org.junit.Test)8 JerseyTest (org.glassfish.jersey.test.JerseyTest)7 Response (javax.ws.rs.core.Response)4 ExecutionException (java.util.concurrent.ExecutionException)2 WebTarget (javax.ws.rs.client.WebTarget)2 GenericType (javax.ws.rs.core.GenericType)2 ArrayList (java.util.ArrayList)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ProcessingException (javax.ws.rs.ProcessingException)1 Entity (javax.ws.rs.client.Entity)1 ClientConfig (org.glassfish.jersey.client.ClientConfig)1 Ignore (org.junit.Ignore)1