use of org.glassfish.jersey.server.ContainerResponse in project jersey by jersey.
the class ApplicationFilterTest method testFilterNotCalledOn404.
@Test
public void testFilterNotCalledOn404() throws Exception {
// not found
final SimpleFilter simpleFilter = new SimpleFilter();
final ResourceConfig resourceConfig = new ResourceConfig(SimpleResource.class).register(simpleFilter);
final ApplicationHandler application = new ApplicationHandler(resourceConfig);
final ContainerResponse response = application.apply(RequestContextBuilder.from("/NOT-FOUND", "GET").build()).get();
assertEquals(404, response.getStatus());
Assert.assertFalse(simpleFilter.called);
}
use of org.glassfish.jersey.server.ContainerResponse in project jersey by jersey.
the class SubResourceDynamicTest method testSubResourceDynamicWithTemplates.
@Test
public void testSubResourceDynamicWithTemplates() throws Exception {
app = createApplication(ParentWithTemplates.class);
ContainerResponse response;
response = app.apply(RequestContextBuilder.from("/parent", "GET").accept("text/plain").build()).get();
assertEquals("parent", response.getEntity());
response = app.apply(RequestContextBuilder.from("/parent/child/first", "GET").accept("text/plain").build()).get();
assertEquals("first", response.getEntity());
}
use of org.glassfish.jersey.server.ContainerResponse in project jersey by jersey.
the class SubResourceProgrammaticTest method _test.
private void _test(ApplicationHandler handler, String requestUri, String expected) throws InterruptedException, ExecutionException {
final ContainerResponse response = handler.apply(RequestContextBuilder.from(requestUri, "GET").build()).get();
assertEquals(200, response.getStatus());
assertEquals(expected, response.getEntity());
}
use of org.glassfish.jersey.server.ContainerResponse in project jersey by jersey.
the class SubResourceProgrammaticTest method testInvalidSubResource.
@Test
public void testInvalidSubResource() throws ExecutionException, InterruptedException {
ApplicationHandler handler = new ApplicationHandler(new ResourceConfig(WrongResource.class));
_test(handler, "/wrong", "ok");
try {
final ContainerResponse response = handler.apply(RequestContextBuilder.from("/wrong/locator", "GET").build()).get();
assertEquals(500, response.getStatus());
fail("Should throw exception caused by validation errors of Sub Resource.");
} catch (Throwable e) {
// ok - Should throw exception caused by validation errors of Sub Resource.
}
}
use of org.glassfish.jersey.server.ContainerResponse in project jersey by jersey.
the class ValidatorTest method testDisableFailOnErrors.
@Test
public void testDisableFailOnErrors() throws ExecutionException, InterruptedException {
final ResourceConfig rc = new ResourceConfig(AmbiguousLocatorResource1.class, AmbiguousLocatorResource2.class, AmbiguousParameterResource.class, AmbiguousResource1.class, AmbiguousResource2.class, ConcreteGenericArrayResource.class, ConcreteParameterizedTypeResource.class, EmptyResource.class, GenericArrayResource.class, MethodAndLocatorResource.class, MethodAndLocatorResource2.class, MyBeanParam.class, ParameterizedTypeResource.class, PercentEncodedCaseSensitiveTest.class, PercentEncodedTest.class, ResourceAsProvider.class, ResourceMethodWithVoidReturnType.class, ResourceRoot.class, ResourceRootNotUnique.class, ResourceSubPathRoot.class, ResourceWithMultipleScopes.class, TestAmbiguousParams.class, TestAsyncGetRMReturningVoid.class, TestEmptyPathSegment.class, TestEntityParamOnSRL.class, TestGetRMConsumingEntity.class, TestGetRMConsumingFormParam.class, TestGetRMReturningVoid.class, TestGetSRMConsumingEntity.class, TestGetSRMConsumingFormParam.class, TestGetSRMReturningVoid.class, TestMoreThanOneEntity.class, TestMultipleHttpMethodDesignatorsRM.class, TestMultipleHttpMethodDesignatorsSRM.class, TestNonConflictingHttpMethodDelete.class, TestNonPublicRM.class, TestRelaxedProducesConsumesParserRules.class, TestRootResourceNonAmbigCtors.class, TestSRLReturningVoid.class, TwoLocatorsResource.class, TypeVariableResource.class, UniqueResource.class, // we should still be able to invoke a GET on this one.
TestDisableValidationFailOnErrorResource.class);
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());
}
Aggregations