Search in sources :

Example 46 with ContainerResponse

use of org.glassfish.jersey.server.ContainerResponse in project jersey by jersey.

the class ResourceInfoTest method testInfoGetChild.

@Test
public void testInfoGetChild() throws ExecutionException, InterruptedException {
    ApplicationHandler handler = getApplication();
    final ContainerResponse response = handler.apply(RequestContextBuilder.from("/info/child", "GET").build()).get();
    assertEquals(200, response.getStatus());
    assertEquals("get-info-child", response.getEntity());
    assertResponseHeaders(response, "ResourceTestingInfo", "getChildInfo");
}
Also used : ContainerResponse(org.glassfish.jersey.server.ContainerResponse) ApplicationHandler(org.glassfish.jersey.server.ApplicationHandler) Test(org.junit.Test)

Example 47 with ContainerResponse

use of org.glassfish.jersey.server.ContainerResponse in project jersey by jersey.

the class ResourceInfoTest method test404.

@Test
public void test404() throws ExecutionException, InterruptedException {
    ApplicationHandler handler = getApplication();
    final ContainerResponse response = handler.apply(RequestContextBuilder.from("/NOT_FOUND", "GET").build()).get();
    assertEquals(404, response.getStatus());
    assertResponseHeaders(response, "<null>", "<null>");
}
Also used : ContainerResponse(org.glassfish.jersey.server.ContainerResponse) ApplicationHandler(org.glassfish.jersey.server.ApplicationHandler) Test(org.junit.Test)

Example 48 with ContainerResponse

use of org.glassfish.jersey.server.ContainerResponse in project jersey by jersey.

the class ResourceInfoTest method testGetSubResource.

@Test
public void testGetSubResource() throws ExecutionException, InterruptedException {
    ApplicationHandler handler = getApplication();
    final ContainerResponse response = handler.apply(RequestContextBuilder.from("/resource/locator", "GET").build()).get();
    assertEquals(200, response.getStatus());
    assertEquals("get-sub-resource", response.getEntity());
    assertResponseHeaders(response, "SubResource", "getFromSubResource");
}
Also used : ContainerResponse(org.glassfish.jersey.server.ContainerResponse) ApplicationHandler(org.glassfish.jersey.server.ApplicationHandler) Test(org.junit.Test)

Example 49 with ContainerResponse

use of org.glassfish.jersey.server.ContainerResponse in project jersey by jersey.

the class ResourceInfoTest method testGetMultiple.

@Test
public void testGetMultiple() throws ExecutionException, InterruptedException {
    ApplicationHandler handler = getApplication();
    ContainerResponse response = handler.apply(RequestContextBuilder.from("/resource", "GET").build()).get();
    assertEquals(200, response.getStatus());
    assertEquals("get", response.getEntity());
    assertResponseHeaders(response, "MyResource", "get");
    response = handler.apply(RequestContextBuilder.from("/resource/get-child", "GET").build()).get();
    assertEquals(200, response.getStatus());
    assertEquals("get-child", response.getEntity());
    assertResponseHeaders(response, "MyResource", "getChild");
}
Also used : ContainerResponse(org.glassfish.jersey.server.ContainerResponse) ApplicationHandler(org.glassfish.jersey.server.ApplicationHandler) Test(org.junit.Test)

Example 50 with ContainerResponse

use of org.glassfish.jersey.server.ContainerResponse in project jersey by jersey.

the class ResourceInfoTest method testGetChild.

@Test
public void testGetChild() throws ExecutionException, InterruptedException {
    ApplicationHandler handler = getApplication();
    final ContainerResponse response = handler.apply(RequestContextBuilder.from("/resource/get-child", "GET").build()).get();
    assertEquals(200, response.getStatus());
    assertEquals("get-child", response.getEntity());
    final String className = "MyResource";
    final String methodName = "getChild";
    assertResponseHeaders(response, className, methodName);
}
Also used : ContainerResponse(org.glassfish.jersey.server.ContainerResponse) ApplicationHandler(org.glassfish.jersey.server.ApplicationHandler) Test(org.junit.Test)

Aggregations

ContainerResponse (org.glassfish.jersey.server.ContainerResponse)211 Test (org.junit.Test)190 ApplicationHandler (org.glassfish.jersey.server.ApplicationHandler)95 ResourceConfig (org.glassfish.jersey.server.ResourceConfig)58 MediaType (javax.ws.rs.core.MediaType)16 Form (javax.ws.rs.core.Form)14 ContainerRequest (org.glassfish.jersey.server.ContainerRequest)14 Cookie (javax.ws.rs.core.Cookie)7 Response (javax.ws.rs.core.Response)5 Ignore (org.junit.Ignore)4 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 ContainerRequestContext (javax.ws.rs.container.ContainerRequestContext)2 ContainerResponseFilter (javax.ws.rs.container.ContainerResponseFilter)2 ContainerException (org.glassfish.jersey.server.ContainerException)2 RequestContextBuilder (org.glassfish.jersey.server.RequestContextBuilder)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 ParameterizedType (java.lang.reflect.ParameterizedType)1 URI (java.net.URI)1 HashSet (java.util.HashSet)1