Search in sources :

Example 66 with SyncInvoker

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

the class JAXRSClientIT method optionsTest.

// ------------------------------------------------------------------
// ---------------------------OPTIONS--------------------------------
// ------------------------------------------------------------------
/*
   * @testName: optionsTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:575;
   * 
   * @test_Strategy: Invoke HTTP options method for the current request
   * synchronously.
   */
@Test
public void optionsTest() throws Fault {
    SyncInvoker sync = createSyncInvokerForMethod("options");
    Response response = sync.options();
    assertResponseOk(response);
}
Also used : Response(jakarta.ws.rs.core.Response) SyncInvoker(jakarta.ws.rs.client.SyncInvoker) Test(org.junit.jupiter.api.Test)

Example 67 with SyncInvoker

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

the class JAXRSClientIT method getWithStringClassTest.

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

Example 68 with SyncInvoker

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

the class JAXRSClientIT method optionsWithStringThrowsWebApplicationExceptionTest.

/*
   * @testName: optionsWithStringThrowsWebApplicationExceptionTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:577;
   * 
   * @test_Strategy: jakarta.ws.rs.client.SyncInvoker.options( Class ) 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 optionsWithStringThrowsWebApplicationExceptionTest() throws Fault {
    Runnable run = new Runnable() {

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

Example 69 with SyncInvoker

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

the class JAXRSClientIT method methodWithGenericTypeResponseWithEntityThrowsNoWebApplicationExceptionTest.

/*
   * @testName:
   * methodWithGenericTypeResponseWithEntityThrowsNoWebApplicationExceptionTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:572;
   * 
   * @test_Strategy: jakarta.ws.rs.client.SyncInvoker.method(String, 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 methodWithGenericTypeResponseWithEntityThrowsNoWebApplicationExceptionTest() throws Fault {
    for (final String method : ENTITY_METHODS) {
        GenericType<Response> generic = createGeneric(Response.class);
        SyncInvoker sync = createSyncInvokerForMethod(method.toLowerCase() + "notok");
        Entity<String> entity = createEntity(method);
        Response response = sync.method(method, entity, generic);
        assertStatusAndLog(response, Status.NOT_ACCEPTABLE);
    }
}
Also used : Response(jakarta.ws.rs.core.Response) SyncInvoker(jakarta.ws.rs.client.SyncInvoker) Test(org.junit.jupiter.api.Test)

Example 70 with SyncInvoker

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

the class JAXRSClientIT method methodThrowsProcessingExceptionTest.

/*
   * @testName: methodThrowsProcessingExceptionTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:559;
   * 
   * @test_Strategy: jakarta.ws.rs.client.SyncInvoker.method(String) throws
   * ProcessingException in case the invocation failed.
   */
@Test
public void methodThrowsProcessingExceptionTest() throws Fault {
    for (final String method : METHODS) {
        Runnable run = new Runnable() {

            @Override
            public void run() {
                SyncInvoker sync = createSyncInvokerWrongUrl();
                sync.method(method);
            }
        };
        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