Search in sources :

Example 51 with WebTarget

use of javax.ws.rs.client.WebTarget in project jersey by jersey.

the class ValidateOnExecutionBasicTest method testOnMethodGetterMatch.

@Test
public void testOnMethodGetterMatch() throws Exception {
    final WebTarget target = target("getter-on-method-match");
    assertThat(target.request().get().getStatus(), equalTo(400));
    assertThat(target.path("sanity").request().get().getStatus(), equalTo(400));
}
Also used : WebTarget(javax.ws.rs.client.WebTarget) Test(org.junit.Test)

Example 52 with WebTarget

use of javax.ws.rs.client.WebTarget in project jersey by jersey.

the class SingletonBeanTest method testGet.

@Test
public void testGet() {
    final WebTarget singleton = target().path("jcdibean/singleton").path(p).queryParam("x", x);
    String s = singleton.request().get(String.class);
    assertThat(s, containsString(singleton.getUri().toString()));
    assertThat(s, containsString(String.format("p=%s", p)));
    assertThat(s, containsString(String.format("queryParam=%s", x)));
}
Also used : WebTarget(javax.ws.rs.client.WebTarget) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 53 with WebTarget

use of javax.ws.rs.client.WebTarget in project jersey by jersey.

the class SingletonBeanTest method testCounter.

@Test
public void testCounter() {
    final WebTarget counter = target().path("jcdibean/singleton").path(p).queryParam("x", x).path("counter");
    if (!ExternalTestContainerFactory.class.isAssignableFrom(getTestContainerFactory().getClass())) {
        // TODO: remove this workaround once JERSEY-2744 is resolved
        counter.request().put(Entity.text("10"));
    }
    String c10 = counter.request().get(String.class);
    assertThat(c10, containsString("10"));
    String c11 = counter.request().get(String.class);
    assertThat(c11, containsString("11"));
    counter.request().put(Entity.text("32"));
    String c32 = counter.request().get(String.class);
    assertThat(c32, containsString("32"));
    counter.request().put(Entity.text("10"));
}
Also used : WebTarget(javax.ws.rs.client.WebTarget) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ExternalTestContainerFactory(org.glassfish.jersey.test.external.ExternalTestContainerFactory) Test(org.junit.Test)

Example 54 with WebTarget

use of javax.ws.rs.client.WebTarget in project jersey by jersey.

the class SingletonDependentBeanTest method testException.

@Test
public void testException() {
    final WebTarget exception = target().path("jcdibean/dependent/singleton").path(p).queryParam("x", x).path("exception");
    assertThat(exception.request().get().readEntity(String.class), containsString("JDCIBeanDependentException"));
}
Also used : WebTarget(javax.ws.rs.client.WebTarget) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 55 with WebTarget

use of javax.ws.rs.client.WebTarget in project jersey by jersey.

the class SingletonDependentBeanTest method testCounter.

@Test
public void testCounter() {
    final WebTarget counter = target().path("jcdibean/dependent/singleton").path(p).queryParam("x", x).path("counter");
    if (!ExternalTestContainerFactory.class.isAssignableFrom(getTestContainerFactory().getClass())) {
        // TODO: remove this workaround once JERSEY-2744 is resolved
        counter.request().put(Entity.text("10"));
    }
    String c10 = counter.request().get(String.class);
    assertThat(c10, containsString("10"));
    String c11 = counter.request().get(String.class);
    assertThat(c11, containsString("11"));
    counter.request().put(Entity.text("32"));
    String c32 = counter.request().get(String.class);
    assertThat(c32, containsString("32"));
    counter.request().put(Entity.text("10"));
}
Also used : WebTarget(javax.ws.rs.client.WebTarget) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ExternalTestContainerFactory(org.glassfish.jersey.test.external.ExternalTestContainerFactory) Test(org.junit.Test)

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