Search in sources :

Example 1 with JerseyWebTarget

use of org.glassfish.jersey.client.JerseyWebTarget in project jersey by jersey.

the class ClientPreInitTest method testReusingPreinitializedConfig.

@Test
public void testReusingPreinitializedConfig() {
    Client client = ClientBuilder.newClient();
    client.register(TestReader.class);
    final WebTarget target = client.target(super.getBaseUri()).path("resource");
    target.register(MyResponseFilter.class);
    ((JerseyWebTarget) target).preInitialize();
    assertTrue(TestReader.initialized);
    final WebTarget childTarget = target.path("child");
    final Response response = childTarget.request().get();
    checkResponse(response, "child:<null>");
    final Response resourceResponse = target.request().get();
    checkResponse(resourceResponse, "resource:<null>");
}
Also used : Response(javax.ws.rs.core.Response) JerseyWebTarget(org.glassfish.jersey.client.JerseyWebTarget) JerseyWebTarget(org.glassfish.jersey.client.JerseyWebTarget) WebTarget(javax.ws.rs.client.WebTarget) Client(javax.ws.rs.client.Client) JerseyClient(org.glassfish.jersey.client.JerseyClient) JerseyTest(org.glassfish.jersey.test.JerseyTest) Test(org.junit.Test)

Example 2 with JerseyWebTarget

use of org.glassfish.jersey.client.JerseyWebTarget in project jersey by jersey.

the class ClientPreInitTest method testRegisterOnPreinitialized1.

@Test
public void testRegisterOnPreinitialized1() {
    Client client = ClientBuilder.newClient();
    final WebTarget target = client.target(super.getBaseUri()).path("resource");
    target.register(MyRequestFilter.class);
    ((JerseyWebTarget) target).preInitialize();
    target.register(MyResponseFilter.class);
    final Response response = target.request().get();
    checkResponse(response, "resource:called");
}
Also used : Response(javax.ws.rs.core.Response) JerseyWebTarget(org.glassfish.jersey.client.JerseyWebTarget) JerseyWebTarget(org.glassfish.jersey.client.JerseyWebTarget) WebTarget(javax.ws.rs.client.WebTarget) Client(javax.ws.rs.client.Client) JerseyClient(org.glassfish.jersey.client.JerseyClient) JerseyTest(org.glassfish.jersey.test.JerseyTest) Test(org.junit.Test)

Example 3 with JerseyWebTarget

use of org.glassfish.jersey.client.JerseyWebTarget in project jersey by jersey.

the class ClientPreInitTest method testRegisterOnPreinitialized2.

@Test
public void testRegisterOnPreinitialized2() {
    Client client = ClientBuilder.newClient();
    final WebTarget target = client.target(super.getBaseUri()).path("resource");
    target.register(MyResponseFilter.class);
    ((JerseyWebTarget) target).preInitialize();
    final WebTarget child = target.path("child");
    child.register(MyRequestFilter.class);
    final Response response = target.request().get();
    checkResponse(response, "resource:<null>");
    final Response childResponse = child.request().get();
    checkResponse(childResponse, "child:called");
}
Also used : Response(javax.ws.rs.core.Response) JerseyWebTarget(org.glassfish.jersey.client.JerseyWebTarget) JerseyWebTarget(org.glassfish.jersey.client.JerseyWebTarget) WebTarget(javax.ws.rs.client.WebTarget) Client(javax.ws.rs.client.Client) JerseyClient(org.glassfish.jersey.client.JerseyClient) JerseyTest(org.glassfish.jersey.test.JerseyTest) Test(org.junit.Test)

Example 4 with JerseyWebTarget

use of org.glassfish.jersey.client.JerseyWebTarget in project jersey by jersey.

the class ClientPreInitTest method testSimplePreinitialize.

@Test
public void testSimplePreinitialize() {
    Client client = ClientBuilder.newClient();
    final WebTarget target = client.target(super.getBaseUri()).path("resource");
    target.register(MyResponseFilter.class);
    final WebTarget childTarget = target.path("child");
    ((JerseyWebTarget) childTarget).preInitialize();
    final Response response = childTarget.request().get();
    checkResponse(response, "child:<null>");
    final Response resourceResponse = target.request().get();
    checkResponse(resourceResponse, "resource:<null>");
}
Also used : Response(javax.ws.rs.core.Response) JerseyWebTarget(org.glassfish.jersey.client.JerseyWebTarget) JerseyWebTarget(org.glassfish.jersey.client.JerseyWebTarget) WebTarget(javax.ws.rs.client.WebTarget) Client(javax.ws.rs.client.Client) JerseyClient(org.glassfish.jersey.client.JerseyClient) JerseyTest(org.glassfish.jersey.test.JerseyTest) Test(org.junit.Test)

Aggregations

Client (javax.ws.rs.client.Client)4 WebTarget (javax.ws.rs.client.WebTarget)4 Response (javax.ws.rs.core.Response)4 JerseyClient (org.glassfish.jersey.client.JerseyClient)4 JerseyWebTarget (org.glassfish.jersey.client.JerseyWebTarget)4 JerseyTest (org.glassfish.jersey.test.JerseyTest)4 Test (org.junit.Test)4