Search in sources :

Example 76 with ContainerResponse

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

the class CookieParamAsPrimitiveTest method testBadPrimitiveWrapperValue.

@Test
public void testBadPrimitiveWrapperValue() throws ExecutionException, InterruptedException {
    final ContainerResponse responseContext = apply(RequestContextBuilder.from("/wrappers", "GET").accept("application/int").cookie(new Cookie("int", "abcdef")).build());
    assertEquals(400, responseContext.getStatus());
}
Also used : Cookie(javax.ws.rs.core.Cookie) ContainerResponse(org.glassfish.jersey.server.ContainerResponse) Test(org.junit.Test)

Example 77 with ContainerResponse

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

the class CookieParamAsStringTest method testStringPost.

@Test
public void testStringPost() throws ExecutionException, InterruptedException {
    initiateWebApplication(ResourceString.class);
    final ContainerResponse responseContext = apply(RequestContextBuilder.from("/", "POST").cookie(new Cookie("arg1", "a")).cookie(new Cookie("arg2", "b")).cookie(new Cookie("arg3", "c")).entity("content").build());
    assertEquals("content", responseContext.getEntity());
}
Also used : Cookie(javax.ws.rs.core.Cookie) ContainerResponse(org.glassfish.jersey.server.ContainerResponse) Test(org.junit.Test)

Example 78 with ContainerResponse

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

the class CsrfProtectionFilterTest method testGetWithHeader.

@Test
public void testGetWithHeader() throws Exception {
    ContainerResponse response = handler.apply(RequestContextBuilder.from("", "/resource", "GET").header(CsrfProtectionFilter.HEADER_NAME, "").build()).get();
    assertEquals("GET", response.getEntity());
}
Also used : ContainerResponse(org.glassfish.jersey.server.ContainerResponse) Test(org.junit.Test)

Example 79 with ContainerResponse

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

the class CsrfProtectionFilterTest method testGetNoHeader.

@Test
public void testGetNoHeader() throws Exception {
    ContainerResponse response = handler.apply(RequestContextBuilder.from("", "/resource", "GET").build()).get();
    assertEquals("GET", response.getEntity());
}
Also used : ContainerResponse(org.glassfish.jersey.server.ContainerResponse) Test(org.junit.Test)

Example 80 with ContainerResponse

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

the class EncodingFilterTest method testNoEntity.

@Test
public void testNoEntity() throws IOException {
    EncodingFilter filter = initializeAndGetFilter();
    ContainerRequest request = RequestContextBuilder.from("/resource", "GET").header(HttpHeaders.ACCEPT_ENCODING, "gzip").build();
    ContainerResponse response = new ContainerResponse(request, Response.ok().build());
    filter.filter(request, response);
    assertNull(response.getHeaders().getFirst(HttpHeaders.CONTENT_ENCODING));
    assertNull(response.getHeaders().getFirst(HttpHeaders.VARY));
}
Also used : ContainerResponse(org.glassfish.jersey.server.ContainerResponse) ContainerRequest(org.glassfish.jersey.server.ContainerRequest) 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