use of javax.ws.rs.client.WebTarget in project jersey by jersey.
the class HelloWorldTest method testLoggingFilterTargetClass.
@Test
@RunSeparately
public void testLoggingFilterTargetClass() {
WebTarget target = target().path(App.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 HelloWorldTest method testLoggingFilterTargetInstance.
@Test
@RunSeparately
public void testLoggingFilterTargetInstance() {
WebTarget target = target().path(App.ROOT_PATH);
target.register(new CustomLoggingFilter()).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 JsonWithPaddingTest method testGetOnLatestChangeXMLFormat.
/**
* Test check GET on the "changes" resource in "application/xml" format.
*/
@Test
public void testGetOnLatestChangeXMLFormat() {
WebTarget target = target();
ChangeRecordBean lastChange = target.path("changes/latest").request("application/xml").get(ChangeRecordBean.class);
assertEquals(1, lastChange.linesChanged);
}
use of javax.ws.rs.client.WebTarget in project jersey by jersey.
the class JsonWithPaddingTest method testApplicationWadl.
/**
* Test checks that the application.wadl is reachable.
* <p/>
*/
@Test
public void testApplicationWadl() {
WebTarget target = target();
String applicationWadl = target.path("application.wadl").request().get(String.class);
assertTrue("Something wrong. Returned wadl length is not > 0", applicationWadl.length() > 0);
}
use of javax.ws.rs.client.WebTarget in project jersey by jersey.
the class ManagedBeanWebAppTest method testWidget.
/**
* Test the JPA backend.
*/
@Test
public void testWidget() {
WebTarget target = target().path("managedbean/singleton/widget");
final WebTarget widget = target.path("1");
assertThat(widget.request().get().getStatus(), is(404));
widget.request().put(Entity.text("One"));
assertThat(widget.request().get(String.class), is("One"));
widget.request().put(Entity.text("Two"));
assertThat(widget.request().get(String.class), is("Two"));
assertThat(widget.request().delete().getStatus(), is(204));
assertThat(widget.request().get().getStatus(), is(404));
}
Aggregations