Search in sources :

Example 1 with SyncInvoker

use of jakarta.ws.rs.client.SyncInvoker 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 SyncInvoker

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

the class JAXRSClientIT method optionsWithGenericTypeStringThrowsWebApplicationExceptionTest.

/*
   * @testName: optionsWithGenericTypeStringThrowsWebApplicationExceptionTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:580;
   * 
   * @test_Strategy: jakarta.ws.rs.client.SyncInvoker.options( GenericType )
   * throws WebApplicationException - in case the response status code of the
   * response returned by the server is not successful and the specified
   * response type is not Response.
   */
@Test
public void optionsWithGenericTypeStringThrowsWebApplicationExceptionTest() throws Fault {
    Runnable run = new Runnable() {

        @Override
        public void run() {
            SyncInvoker sync = createSyncInvokerForMethod("optionsnotok");
            GenericType<String> generic = createGeneric(String.class);
            sync.options(generic);
        }
    };
    assertWebApplicationException(run);
}
Also used : SyncInvoker(jakarta.ws.rs.client.SyncInvoker) Test(org.junit.jupiter.api.Test)

Example 3 with SyncInvoker

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

the class JAXRSClientIT method methodWithGenericTypeResponseWithEntityTest.

/*
   * @testName: methodWithGenericTypeResponseWithEntityTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:572;
   * 
   * @test_Strategy: Invoke an arbitrary method for the current request
   * synchronously.
   */
@Test
public void methodWithGenericTypeResponseWithEntityTest() throws Fault {
    Response response = null;
    for (String method : ENTITY_METHODS) {
        GenericType<Response> generic = createGeneric(Response.class);
        SyncInvoker sync = createSyncInvokerForMethod(method.toLowerCase());
        Entity<String> entity = createEntity(method.toLowerCase());
        response = sync.method(method, entity, generic);
        assertResponseOk(response);
    }
}
Also used : Response(jakarta.ws.rs.core.Response) SyncInvoker(jakarta.ws.rs.client.SyncInvoker) Test(org.junit.jupiter.api.Test)

Example 4 with SyncInvoker

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

the class JAXRSClientIT method methodWithGenericTypeStringWithEntityTest.

/*
   * @testName: methodWithGenericTypeStringWithEntityTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:572;
   * 
   * @test_Strategy: Invoke an arbitrary method for the current request
   * synchronously.
   */
@Test
public void methodWithGenericTypeStringWithEntityTest() throws Fault {
    String response = null;
    for (String method : ENTITY_METHODS) {
        GenericType<String> generic = createGeneric(String.class);
        SyncInvoker sync = createSyncInvokerForMethod(method.toLowerCase());
        Entity<String> entity = createEntity(method.toLowerCase());
        response = sync.method(method, entity, generic);
        assertResponseString(response, method.toLowerCase());
    }
}
Also used : SyncInvoker(jakarta.ws.rs.client.SyncInvoker) Test(org.junit.jupiter.api.Test)

Example 5 with SyncInvoker

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

the class JAXRSClientIT method postTest.

// ------------------------------------------------------------------
// ---------------------------POST-----------------------------------
// ------------------------------------------------------------------
/*
   * @testName: postTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:583;
   * 
   * @test_Strategy: Invoke HTTP post method for the current request
   * synchronously.
   */
@Test
public void postTest() throws Fault {
    SyncInvoker sync = createSyncInvokerForMethod("post");
    Entity<String> entity = createEntity("post");
    Response response = sync.post(entity);
    assertResponseOk(response);
}
Also used : Response(jakarta.ws.rs.core.Response) SyncInvoker(jakarta.ws.rs.client.SyncInvoker) Test(org.junit.jupiter.api.Test)

Aggregations

SyncInvoker (jakarta.ws.rs.client.SyncInvoker)100 Test (org.junit.jupiter.api.Test)98 Response (jakarta.ws.rs.core.Response)41 Client (jakarta.ws.rs.client.Client)2 WebTarget (jakarta.ws.rs.client.WebTarget)2 JaxrsCommonClient (ee.jakarta.tck.ws.rs.common.client.JaxrsCommonClient)1 JdkLoggingFilter (ee.jakarta.tck.ws.rs.common.client.JdkLoggingFilter)1 AsyncInvoker (jakarta.ws.rs.client.AsyncInvoker)1 Invocation (jakarta.ws.rs.client.Invocation)1 Status (jakarta.ws.rs.core.Response.Status)1 ThrottledClient (jaxrs.examples.client.custom.ThrottledClient)1