Search in sources :

Example 1 with AsyncInvoker

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

the class SpecExamples method typeRelationships.

public void typeRelationships() {
    Client client = ClientBuilder.newClient();
    WebTarget uri = client.target("");
    Invocation.Builder builder = uri.request("text/plain");
    SyncInvoker syncInvoker = builder;
    AsyncInvoker asyncInvoker = builder.async();
    Invocation inv = builder.buildGet();
    Response r1 = builder.get();
    Response r2 = syncInvoker.get();
    Response r3 = inv.invoke();
    Future<Response> fr1 = asyncInvoker.get();
    Future<Response> fr2 = inv.submit();
}
Also used : Response(jakarta.ws.rs.core.Response) Invocation(jakarta.ws.rs.client.Invocation) AsyncInvoker(jakarta.ws.rs.client.AsyncInvoker) SyncInvoker(jakarta.ws.rs.client.SyncInvoker) WebTarget(jakarta.ws.rs.client.WebTarget) Client(jakarta.ws.rs.client.Client) ThrottledClient(jaxrs.examples.client.custom.ThrottledClient)

Example 2 with AsyncInvoker

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

the class JAXRSClientIT method postTest.

// ------------------------------------------------------------------
// ---------------------------POST-----------------------------------
// ------------------------------------------------------------------
/*
   * @testName: postTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:397;
   * 
   * @test_Strategy: Invoke HTTP post method for the current request
   * asynchronously.
   */
@Test
public void postTest() throws Fault {
    AsyncInvoker async = startAsyncInvokerForMethod("post");
    Entity<String> entity = Entity.entity("post", MediaType.WILDCARD_TYPE);
    Future<Response> future = async.post(entity);
    checkFutureOkResponseNoTime(future);
// return future;
}
Also used : Response(jakarta.ws.rs.core.Response) AsyncInvoker(jakarta.ws.rs.client.AsyncInvoker) Test(org.junit.jupiter.api.Test)

Example 3 with AsyncInvoker

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

the class JAXRSClientIT method optionsWithResponseClassWhileServerWaitTest.

/*
   * @testName: optionsWithResponseClassWhileServerWaitTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:394;
   * 
   * @test_Strategy: Invoke HTTP options method for the current request
   * asynchronously.
   */
@Test
public void optionsWithResponseClassWhileServerWaitTest() throws Fault {
    AsyncInvoker async = startAsyncInvokerForMethod("optionsandwait");
    Future<Response> future = async.options(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 4 with AsyncInvoker

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

the class JAXRSClientIT method headThrowsProcessingExceptionTest.

/*
   * @testName: headThrowsProcessingExceptionTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:383;
   * 
   * @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 headThrowsProcessingExceptionTest() throws Fault {
    _hostname = NONEXISTING_SITE;
    AsyncInvoker async = startAsyncInvokerForMethod("head");
    Future<Response> future = async.head();
    assertExceptionWithProcessingExceptionIsThrownAndLog(future);
}
Also used : Response(jakarta.ws.rs.core.Response) AsyncInvoker(jakarta.ws.rs.client.AsyncInvoker) Test(org.junit.jupiter.api.Test)

Example 5 with AsyncInvoker

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

the class JAXRSClientIT method getWithCallbackThrowsNoWebApplicationExceptionForResponseTest.

/*
   * @testName: getWithCallbackThrowsNoWebApplicationExceptionForResponseTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:382;
   * 
   * @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 getWithCallbackThrowsNoWebApplicationExceptionForResponseTest() throws Fault {
    AsyncInvoker async = startAsyncInvokerForMethod("getnotok");
    InvocationCallback<Response> callback = createCallback(false);
    Future<Response> future = async.get(callback);
    checkFutureStatusResponseNoTime(future, Status.NOT_ACCEPTABLE);
}
Also used : Response(jakarta.ws.rs.core.Response) 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