Search in sources :

Example 1 with SyncInvoker

use of javax.ws.rs.client.SyncInvoker in project jersey by jersey.

the class GenericResponseTest method testPost.

@Test
public void testPost() {
    GenericType<Response> generic = new GenericType<Response>(Response.class);
    Entity entity = Entity.entity("entity", MediaType.WILDCARD_TYPE);
    WebTarget target = target("resource");
    SyncInvoker sync = target.request();
    Response response = sync.post(entity, generic);
    Assert.assertEquals(200, response.getStatus());
    Assert.assertEquals("entity", response.readEntity(String.class));
}
Also used : Response(javax.ws.rs.core.Response) Entity(javax.ws.rs.client.Entity) GenericType(javax.ws.rs.core.GenericType) SyncInvoker(javax.ws.rs.client.SyncInvoker) WebTarget(javax.ws.rs.client.WebTarget) Test(org.junit.Test) JerseyTest(org.glassfish.jersey.test.JerseyTest)

Example 2 with SyncInvoker

use of javax.ws.rs.client.SyncInvoker in project jersey by jersey.

the class GenericResponseTest method testGetGenericString.

@Test
public void testGetGenericString() {
    GenericType<String> generic = new GenericType<String>(String.class);
    WebTarget target = target("resource");
    SyncInvoker sync = target.request();
    final String entity = sync.get(generic);
    Assert.assertEquals("get", entity);
}
Also used : GenericType(javax.ws.rs.core.GenericType) SyncInvoker(javax.ws.rs.client.SyncInvoker) WebTarget(javax.ws.rs.client.WebTarget) Test(org.junit.Test) JerseyTest(org.glassfish.jersey.test.JerseyTest)

Example 3 with SyncInvoker

use of javax.ws.rs.client.SyncInvoker in project jersey by jersey.

the class NonSuccessfulResponseTest method generalTestPost.

private void generalTestPost(int status) {
    Entity<String> entity = Entity.entity("entity", MediaType.WILDCARD_TYPE);
    WebTarget target = target("resource").path(Integer.toString(status));
    SyncInvoker sync = target.request();
    Response response = sync.post(entity, Response.class);
    Assert.assertEquals(status, response.getStatus());
    Assert.assertEquals("entity", response.readEntity(String.class));
}
Also used : Response(javax.ws.rs.core.Response) SyncInvoker(javax.ws.rs.client.SyncInvoker) WebTarget(javax.ws.rs.client.WebTarget)

Example 4 with SyncInvoker

use of javax.ws.rs.client.SyncInvoker in project jersey by jersey.

the class NonSuccessfulResponseTest method generalTestGet.

private void generalTestGet(int status) {
    WebTarget target = target("resource").path(Integer.toString(status));
    SyncInvoker sync = target.request();
    Response response = sync.get(Response.class);
    Assert.assertEquals(status, response.getStatus());
    Assert.assertEquals("get", response.readEntity(String.class));
}
Also used : Response(javax.ws.rs.core.Response) SyncInvoker(javax.ws.rs.client.SyncInvoker) WebTarget(javax.ws.rs.client.WebTarget)

Example 5 with SyncInvoker

use of javax.ws.rs.client.SyncInvoker in project jersey by jersey.

the class GenericResponseTest method testGet.

@Test
public void testGet() {
    GenericType<Response> generic = new GenericType<Response>(Response.class);
    WebTarget target = target("resource");
    SyncInvoker sync = target.request();
    Response response = sync.get(generic);
    Assert.assertEquals(200, response.getStatus());
    Assert.assertEquals("get", response.readEntity(String.class));
}
Also used : Response(javax.ws.rs.core.Response) GenericType(javax.ws.rs.core.GenericType) SyncInvoker(javax.ws.rs.client.SyncInvoker) WebTarget(javax.ws.rs.client.WebTarget) Test(org.junit.Test) JerseyTest(org.glassfish.jersey.test.JerseyTest)

Aggregations

SyncInvoker (javax.ws.rs.client.SyncInvoker)5 WebTarget (javax.ws.rs.client.WebTarget)5 Response (javax.ws.rs.core.Response)4 GenericType (javax.ws.rs.core.GenericType)3 JerseyTest (org.glassfish.jersey.test.JerseyTest)3 Test (org.junit.Test)3 Entity (javax.ws.rs.client.Entity)1