Package org.glassfish.jersey.server

Examples of org.glassfish.jersey.server.ContainerResponse


     */
    @Test
    public void testHeadWithInputStream() throws Exception {
        initiateWebApplication(InputStreamResource.class, InputStreamWriterInterceptor.class);

        final ContainerResponse response = app.apply(RequestContextBuilder.from("/", "HEAD").build()).get();

        assertThat(response.getStatus(), equalTo(200));
        assertThat(InputStreamResource.INPUT_STREAM_CLOSED, is(true));
        assertThat(InputStreamWriterInterceptor.INPUT_STREAM_CLOSED, is(true));
    }
View Full Code Here


        _testListDefault("double", "3.14159265358979");
    }

    @Test
    public void testBadPrimitiveValue() throws ExecutionException, InterruptedException {
        final ContainerResponse responseContext = apply(
                RequestContextBuilder.from("/;int=abcdef", "GET").
                        accept("application/int").
                        build()
        );

        assertEquals(404, responseContext.getStatus());
    }
View Full Code Here

        assertEquals(404, responseContext.getStatus());
    }

    @Test
    public void testBadPrimitiveWrapperValue() throws ExecutionException, InterruptedException {
        final ContainerResponse responseContext = apply(
                RequestContextBuilder.from("/wrappers;int=abcdef", "GET").
                        accept("application/int").
                        build()
        );

        assertEquals(404, responseContext.getStatus());
    }
View Full Code Here

        assertEquals(404, responseContext.getStatus());
    }

    @Test
    public void testBadPrimitiveListValue() throws ExecutionException, InterruptedException {
        final ContainerResponse responseContext = apply(
                RequestContextBuilder.from("/list;int=abcdef;int=abcdef", "GET").
                        accept("application/int").
                        build()
        );

        assertEquals(404, responseContext.getStatus());
    }
View Full Code Here

    @Test
    public void testGetNoHead() throws Exception {
        initiateWebApplication(ResourceGetNoHead.class);

        ContainerResponse response = app.apply(RequestContextBuilder.from("/sub", "HEAD").build()).get();

        assertEquals(200, response.getStatus());
        assertEquals(MediaType.TEXT_PLAIN_TYPE, response.getMediaType());
        assertFalse(response.hasEntity());
    }
View Full Code Here

    @Test
    public void testGetWithHead() throws Exception {
        initiateWebApplication(ResourceGetWithHead.class);

        ContainerResponse response = app.apply(RequestContextBuilder.from("/sub", "HEAD").build()).get();
        assertEquals(200, response.getStatus());
        assertFalse(response.hasEntity());
        assertEquals("HEAD", response.getHeaders().getFirst("X-TEST"));
    }
View Full Code Here

    @Test
    public void testGetWithProduceNoHead() throws Exception {
        initiateWebApplication(ResourceGetWithProduceNoHead.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());

        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());
    }
View Full Code Here

    @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());
    }
View Full Code Here

    @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());
    }
View Full Code Here

                QueryExceptionMapper.class,
                CookieExceptionMapper.class,
                HeaderExceptionMapper.class,
                FormExceptionMapper.class);

        ContainerResponse responseContext = getResponseContext(UriBuilder.fromPath("/").path("path/ 123").build().toString());
        assertEquals("path", responseContext.getEntity());

        responseContext = getResponseContext(UriBuilder.fromPath("/").path("matrix;x= 123").build().toString());
        assertEquals("matrix", responseContext.getEntity());

        responseContext = getResponseContext(UriBuilder.fromPath("/").path("query").queryParam("x", " 123").build().toString());
        assertEquals("query", responseContext.getEntity());

        responseContext = getResponseContext(UriBuilder.fromPath("/").path("cookie").build().toString(), new Cookie("x", " 123"));
        assertEquals("cookie", responseContext.getEntity());

        responseContext = apply(
                RequestContextBuilder.from("/header", "GET").
                        header("x", " 123").
                        build()
        );
        assertEquals("header", responseContext.getEntity());

        Form f = new Form();
        f.param("x", " 123");
        responseContext = apply(
                RequestContextBuilder.from("/form", "POST").
                        type(MediaType.APPLICATION_FORM_URLENCODED_TYPE).
                        entity(f).
                        build()
        );
        assertEquals("form", responseContext.getEntity());
    }
View Full Code Here

TOP

Related Classes of org.glassfish.jersey.server.ContainerResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.