Search in sources :

Example 26 with ContainerResponse

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

the class DynamicFeatureTest method testPreMatchingFilter.

@Test
public void testPreMatchingFilter() throws Exception {
    final ApplicationHandler application = createApplication(PreMatchingDynamicFeature.class);
    ContainerResponse response;
    response = application.apply(RequestContextBuilder.from("/resource/postmatch", "GET").build()).get();
    assertEquals(200, response.getStatus());
    assertEquals("get", response.getEntity());
}
Also used : ContainerResponse(org.glassfish.jersey.server.ContainerResponse) ApplicationHandler(org.glassfish.jersey.server.ApplicationHandler) Test(org.junit.Test)

Example 27 with ContainerResponse

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

the class DynamicFeatureTest method testSupportedProvidersFeature.

@Test
public void testSupportedProvidersFeature() throws Exception {
    final ApplicationHandler application = createApplication(SupportedProvidersDynamicFeature.class);
    ContainerResponse response;
    response = application.apply(RequestContextBuilder.from("/resource/providers", "POST").entity("get").build()).get();
    assertEquals(200, response.getStatus());
    assertEquals("get", response.getEntity());
    assertEquals("ProviderBall", response.getHeaderString("writer"));
}
Also used : ContainerResponse(org.glassfish.jersey.server.ContainerResponse) ApplicationHandler(org.glassfish.jersey.server.ApplicationHandler) Test(org.junit.Test)

Example 28 with ContainerResponse

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

the class HeadSubResourceMethodTest method testGetWithProduceWithHead.

@Test
public void testGetWithProduceWithHead() throws Exception {
    initiateWebApplication(ResourceGetWithProduceWithHead.class);
    MediaType foo = MediaType.valueOf("application/foo");
    ContainerResponse response = app.apply(RequestContextBuilder.from("/sub", "HEAD").accept(foo).build()).get();
    assertEquals(200, response.getStatus());
    assertFalse(response.hasEntity());
    assertEquals(foo, response.getMediaType());
    assertEquals("FOO-HEAD", response.getHeaders().getFirst("X-TEST").toString());
    MediaType bar = MediaType.valueOf("application/bar");
    response = app.apply(RequestContextBuilder.from("/sub", "HEAD").accept(bar).build()).get();
    assertEquals(200, response.getStatus());
    assertFalse(response.hasEntity());
    assertEquals(bar, response.getMediaType());
    assertEquals("BAR-HEAD", response.getHeaders().getFirst("X-TEST").toString());
}
Also used : ContainerResponse(org.glassfish.jersey.server.ContainerResponse) MediaType(javax.ws.rs.core.MediaType) Test(org.junit.Test)

Example 29 with ContainerResponse

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

the class HeadSubResourceMethodTest method testGetWithProduceNoHeadDifferentSub.

@Test
public void testGetWithProduceNoHeadDifferentSub() throws Exception {
    initiateWebApplication(ResourceGetWithProduceNoHeadDifferentSub.class);
    MediaType foo = MediaType.valueOf("application/foo");
    ContainerResponse response = app.apply(RequestContextBuilder.from("/sub1", "HEAD").accept(foo).build()).get();
    assertEquals(200, response.getStatus());
    assertFalse(response.hasEntity());
    assertEquals(foo, response.getMediaType());
    MediaType bar = MediaType.valueOf("application/bar");
    response = app.apply(RequestContextBuilder.from("/sub2", "HEAD").accept(bar).build()).get();
    assertEquals(200, response.getStatus());
    assertFalse(response.hasEntity());
    assertEquals(bar, response.getMediaType());
}
Also used : ContainerResponse(org.glassfish.jersey.server.ContainerResponse) MediaType(javax.ws.rs.core.MediaType) Test(org.junit.Test)

Example 30 with ContainerResponse

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

the class HeadTest method testResourceXXX.

@Test
public void testResourceXXX() throws Exception {
    initiateWebApplication(ResourceGetWithNoProduces.class);
    ContainerResponse response = app.apply(RequestContextBuilder.from("/", "HEAD").accept("text/plain").build()).get();
    assertEquals(200, response.getStatus());
    assertEquals("text", response.getHeaderString("x-value"));
    response = app.apply(RequestContextBuilder.from("/", "HEAD").accept("text/html").build()).get();
    assertEquals(200, response.getStatus());
    assertEquals("html", response.getHeaderString("x-value"));
}
Also used : ContainerResponse(org.glassfish.jersey.server.ContainerResponse) 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