Search in sources :

Example 66 with AsyncInvoker

use of jakarta.ws.rs.client.AsyncInvoker in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method methodWithResponseClassWhileServerWaitTest.

/*
   * @testName: methodWithResponseClassWhileServerWaitTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:386;
   * 
   * @test_Strategy: Invoke an arbitrary method for the current request
   * asynchronously.
   */
@Test
public void methodWithResponseClassWhileServerWaitTest() throws Fault {
    Future<Response> future = null;
    for (String method : METHODS) {
        AsyncInvoker async = startAsyncInvokerForMethod(method.toLowerCase() + "andwait");
        future = async.method(method, Response.class);
        checkFutureOkResponse(future);
    }
// return future;
}
Also used : Response(jakarta.ws.rs.core.Response) AsyncInvoker(jakarta.ws.rs.client.AsyncInvoker) Test(org.junit.jupiter.api.Test)

Example 67 with AsyncInvoker

use of jakarta.ws.rs.client.AsyncInvoker in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method deleteWithResponseClassWhileServerWaitTest.

/*
   * @testName: deleteWithResponseClassWhileServerWaitTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:376;
   * 
   * @test_Strategy: Invoke HTTP DELETE method for the current request
   * asynchronously.
   */
@Test
public void deleteWithResponseClassWhileServerWaitTest() throws Fault {
    AsyncInvoker async = startAsyncInvokerForMethod("deleteandwait");
    Future<Response> future = async.delete(Response.class);
    checkFutureOkResponse(future);
// return future;
}
Also used : Response(jakarta.ws.rs.core.Response) AsyncInvoker(jakarta.ws.rs.client.AsyncInvoker) Test(org.junit.jupiter.api.Test)

Example 68 with AsyncInvoker

use of jakarta.ws.rs.client.AsyncInvoker in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method postWithCallbackThrowsWebApplicationExceptionTest.

/*
   * @testName: postWithCallbackThrowsWebApplicationExceptionTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:400;
   * 
   * @test_Strategy: Note that calling the Future.get() method on the returned
   * Future instance may throw an ExecutionException that wraps a
   * WebApplicationException or one of its subclasses thrown in case the
   * received response status code is not successful and the specified response
   * type is not Response.
   */
@Test
public void postWithCallbackThrowsWebApplicationExceptionTest() throws Fault {
    Entity<String> entity = Entity.entity("post", MediaType.WILDCARD_TYPE);
    InvocationCallback<String> callback = createStringCallback(false);
    AsyncInvoker async = startAsyncInvokerForMethod("postnotok");
    Future<String> future = async.post(entity, callback);
    assertExceptionWithWebApplicationExceptionIsThrownAndLog(future);
}
Also used : AsyncInvoker(jakarta.ws.rs.client.AsyncInvoker) Test(org.junit.jupiter.api.Test)

Example 69 with AsyncInvoker

use of jakarta.ws.rs.client.AsyncInvoker in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method optionsWithCallbackWhileServerWaitTest.

/*
   * @testName: optionsWithCallbackWhileServerWaitTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:396;
   * 
   * @test_Strategy: Invoke HTTP options method for the current request
   * asynchronously.
   */
@Test
public void optionsWithCallbackWhileServerWaitTest() throws Fault {
    AsyncInvoker async = startAsyncInvokerForMethod("optionsandwait");
    InvocationCallback<Response> callback = createCallback(true);
    Future<Response> future = async.options(callback);
    checkFutureOkResponse(future);
    assertCallbackCall();
// return future;
}
Also used : Response(jakarta.ws.rs.core.Response) AsyncInvoker(jakarta.ws.rs.client.AsyncInvoker) Test(org.junit.jupiter.api.Test)

Example 70 with AsyncInvoker

use of jakarta.ws.rs.client.AsyncInvoker in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method postWithGenericTypeThrowsProcessingExceptionTest.

/*
   * @testName: postWithGenericTypeThrowsProcessingExceptionTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:399;
   * 
   * @test_Strategy: Note that calling the Future.get() method on the returned
   * Future instance may throw an ExecutionException that wraps an
   * jakarta.ws.rs.ProcessingException thrown in case of an invocation processing
   * failure.
   */
@Test
public void postWithGenericTypeThrowsProcessingExceptionTest() throws Fault {
    _hostname = NONEXISTING_SITE;
    Entity<String> entity = Entity.entity("post", MediaType.WILDCARD_TYPE);
    GenericType<String> generic = createGeneric(String.class);
    AsyncInvoker async = startAsyncInvokerForMethod("post");
    Future<String> future = async.post(entity, generic);
    assertExceptionWithProcessingExceptionIsThrownAndLog(future);
}
Also used : AsyncInvoker(jakarta.ws.rs.client.AsyncInvoker) Test(org.junit.jupiter.api.Test)

Aggregations

AsyncInvoker (jakarta.ws.rs.client.AsyncInvoker)151 Test (org.junit.jupiter.api.Test)148 Response (jakarta.ws.rs.core.Response)78 Client (jakarta.ws.rs.client.Client)3 WebTarget (jakarta.ws.rs.client.WebTarget)3 JdkLoggingFilter (ee.jakarta.tck.ws.rs.common.client.JdkLoggingFilter)2 Invocation (jakarta.ws.rs.client.Invocation)2 JaxrsCommonClient (ee.jakarta.tck.ws.rs.common.client.JaxrsCommonClient)1 SyncInvoker (jakarta.ws.rs.client.SyncInvoker)1 ThrottledClient (jaxrs.examples.client.custom.ThrottledClient)1