Search in sources :

Example 86 with WebTarget

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);
}
Also used : WebTarget(javax.ws.rs.client.WebTarget) Test(org.junit.Test) JerseyTest(org.glassfish.jersey.test.JerseyTest) RunSeparately(org.glassfish.jersey.test.util.runner.RunSeparately)

Example 87 with WebTarget

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);
}
Also used : WebTarget(javax.ws.rs.client.WebTarget) Test(org.junit.Test) JerseyTest(org.glassfish.jersey.test.JerseyTest) RunSeparately(org.glassfish.jersey.test.util.runner.RunSeparately)

Example 88 with WebTarget

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);
}
Also used : WebTarget(javax.ws.rs.client.WebTarget) JerseyTest(org.glassfish.jersey.test.JerseyTest) Test(org.junit.Test)

Example 89 with WebTarget

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);
}
Also used : WebTarget(javax.ws.rs.client.WebTarget) JerseyTest(org.glassfish.jersey.test.JerseyTest) Test(org.junit.Test)

Example 90 with WebTarget

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));
}
Also used : WebTarget(javax.ws.rs.client.WebTarget) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test) JerseyTest(org.glassfish.jersey.test.JerseyTest)

Aggregations

WebTarget (javax.ws.rs.client.WebTarget)1393 Response (javax.ws.rs.core.Response)712 Test (org.junit.Test)702 Client (javax.ws.rs.client.Client)318 JerseyTest (org.glassfish.jersey.test.JerseyTest)297 Invocation (javax.ws.rs.client.Invocation)106 List (java.util.List)76 ProcessingException (javax.ws.rs.ProcessingException)71 Builder (javax.ws.rs.client.Invocation.Builder)71 ClientBuilder (javax.ws.rs.client.ClientBuilder)69 GenericType (javax.ws.rs.core.GenericType)64 ArrayList (java.util.ArrayList)61 IOException (java.io.IOException)59 Message (com.remswork.project.alice.model.support.Message)58 PulsarAdminException (org.apache.pulsar.client.admin.PulsarAdminException)58 InputStream (java.io.InputStream)52 NamespaceName (org.apache.pulsar.common.naming.NamespaceName)52 ClientConfig (org.glassfish.jersey.client.ClientConfig)52 Form (javax.ws.rs.core.Form)42 MultiPart (org.glassfish.jersey.media.multipart.MultiPart)42