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 ExceptionTest method test500StatusCode.
@Test
public void test500StatusCode() {
startServer(ExceptionResource.class);
Client client = ClientBuilder.newClient();
WebTarget r = client.target(getUri().path("500").build());
assertEquals(500, r.request().get(Response.class).getStatus());
}
use of javax.ws.rs.client.WebTarget in project jersey by jersey.
the class ExceptionTest method test400StatusCode.
@Test
public void test400StatusCode() {
startServer(ExceptionResource.class);
Client client = ClientBuilder.newClient();
WebTarget r = client.target(getUri().path("400").build());
assertEquals(400, r.request().get(Response.class).getStatus());
}
use of javax.ws.rs.client.WebTarget in project jersey by jersey.
the class LifecycleListenerTest method testReload.
@Test
public void testReload() {
final ResourceConfig rc = new ResourceConfig(One.class);
Reloader reloader = new Reloader();
rc.registerInstances(reloader);
startServer(rc);
WebTarget r = ClientBuilder.newClient().target(getUri().path("/").build());
assertEquals("one", r.path("one").request().get(String.class));
assertEquals(404, r.path("two").request().get(Response.class).getStatus());
// add Two resource
reloader.reload(new ResourceConfig(One.class, Two.class));
assertEquals("one", r.path("one").request().get(String.class));
assertEquals("two", r.path("two").request().get(String.class));
}
use of javax.ws.rs.client.WebTarget in project jersey by jersey.
the class NoEntityTest method testGet.
@Test
public void testGet() {
WebTarget r = target("test");
for (int i = 0; i < 5; i++) {
Response cr = r.request().get();
cr.close();
}
}
Aggregations