Search in sources :

Example 61 with WebTarget

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

the class GZIPContentEncodingTest method testPost.

@Test
public void testPost() {
    WebTarget r = target();
    byte[] content = new byte[1024 * 1024];
    assertTrue(Arrays.equals(content, r.request().post(Entity.entity(content, MediaType.APPLICATION_OCTET_STREAM_TYPE)).readEntity(byte[].class)));
    Response cr = r.request().post(Entity.entity(content, MediaType.APPLICATION_OCTET_STREAM_TYPE));
    assertTrue(cr.hasEntity());
    cr.close();
}
Also used : Response(javax.ws.rs.core.Response) WebTarget(javax.ws.rs.client.WebTarget) Test(org.junit.Test) JerseyTest(org.glassfish.jersey.test.JerseyTest)

Example 62 with WebTarget

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

Example 63 with WebTarget

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

the class ManagedClientTest method testManagedClient.

/**
     * Test that a connection via managed clients works properly.
     *
     * @throws Exception in case of test failure.
     */
@Test
public void testManagedClient() throws Exception {
    final WebTarget resource = target().path("public").path("{name}");
    Response response;
    response = resource.resolveTemplate("name", "a").request(MediaType.TEXT_PLAIN).get();
    assertEquals(200, response.getStatus());
    assertEquals("a", response.readEntity(String.class));
    response = resource.resolveTemplate("name", "b").request(MediaType.TEXT_PLAIN).get();
    assertEquals(200, response.getStatus());
    assertEquals("b", response.readEntity(String.class));
}
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 64 with WebTarget

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

the class HttpHeadersTest method testPost.

@Test
public void testPost() {
    WebTarget r = target("test");
    Response cr = r.request().header("X-CLIENT", "client").post(Entity.text("POST"));
    assertEquals(200, cr.getStatus());
    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 65 with WebTarget

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

the class HttpMethodTest method testPostNoConsumeProduce.

@Test
public void testPostNoConsumeProduce() {
    WebTarget r = getWebTarget();
    assertEquals(204, r.path("noconsumeproduce").request().post(null).getStatus());
    Response cr = r.path("noconsumeproduce").request().post(Entity.text("POST"));
    assertFalse(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)

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