Search in sources :

Example 61 with SyncInvoker

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

the class JAXRSClientIT method methodWithStringClassWithEntityTest.

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

Example 62 with SyncInvoker

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

the class JAXRSClientIT method postWithStringClassTest.

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

Example 63 with SyncInvoker

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

the class JAXRSClientIT method traceWithGenericTypeStringThrowsWebApplicationExceptionTest.

/*
   * @testName: traceWithGenericTypeStringThrowsWebApplicationExceptionTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:604;
   * 
   * @test_Strategy: jakarta.ws.rs.client.SyncInvoker.trace( Entity, 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 traceWithGenericTypeStringThrowsWebApplicationExceptionTest() throws Fault {
    Runnable run = new Runnable() {

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

Example 64 with SyncInvoker

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

the class JAXRSClientIT method createSyncInvokerForMethod.

/**
 * Create SyncInvoker for given resource method and start time
 */
protected SyncInvoker createSyncInvokerForMethod(String methodName) {
    Client client = ClientBuilder.newClient();
    client.register(new JdkLoggingFilter(false));
    WebTarget target = client.target(getUrl(methodName));
    SyncInvoker sync = target.request();
    return sync;
}
Also used : JdkLoggingFilter(ee.jakarta.tck.ws.rs.common.client.JdkLoggingFilter) SyncInvoker(jakarta.ws.rs.client.SyncInvoker) WebTarget(jakarta.ws.rs.client.WebTarget) JaxrsCommonClient(ee.jakarta.tck.ws.rs.common.client.JaxrsCommonClient) Client(jakarta.ws.rs.client.Client)

Example 65 with SyncInvoker

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

the class JAXRSClientIT method traceWithStringClassThrowsProcessingExceptionTest.

/*
   * @testName: traceWithStringClassThrowsProcessingExceptionTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:601;
   * 
   * @test_Strategy: jakarta.ws.rs.client.SyncInvoker.trace( Entity, Class )
   * throws ProcessingException in case the invocation failed.
   */
@Test
public void traceWithStringClassThrowsProcessingExceptionTest() throws Fault {
    Runnable run = new Runnable() {

        @Override
        public void run() {
            SyncInvoker sync = createSyncInvokerWrongUrl();
            sync.trace(String.class);
        }
    };
    assertProcessingException(run);
}
Also used : 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