use of javax.ws.rs.client.WebTarget in project jersey by jersey.
the class HttpMethodTest method testAll.
@Test
public void testAll() {
WebTarget r = getWebTarget();
assertEquals("GET", r.request().get(String.class));
assertEquals("POST", r.request().post(Entity.text("POST"), String.class));
assertEquals(204, r.path("noproduce").request().post(Entity.text("POST")).getStatus());
assertEquals(204, r.path("noconsumeproduce").request().post(null).getStatus());
assertEquals("PUT", r.request().post(Entity.text("PUT"), String.class));
assertEquals("DELETE", r.request().delete(String.class));
}
use of javax.ws.rs.client.WebTarget in project jersey by jersey.
the class HttpMethodTest method testHead.
@Test
public void testHead() {
WebTarget r = getWebTarget();
Response cr = r.request().head();
assertFalse(cr.hasEntity());
}
use of javax.ws.rs.client.WebTarget in project jersey by jersey.
the class HttpMethodTest method testPost.
@Test
public void testPost() {
WebTarget r = getWebTarget();
assertEquals("POST", r.request().post(Entity.text("POST"), String.class));
Response cr = r.request().post(Entity.text("POST"));
assertTrue(cr.hasEntity());
cr.close();
}
use of javax.ws.rs.client.WebTarget in project jersey by jersey.
the class DefaultMethodResourceTest method testDefaultMethods.
/**
* Test that JDK8 default methods do work as common JAX-RS resource methods.
*/
@Test
public void testDefaultMethods() {
final WebTarget defaultMethodTarget = target("default-method");
// test default method with no @Path annotation
String response = defaultMethodTarget.request().get(String.class);
assertEquals("interface-root", response);
// test default method with with @Path annotation
response = defaultMethodTarget.path("path").request().get(String.class);
assertEquals("interface-path", response);
}
use of javax.ws.rs.client.WebTarget in project jersey by jersey.
the class LambdaResourceTest method testLambdas.
/**
* Test that JDK8 lambdas do work in common JAX-RS resource methods.
*/
@Test
public void testLambdas() {
final WebTarget target = target("lambdas/{p}");
// test default method with no @Path annotation
String response = target.resolveTemplate("p", "test").request().get(String.class);
assertThat(response, equalTo("test-lambdaized"));
}
Aggregations