Search in sources :

Example 31 with Response

use of javax.ws.rs.core.Response in project jersey by jersey.

the class EventListenerTest method testExceptionProcessing.

@Test
public void testExceptionProcessing() {
    final Response response = target().path("resource/locator/exception").request().get();
    assertEquals(200, response.getStatus());
    assertEquals("mapped", response.readEntity(String.class));
    int i = 1;
    System.out.println(response.getHeaders());
    assertEquals("[" + i++ + "]", response.getHeaderString("R.MATCHED_LOCATOR.order"));
    assertEquals("[" + i++ + "]", response.getHeaderString("R.MATCHED_SUB_RESOURCE.order"));
    assertEquals("[" + i++ + "]", response.getHeaderString("R.REQ_FILTERS_START.order"));
    assertEquals("[" + i++ + "]", response.getHeaderString("R.REQ_FILTERS_FINISHED.order"));
    assertEquals("[" + i++ + "]", response.getHeaderString("R.RESOURCE_METHOD_START.order"));
    assertEquals("[" + i++ + "]", response.getHeaderString("R.RESOURCE_METHOD_FINISHED.order"));
    assertEquals("[" + i++ + "]", response.getHeaderString("R.EXCEPTION_MAPPER_FOUND.order"));
    assertEquals("[" + i++ + "]", response.getHeaderString("R.RESP_FILTERS_START.order"));
    assertEquals("[" + i + "]", response.getHeaderString("R.RESP_FILTERS_FINISHED.order"));
}
Also used : AsyncResponse(javax.ws.rs.container.AsyncResponse) Response(javax.ws.rs.core.Response) JerseyTest(org.glassfish.jersey.test.JerseyTest) Test(org.junit.Test)

Example 32 with Response

use of javax.ws.rs.core.Response in project jersey by jersey.

the class MonitoringStatisticsLocatorTest method testResourceClassStatisticsWadlOptions.

@Test
public void testResourceClassStatisticsWadlOptions() {
    final Response response = target().path("resource/resourceClassStatisticsWadlOptionsTest").request().get();
    assertEquals(200, response.getStatus());
    assertEquals("OK", response.readEntity(String.class));
}
Also used : Response(javax.ws.rs.core.Response) Test(org.junit.Test) JerseyTest(org.glassfish.jersey.test.JerseyTest)

Example 33 with Response

use of javax.ws.rs.core.Response in project jersey by jersey.

the class MonitoringStatisticsLocatorTest method testUriStatisticsAnotherHello.

@Test
public void testUriStatisticsAnotherHello() throws InterruptedException {
    Response response = target().path("another/hello").request().get();
    assertEquals(200, response.getStatus());
    assertEquals("Hello, again.", response.readEntity(String.class));
    Thread.sleep(600);
    response = target().path("resource/uriStatisticsAnotherHelloTest").request().get();
    assertEquals(200, response.getStatus());
    assertEquals("OK", response.readEntity(String.class));
}
Also used : Response(javax.ws.rs.core.Response) Test(org.junit.Test) JerseyTest(org.glassfish.jersey.test.JerseyTest)

Example 34 with Response

use of javax.ws.rs.core.Response in project jersey by jersey.

the class MonitoringStatisticsLocatorTest method test.

@Test
public void test() throws InterruptedException {
    Response response = target().path("resource").request().get();
    assertEquals(200, response.getStatus());
    assertEquals("null", response.readEntity(String.class));
    response = target().path("resource/resource-locator").request().get();
    assertEquals(200, response.getStatus());
    assertEquals("get", response.readEntity(String.class));
    response = target().path("resource/resource-locator").request().get();
    assertEquals(200, response.getStatus());
    assertEquals("get", response.readEntity(String.class));
    response = target().path("resource/resource-locator/sub").request().get();
    assertEquals(200, response.getStatus());
    assertEquals("get", response.readEntity(String.class));
    response = target().path("resource/hello").request().get();
    assertEquals(200, response.getStatus());
    assertEquals("Hello!", response.readEntity(String.class));
    response = target().path("another/hello").request().get();
    assertEquals(200, response.getStatus());
    assertEquals("Hello, again.", response.readEntity(String.class));
    response = target().path("another/xml").request().get();
    assertEquals(200, response.getStatus());
    assertEquals("<?xml version=\"1.0\"?><hello>World!</hello>", response.readEntity(String.class));
    Thread.sleep(600);
    response = target().path("resource").request().get();
    assertEquals(200, response.getStatus());
    assertEquals("getFound", response.readEntity(String.class));
    response = target().path("resource/uri").request().get();
    assertEquals(200, response.getStatus());
    assertEquals("getFound", response.readEntity(String.class));
}
Also used : Response(javax.ws.rs.core.Response) Test(org.junit.Test) JerseyTest(org.glassfish.jersey.test.JerseyTest)

Example 35 with Response

use of javax.ws.rs.core.Response in project jersey by jersey.

the class MonitoringStatisticsLocatorTest method testResourceClassStatisticsGenericOptions.

@Test
public void testResourceClassStatisticsGenericOptions() {
    final Response response = target().path("resource/resourceClassStatisticsGenericOptionsTest").request().get();
    assertEquals(200, response.getStatus());
    assertEquals("OK", response.readEntity(String.class));
}
Also used : Response(javax.ws.rs.core.Response) Test(org.junit.Test) JerseyTest(org.glassfish.jersey.test.JerseyTest)

Aggregations

Response (javax.ws.rs.core.Response)10205 Test (org.junit.Test)5764 Test (org.testng.annotations.Test)1113 JerseyTest (org.glassfish.jersey.test.JerseyTest)870 Test (org.junit.jupiter.api.Test)701 WebTarget (javax.ws.rs.client.WebTarget)668 Builder (javax.ws.rs.client.Invocation.Builder)638 WebClient (org.apache.cxf.jaxrs.client.WebClient)620 DBUnitTest (org.orcid.test.DBUnitTest)611 ResteasyClientBuilder (org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder)577 Parameters (org.testng.annotations.Parameters)537 URI (java.net.URI)515 HashMap (java.util.HashMap)508 Path (javax.ws.rs.Path)506 List (java.util.List)465 ArrayList (java.util.ArrayList)419 Produces (javax.ws.rs.Produces)396 IOException (java.io.IOException)393 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)354 GET (javax.ws.rs.GET)348