use of javax.ws.rs.client.WebTarget in project jersey by jersey.
the class GZIPContentEncodingTest method testPost.
@Test
public void testPost() {
WebTarget r = target();
byte[] content = new byte[1024 * 1024];
assertTrue(Arrays.equals(content, r.request().post(Entity.entity(content, MediaType.APPLICATION_OCTET_STREAM_TYPE)).readEntity(byte[].class)));
Response cr = r.request().post(Entity.entity(content, MediaType.APPLICATION_OCTET_STREAM_TYPE));
assertTrue(cr.hasEntity());
cr.close();
}
use of javax.ws.rs.client.WebTarget in project jersey by jersey.
the class HelloWorldTest method testLoggingFilterTargetClass.
@Test
public void testLoggingFilterTargetClass() {
WebTarget target = target().path(ROOT_PATH);
target.register(CustomLoggingFilter.class).property("foo", "bar");
CustomLoggingFilter.preFilterCalled = CustomLoggingFilter.postFilterCalled = 0;
String s = target.request().get(String.class);
assertEquals(HelloWorldResource.CLICHED_MESSAGE, s);
assertEquals(1, CustomLoggingFilter.preFilterCalled);
assertEquals(1, CustomLoggingFilter.postFilterCalled);
}
use of javax.ws.rs.client.WebTarget in project jersey by jersey.
the class ManagedClientTest method testManagedClient.
/**
* Test that a connection via managed clients works properly.
*
* @throws Exception in case of test failure.
*/
@Test
public void testManagedClient() throws Exception {
final WebTarget resource = target().path("public").path("{name}");
Response response;
response = resource.resolveTemplate("name", "a").request(MediaType.TEXT_PLAIN).get();
assertEquals(200, response.getStatus());
assertEquals("a", response.readEntity(String.class));
response = resource.resolveTemplate("name", "b").request(MediaType.TEXT_PLAIN).get();
assertEquals(200, response.getStatus());
assertEquals("b", response.readEntity(String.class));
}
use of javax.ws.rs.client.WebTarget in project jersey by jersey.
the class HttpHeadersTest method testPost.
@Test
public void testPost() {
WebTarget r = target("test");
Response cr = r.request().header("X-CLIENT", "client").post(Entity.text("POST"));
assertEquals(200, cr.getStatus());
assertTrue(cr.hasEntity());
cr.close();
}
use of javax.ws.rs.client.WebTarget in project jersey by jersey.
the class HttpMethodTest method testPostNoConsumeProduce.
@Test
public void testPostNoConsumeProduce() {
WebTarget r = getWebTarget();
assertEquals(204, r.path("noconsumeproduce").request().post(null).getStatus());
Response cr = r.path("noconsumeproduce").request().post(Entity.text("POST"));
assertFalse(cr.hasEntity());
cr.close();
}
Aggregations