Package org.glassfish.jersey.server

Examples of org.glassfish.jersey.server.ApplicationHandler.apply()



        ContainerResponse response;
        // making sure the JVM optimization does not swap the order of the calls.
        synchronized (this) {
            app.apply(RequestContextBuilder.from("/", "POST").entity("Foo").build());
            response = responseFuture.get();
        }

        assertTrue("Status: " + response.getStatus(), response.getStatus() < 300);
        assertEquals("Foo", response.getEntity());
View Full Code Here


    @Test
    public void testAcceptGet() throws Exception {
        ApplicationHandler app = createApplication(Resource.class);

        String s = (String) app.apply(RequestContextBuilder.from("/", "GET").accept("application/foo").build()).get().getEntity();
        assertEquals("foo", s);

        s = (String) app.apply(RequestContextBuilder.from("/", "GET").accept("application/foo;q=0.1").build()).get().getEntity();
        assertEquals("foo", s);
View Full Code Here

        ApplicationHandler app = createApplication(Resource.class);

        String s = (String) app.apply(RequestContextBuilder.from("/", "GET").accept("application/foo").build()).get().getEntity();
        assertEquals("foo", s);

        s = (String) app.apply(RequestContextBuilder.from("/", "GET").accept("application/foo;q=0.1").build()).get().getEntity();
        assertEquals("foo", s);

        s = (String) app.apply(RequestContextBuilder.from("/", "GET").accept("application/foo", "application/bar;q=0.4", "application/baz;q=0.2").build())
                .get().getEntity();
        assertEquals("foo", s);
View Full Code Here

        assertEquals("foo", s);

        s = (String) app.apply(RequestContextBuilder.from("/", "GET").accept("application/foo;q=0.1").build()).get().getEntity();
        assertEquals("foo", s);

        s = (String) app.apply(RequestContextBuilder.from("/", "GET").accept("application/foo", "application/bar;q=0.4", "application/baz;q=0.2").build())
                .get().getEntity();
        assertEquals("foo", s);

        s = (String) app.apply(RequestContextBuilder.from("/", "GET").accept("application/foo;q=0.4", "application/bar", "application/baz;q=0.2").build())
                .get().getEntity();
View Full Code Here

        s = (String) app.apply(RequestContextBuilder.from("/", "GET").accept("application/foo", "application/bar;q=0.4", "application/baz;q=0.2").build())
                .get().getEntity();
        assertEquals("foo", s);

        s = (String) app.apply(RequestContextBuilder.from("/", "GET").accept("application/foo;q=0.4", "application/bar", "application/baz;q=0.2").build())
                .get().getEntity();
        assertEquals("bar", s);

        s = (String) app.apply(RequestContextBuilder.from("/", "GET").accept("application/foo;q=0.4", "application/bar;q=0.2", "application/baz").build())
                .get().getEntity();
View Full Code Here

        s = (String) app.apply(RequestContextBuilder.from("/", "GET").accept("application/foo;q=0.4", "application/bar", "application/baz;q=0.2").build())
                .get().getEntity();
        assertEquals("bar", s);

        s = (String) app.apply(RequestContextBuilder.from("/", "GET").accept("application/foo;q=0.4", "application/bar;q=0.2", "application/baz").build())
                .get().getEntity();
        assertEquals("baz", s);
    }

    @Test
View Full Code Here

    @Test
    public void testAcceptGetWildCard() throws Exception {
        ApplicationHandler app = createApplication(Resource.class);

        ContainerResponse response = app.apply(RequestContextBuilder.from("/", "GET").accept("application/wildcard", "application/foo;q=0.6",
                "application/bar;q=0.4", "application/baz;q=0.2").build()).get();
        assertTrue("Status: " + response.getStatus(), response.getStatus() < 300);

        String s = (String) response.getEntity();
        assertEquals("wildcard", s);
View Full Code Here

    @Test
    public void testQualityErrorGreaterThanOne() throws Exception {
        ApplicationHandler app = createApplication(Resource.class);

        ContainerResponse response = app.apply(RequestContextBuilder.from("/", "GET").accept("application/foo;q=1.1").build()).get();
        assertEquals(400, response.getStatus());
    }

    @Test
    public void testQualityErrorMoreThanThreeDigits() throws Exception {
View Full Code Here

    @Test
    public void testQualityErrorMoreThanThreeDigits() throws Exception {
        ApplicationHandler app = createApplication(Resource.class);

        ContainerResponse response = app.apply(RequestContextBuilder.from("/", "GET").accept("application/foo;q=0.1234").build()).get();
        assertEquals(400, response.getStatus());
    }

    @Path("/")
    public static class MultipleResource {
View Full Code Here

        ApplicationHandler app = createApplication(MultipleResource.class);

        MediaType foo = MediaType.valueOf("application/foo");
        MediaType bar = MediaType.valueOf("application/bar");

        ContainerResponse response = app.apply(RequestContextBuilder.from("/", "GET").accept(foo).build()).get();
        assertTrue("Status: " + response.getStatus(), response.getStatus() < 300);
        assertEquals("GET", response.getEntity());
        assertEquals(foo, response.getMediaType());

        response = app.apply(RequestContextBuilder.from("/", "GET").accept(bar).build()).get();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.