Search in sources :

Example 11 with ClientRequestFilter

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

the class JAXRSClientIT method invokeWithClientRequestFilters.

// ////////////////////////////////////////////////////////////////////
protected Response invokeWithClientRequestFilters(ClientRequestFilter... filters) {
    Client client = ClientBuilder.newClient();
    for (ClientRequestFilter filter : filters) client.register(filter);
    WebTarget target = client.target("http://nourl/");
    Response response = target.request().buildGet().invoke();
    return response;
}
Also used : ClientRequestFilter(jakarta.ws.rs.client.ClientRequestFilter) Response(jakarta.ws.rs.core.Response) WebTarget(jakarta.ws.rs.client.WebTarget) JAXRSCommonClient(ee.jakarta.tck.ws.rs.common.JAXRSCommonClient) Client(jakarta.ws.rs.client.Client)

Example 12 with ClientRequestFilter

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

the class JAXRSClientIT method invokeWithResponseAndAssertStatus.

protected static void invokeWithResponseAndAssertStatus(Response response, Status status, ContextProvider provider) throws Fault {
    ClientRequestFilter filter = createRequestFilter(response);
    Invocation i = buildInvocation(filter, provider);
    Response r = invoke(i);
    assertStatus(r, status);
}
Also used : ClientRequestFilter(jakarta.ws.rs.client.ClientRequestFilter) Response(jakarta.ws.rs.core.Response) Invocation(jakarta.ws.rs.client.Invocation)

Example 13 with ClientRequestFilter

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

the class JAXRSClientIT method getStatusInfoTest.

/*
   * @testName: getStatusInfoTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:473; JAXRS:JAVADOC:479; JAXRS:JAVADOC:480;
   * 
   * @test_Strategy: Get the status code associated with the response.
   * 
   * ClientResponseFilter.filter
   */
@Test
public void getStatusInfoTest() throws Fault {
    ContextProvider provider = new ContextProvider() {

        @Override
        protected void checkFilterContext(ClientRequestContext requestContext, ClientResponseContext responseContext) throws Fault {
            assertTrue(responseContext.getStatusInfo().getStatusCode() == 222, "unexpected status " + responseContext.getStatusInfo().getStatusCode());
            TestUtil.logMsg("Found expected response status 222");
        }
    };
    Response response = Response.status(222).build();
    ClientRequestFilter filter = createRequestFilter(response);
    Invocation i = buildInvocation(filter, provider);
    Response r = invoke(i);
    assertTrue(r.getStatus() == 222, "unexpected status " + r.getStatus());
}
Also used : ClientRequestContext(jakarta.ws.rs.client.ClientRequestContext) Response(jakarta.ws.rs.core.Response) ClientRequestFilter(jakarta.ws.rs.client.ClientRequestFilter) Invocation(jakarta.ws.rs.client.Invocation) ClientResponseContext(jakarta.ws.rs.client.ClientResponseContext) Test(org.junit.jupiter.api.Test)

Aggregations

ClientRequestFilter (jakarta.ws.rs.client.ClientRequestFilter)13 Response (jakarta.ws.rs.core.Response)11 ClientRequestContext (jakarta.ws.rs.client.ClientRequestContext)10 Test (org.junit.jupiter.api.Test)4 Invocation (jakarta.ws.rs.client.Invocation)3 JAXRSCommonClient (ee.jakarta.tck.ws.rs.common.JAXRSCommonClient)2 Client (jakarta.ws.rs.client.Client)2 ClientResponseContext (jakarta.ws.rs.client.ClientResponseContext)2 WebTarget (jakarta.ws.rs.client.WebTarget)2 StringBean (ee.jakarta.tck.ws.rs.common.provider.StringBean)1 ClientBuilder (jakarta.ws.rs.client.ClientBuilder)1 Link (jakarta.ws.rs.core.Link)1 Builder (jakarta.ws.rs.core.Link.Builder)1 MediaType (jakarta.ws.rs.core.MediaType)1 UriBuilder (jakarta.ws.rs.core.UriBuilder)1 IOException (java.io.IOException)1