Search in sources :

Example 91 with SyncInvoker

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

the class JAXRSClientIT method methodWithStringClassThrowsWebApplicationExceptionTest.

/*
   * @testName: methodWithStringClassThrowsWebApplicationExceptionTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:561;
   * 
   * @test_Strategy: jakarta.ws.rs.client.SyncInvoker.method(String) 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 methodWithStringClassThrowsWebApplicationExceptionTest() throws Fault {
    for (final String method : METHODS) {
        Runnable run = new Runnable() {

            @Override
            public void run() {
                SyncInvoker sync = createSyncInvokerForMethod(method.toLowerCase() + "notok");
                sync.method(method, String.class);
            }
        };
        assertWebApplicationException(run);
    }
}
Also used : SyncInvoker(jakarta.ws.rs.client.SyncInvoker) Test(org.junit.jupiter.api.Test)

Example 92 with SyncInvoker

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

the class JAXRSClientIT method putWithGenericTypeResponseTest.

/*
   * @testName: putWithGenericTypeResponseTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:596;
   * 
   * @test_Strategy: Invoke HTTP put method for the current request
   * synchronously.
   */
@Test
public void putWithGenericTypeResponseTest() throws Fault {
    GenericType<Response> generic = createGeneric(Response.class);
    Entity<String> entity = createEntity("put");
    SyncInvoker sync = createSyncInvokerForMethod("put");
    Response response = sync.put(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 93 with SyncInvoker

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

the class JAXRSClientIT method getWithStringClassThrowsProcessingExceptionTest.

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

        @Override
        public void run() {
            SyncInvoker sync = createSyncInvokerWrongUrl();
            sync.get(String.class);
        }
    };
    assertProcessingException(run);
}
Also used : SyncInvoker(jakarta.ws.rs.client.SyncInvoker) Test(org.junit.jupiter.api.Test)

Example 94 with SyncInvoker

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

the class JAXRSClientIT method methodWithGenericTypeStringThrowsWebApplicationExceptionTest.

/*
   * @testName: methodWithGenericTypeStringThrowsWebApplicationExceptionTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:564;
   * 
   * @test_Strategy: jakarta.ws.rs.client.SyncInvoker.method(GenericType<String>)
   * 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 methodWithGenericTypeStringThrowsWebApplicationExceptionTest() throws Fault {
    final GenericType<String> generic = createGeneric(String.class);
    for (final String method : METHODS) {
        Runnable run = new Runnable() {

            @Override
            public void run() {
                SyncInvoker sync = createSyncInvokerForMethod(method.toLowerCase() + "notok");
                sync.method(method, generic);
            }
        };
        assertWebApplicationException(run);
    }
}
Also used : SyncInvoker(jakarta.ws.rs.client.SyncInvoker) Test(org.junit.jupiter.api.Test)

Example 95 with SyncInvoker

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

the class JAXRSClientIT method putWithResponseClassTest.

/*
   * @testName: putWithResponseClassTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:593;
   * 
   * @test_Strategy: Invoke HTTP put method for the current request
   * synchronously.
   */
@Test
public void putWithResponseClassTest() throws Fault {
    Entity<String> entity = createEntity("put");
    SyncInvoker sync = createSyncInvokerForMethod("put");
    Response response = sync.put(entity, Response.class);
    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