Package org.glassfish.jersey.server

Examples of org.glassfish.jersey.server.ContainerRequest


            final ResourceConfig rc = new ResourceConfig(WidgetsResource.class, ExtraResource.class);
            rc.property(ServerProperties.WADL_FEATURE_DISABLE, false);

            final ApplicationHandler applicationHandler = new ApplicationHandler(rc);

            final ContainerResponse containerResponse = applicationHandler.apply(new ContainerRequest(
                    URI.create("/"), URI.create("/application.wadl"),
                    "GET", null, new MapPropertiesDelegate())).get();

            assertEquals(200, containerResponse.getStatus());
        }
View Full Code Here


            final ResourceConfig rc = new ResourceConfig(WidgetsResource.class, ExtraResource.class);
            rc.property(ServerProperties.WADL_GENERATOR_CONFIG, MyWadlGeneratorConfig.class.getName());

            final ApplicationHandler applicationHandler = new ApplicationHandler(rc);

            final ContainerResponse containerResponse = applicationHandler.apply(new ContainerRequest(
                    URI.create("/"), URI.create("/application.wadl"),
                    "GET", null, new MapPropertiesDelegate())).get();

            final DocumentBuilderFactory bf = DocumentBuilderFactory.newInstance();
            bf.setNamespaceAware(true);
View Full Code Here

            final ResourceConfig rc = new ResourceConfig(EmptyProducesTestResource.class);
            rc.property(ServerProperties.WADL_FEATURE_DISABLE, false);

            final ApplicationHandler applicationHandler = new ApplicationHandler(rc);

            final ContainerResponse containerResponse = applicationHandler.apply(new ContainerRequest(
                    URI.create("/"), URI.create("/application.wadl"),
                    "GET", null, new MapPropertiesDelegate())).get();

            assertEquals(200, containerResponse.getStatus());
View Full Code Here

        return resourceConfig;
    }

    private void assertApply(int responseStatus, ResourceConfig resourceConfig, URI uri) throws InterruptedException, ExecutionException {
        final ApplicationHandler applicationHandler = new ApplicationHandler(resourceConfig);
        final ContainerRequest requestContext = new ContainerRequest(uri, uri, "POST", null, new MapPropertiesDelegate());
        final ContainerResponse containerResponse = applicationHandler.apply(requestContext).get();

        assertEquals(responseStatus, containerResponse.getStatus());
    }
View Full Code Here

                TestDisableValidationFailOnErrorResource.class // we should still be able to invoke a GET on this one.
        );
        rc.property(ServerProperties.RESOURCE_VALIDATION_IGNORE_ERRORS, true);
        ApplicationHandler ah = new ApplicationHandler(rc);

        final ContainerRequest request = RequestContextBuilder.from("/test-disable-validation-fail-on-error", "GET").build();
        ContainerResponse response = ah.apply(request).get();

        assertEquals(200, response.getStatus());
        assertEquals("PASSED", response.getEntity());
    }
View Full Code Here

        final Resource resource = resourceBuilder.build();
        resourceConfig.registerResources(resource);

        ApplicationHandler app = createApplication(resourceConfig);

        ContainerRequest request;
        request = RequestContextBuilder.from("/hello", "GET").build();
        assertEquals("Hello!", app.apply(request).get().getEntity());

        request = RequestContextBuilder.from("/hello2", "GET").build();
        assertEquals("Hello!", app.apply(request).get().getEntity());
View Full Code Here

            throws ExecutionException, InterruptedException {
        RequestContextBuilder requestContextBuilder = RequestContextBuilder.from("/", method);
        if (entity != null) {
            requestContextBuilder.entity(entity).type(mediaType);
        }
        ContainerRequest requestContext = requestContextBuilder.accept(accept).build();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        app.apply(requestContext, baos);
        assertEquals(expected, baos.toString());
    }
View Full Code Here

        app = new ApplicationHandler(rc);
    }

    @Test
    public void testAsyncApp() throws InterruptedException, ExecutionException {
        ContainerRequest req =
                RequestContextBuilder.from(BASE_URI, URI.create(BASE_URI.getPath() + uriSuffix), "GET").build();

        Future<ContainerResponse> res = app.apply(req);

        assertEquals(expectedResponse, res.get().getEntity());
View Full Code Here

    }

    @Test
    public void testRequestNoType() throws ExecutionException, InterruptedException {
        ApplicationHandler application = new ApplicationHandler(new ResourceConfig(WadlResource.class));
        final ContainerRequest request = RequestContextBuilder.from("/resource", "OPTIONS").build();
        final ContainerResponse response = application.apply(request).get();
        Assert.assertEquals(200, response.getStatus());
        final MediaType type = response.getMediaType();
        Assert.assertTrue(type.equals(MediaTypes.WADL) || type.equals(MediaType.TEXT_HTML_TYPE)
                || type.equals(MediaType.TEXT_PLAIN));
View Full Code Here

    public void testNoHeadWildcard() throws ExecutionException, InterruptedException {
        final ResourceConfig resourceConfig = new ResourceConfig(ResourceWithoutGetMethod.class);
        resourceConfig.property(ServerProperties.WADL_FEATURE_DISABLE, true);
        ApplicationHandler application = new ApplicationHandler(resourceConfig);

        final ContainerRequest request = RequestContextBuilder.from("/no-get", "OPTIONS").accept(MediaType.MEDIA_TYPE_WILDCARD)
                .build();
        final ContainerResponse response = application.apply(request).get();
        Assert.assertEquals(200, response.getStatus());

        final List<String> strings = response.getStringHeaders().get(HttpHeaders.ALLOW);
View Full Code Here

TOP

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

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.