Search in sources :

Example 66 with WebTarget

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

Example 67 with WebTarget

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

Example 68 with WebTarget

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

Example 69 with WebTarget

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

Example 70 with WebTarget

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