Package org.glassfish.jersey.server

Examples of org.glassfish.jersey.server.ContainerResponse


    @Override
    public void commit() {
        try {
            if (!configSetStatusOverSendError && !response.isCommitted()) {
                final ContainerResponse responseContext = getResponseContext();
                final int status = responseContext.getStatus();
                if (status >= 400 && !(useSetStatusOn404 && status == 404)) {
                    final String reason = responseContext.getStatusInfo().getReasonPhrase();
                    try {
                        if (reason == null || reason.isEmpty()) {
                            response.sendError(status);
                        } else {
                            response.sendError(status, reason);
View Full Code Here


                }
            });
            return null; // return null on current thread
        } else {
            // TODO replace with processing context factory method.
            return new ContainerResponse(request, invoke(processingContext, resource));
        }
    }
View Full Code Here

                }
            });
            return null; // return null on current thread
        } else {
            // TODO replace with processing context factory method.
            return new ContainerResponse(request, invoke(processingContext, resource));
        }
    }
View Full Code Here

    @Test
    public void testCustomRuntimeThreadProviderSupport() throws ExecutionException, InterruptedException {
        ApplicationHandler ah = createApplication(CustomThreadProvider.class, ExecutorsTestResource.class);

        final ContainerResponse response = ah.apply(RequestContextBuilder.from("/executors-test", "GET").build()).get();

        assertEquals(200, response.getStatus());
        assertEquals("Some executor test assertions failed.", 111, response.getEntity());
    }
View Full Code Here

    @Test
    public void testWithInstance() throws ExecutionException, InterruptedException {
        final ResourceConfig resourceConfig = new ResourceConfig(Resource.class)
                .register(UriModifyFilter.class);
        final ApplicationHandler application = new ApplicationHandler(resourceConfig);
        final ContainerResponse response = application.apply(RequestContextBuilder.from("/a/b/c", "GET").build()).get();

        assertEquals(200, response.getStatus());
        assertEquals("/a/b?filter=c", response.getEntity());
    }
View Full Code Here

    @Ignore("JERSEY-2414 - not yet implemented")
    public void testResourceMethod() throws ExecutionException, InterruptedException {
        final ResourceConfig resourceConfig = new ResourceConfig(ResourceWithSubresourceLocator.class)
                .register(FilterOne.class).register(FilterTwo.class);
        final ApplicationHandler application = new ApplicationHandler(resourceConfig);
        final ContainerResponse response = application.apply(RequestContextBuilder.from("/sub", "GET").build()).get();

        assertEquals(200, response.getStatus());
        assertEquals("onetwo", response.getEntity());
        List<Object> xTest = response.getHeaders().get("X-TEST");
        assertEquals(2, xTest.size());
        assertEquals("two", xTest.get(0));
        assertEquals("one", xTest.get(1));
    }
View Full Code Here

    @Ignore("JERSEY-2414 - not yet implemented")
    public void testResourceSubresourceMethod() throws ExecutionException, InterruptedException {
        final ResourceConfig resourceConfig = new ResourceConfig(ResourceWithSubresourceLocator.class)
                .register(FilterOne.class).register(FilterTwo.class);
        final ApplicationHandler application = new ApplicationHandler(resourceConfig);
        final ContainerResponse response = application.apply(RequestContextBuilder.from("/sub/submethod", "GET")
                .build()).get();

        assertEquals(200, response.getStatus());
        assertEquals("onetwo", response.getEntity());
        List<Object> xTest = response.getHeaders().get("X-TEST");
        assertEquals(2, xTest.size());
        assertEquals("two", xTest.get(0));
        assertEquals("one", xTest.get(1));
    }
View Full Code Here

    @Ignore("JERSEY-2414 - not yet implemented")
    public void testResourceMethodOnClass() throws ExecutionException, InterruptedException {
        final ResourceConfig resourceConfig = new ResourceConfig(ResourceWithSubresourceLocatorOnClass.class)
                .register(FilterOne.class).register(FilterTwo.class);
        final ApplicationHandler application = new ApplicationHandler(resourceConfig);
        final ContainerResponse response = application.apply(RequestContextBuilder.from("/sub", "GET").build()).get();

        assertEquals(200, response.getStatus());
        assertEquals("onetwo", response.getEntity());
        List<Object> xTest = response.getHeaders().get("X-TEST");
        assertEquals(2, xTest.size());
        assertEquals("two", xTest.get(0));
        assertEquals("one", xTest.get(1));
    }
View Full Code Here

    @Ignore("JERSEY-2414 - not yet implemented")
    public void testResourceSubresourceMethodOnClass() throws ExecutionException, InterruptedException {
        final ResourceConfig resourceConfig = new ResourceConfig(ResourceWithSubresourceLocatorOnClass.class)
                .register(FilterOne.class).register(FilterTwo.class);
        final ApplicationHandler application = new ApplicationHandler(resourceConfig);
        final ContainerResponse response = application.apply(RequestContextBuilder.from("/sub/submethod", "GET").build()).get();

        assertEquals(200, response.getStatus());
        assertEquals("onetwo", response.getEntity());
        List<Object> xTest = response.getHeaders().get("X-TEST");
        assertEquals(2, xTest.size());
        assertEquals("two", xTest.get(0));
        assertEquals("one", xTest.get(1));
    }
View Full Code Here

    @Test
    public void testResourceMethodMultiple() throws ExecutionException, InterruptedException {
        final ResourceConfig resourceConfig = new ResourceConfig(ResourceWithMethodMultiple.class)
                .register(FilterOne.class).register(FilterTwo.class);
        final ApplicationHandler application = new ApplicationHandler(resourceConfig);
        final ContainerResponse response = application.apply(RequestContextBuilder.from("/", "GET").build()).get();

        assertEquals(200, response.getStatus());
        assertEquals("onetwo", response.getEntity());
        List<Object> xTest = response.getHeaders().get("X-TEST");
        assertEquals(2, xTest.size());
        assertEquals("two", xTest.get(0));
        assertEquals("one", xTest.get(1));
    }
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.