Package org.glassfish.jersey.server

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


    @Test
    public void testPathParamOnAmbiguousTemplate5() throws ExecutionException, InterruptedException {
        final ApplicationHandler applicationHandler = new ApplicationHandler(new ResourceConfig(ResourceABC.class,
                ResourceXYZ.class));
        final ContainerResponse response = applicationHandler.apply(RequestContextBuilder.from("/xxx/foo", "GET").build()).get();
        Assert.assertEquals(200, response.getStatus());
        Assert.assertEquals("subx-xyz:xxx:foo", response.getEntity());
    }

    @Path("locator")
View Full Code Here


    }

    @Test
    public void testPathParamOnAmbiguousTemplateTroughSubResourceLocator1() throws ExecutionException, InterruptedException {
        final ApplicationHandler applicationHandler = new ApplicationHandler(new ResourceConfig(SimpleLocator.class));
        final ContainerResponse response = applicationHandler.apply(RequestContextBuilder.from("/locator/abc/uuu/a", "GET")
                .build()).get();
        Assert.assertEquals(404, response.getStatus());
    }

    @Test
View Full Code Here

    }

    @Test
    public void testPathParamOnAmbiguousTemplateTroughSubResourceLocator2() throws ExecutionException, InterruptedException {
        final ApplicationHandler applicationHandler = new ApplicationHandler(new ResourceConfig(SimpleLocator.class));
        final ContainerResponse response = applicationHandler.apply(RequestContextBuilder.from("/locator/abc/a", "GET")
                .build()).get();
        Assert.assertEquals(200, response.getStatus());
        Assert.assertEquals("a-abc:null", response.getEntity());
    }
View Full Code Here

    }

    @Test
    public void testPathParamOnAmbiguousTemplateTroughSubResourceLocator3() throws ExecutionException, InterruptedException {
        final ApplicationHandler applicationHandler = new ApplicationHandler(new ResourceConfig(SimpleLocator.class));
        final ContainerResponse response = applicationHandler.apply(RequestContextBuilder.from("/locator/xyz/subxfoo", "GET")
                .build()).get();
        Assert.assertEquals(200, response.getStatus());
        Assert.assertEquals("subx-xyz:null:subxfoo", response.getEntity());
    }
View Full Code Here

    }

    @Test
    public void testSubResourceLocatorWithPathParams() throws ExecutionException, InterruptedException {
        final ApplicationHandler applicationHandler = new ApplicationHandler(new ResourceConfig(ResourceWithLocator.class));
        final ContainerResponse response = applicationHandler.apply(RequestContextBuilder.from("/uuu", "GET").build()).get();
        Assert.assertEquals(200, response.getStatus());
        Assert.assertEquals("uuu", response.getEntity());
    }

    @Test
View Full Code Here

    }

    @Test
    public void testSubResourceLocatorWithPathParams2() throws ExecutionException, InterruptedException {
        final ApplicationHandler applicationHandler = new ApplicationHandler(new ResourceConfig(ResourceWithLocator.class));
        final ContainerResponse response = applicationHandler.apply(RequestContextBuilder.from("/uuu/test", "GET").build()).get();
        Assert.assertEquals(200, response.getStatus());
        Assert.assertEquals("uuu:test", response.getEntity());
    }

View Full Code Here

    @Test
    public void testOptionsOnRoot() throws ExecutionException, InterruptedException {
        ResourceConfig resourceConfig = new ResourceConfig(ResourceA.class, ResourceB.class, ResourceQ.class);
        ApplicationHandler app = new ApplicationHandler(resourceConfig);
        final ContainerResponse containerResponse = app.apply(RequestContextBuilder.from("/aaa", "OPTIONS")
                .accept(MediaType.TEXT_PLAIN).build()).get();
        Assert.assertEquals(200, containerResponse.getStatus());
        Assert.assertEquals("POST, GET, OPTIONS, HEAD", containerResponse.getEntity());
    }
View Full Code Here

    @Test
    public void testGetOnRoot() throws ExecutionException, InterruptedException {
        ResourceConfig resourceConfig = new ResourceConfig(ResourceA.class, ResourceB.class, ResourceQ.class);
        ApplicationHandler app = new ApplicationHandler(resourceConfig);
        final ContainerResponse containerResponse = app.apply(RequestContextBuilder.from("/aaa", "GET")
                .accept(MediaType.TEXT_PLAIN).build()).get();
        Assert.assertEquals(200, containerResponse.getStatus());
        Assert.assertEquals("getA", containerResponse.getEntity());
    }
View Full Code Here

    @Test
    public void testOptionsOnChild() throws ExecutionException, InterruptedException {
        ResourceConfig resourceConfig = new ResourceConfig(ResourceA.class, ResourceB.class, ResourceQ.class);
        ApplicationHandler app = new ApplicationHandler(resourceConfig);
        final ContainerResponse containerResponse = app.apply(RequestContextBuilder.from("/resq/c", "OPTIONS")
                .accept(MediaType.TEXT_PLAIN).build()).get();
        Assert.assertEquals(200, containerResponse.getStatus());
        Assert.assertEquals("GET, OPTIONS, HEAD, PUT", containerResponse.getEntity());
    }
View Full Code Here

    @Test
    public void testGetOnChild() throws ExecutionException, InterruptedException {
        ResourceConfig resourceConfig = new ResourceConfig(ResourceA.class, ResourceB.class, ResourceQ.class);
        ApplicationHandler app = new ApplicationHandler(resourceConfig);
        final ContainerResponse containerResponse = app.apply(RequestContextBuilder.from("/resq/a", "GET").build()).get();
        Assert.assertEquals(200, containerResponse.getStatus());
        Assert.assertEquals("getA", containerResponse.getEntity());
    }
}
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.