use of org.glassfish.jersey.server.ResourceConfig in project jersey by jersey.
the class ResponseMediaTypeFromProvidersTest method testSubResource.
@Test
public void testSubResource() throws Exception {
final ResourceConfig resourceConfig = new ResourceConfig(AnotherSubResource.class);
final ApplicationHandler applicationHandler = new ApplicationHandler(resourceConfig);
final ContainerResponse response = applicationHandler.apply(RequestContextBuilder.from("/resource/subresource/sub", "POST").header("Accept", "text/plain").build()).get();
assertThat(response.getStatus(), equalTo(200));
assertThat(response.getHeaderString("Content-Type"), equalTo("text/plain"));
assertThat((String) response.getEntity(), equalTo("AnotherSubResource"));
}
use of org.glassfish.jersey.server.ResourceConfig in project jersey by jersey.
the class SubResourceValidationTest method testDisable.
@Test
public void testDisable() throws ExecutionException, InterruptedException {
ResourceConfig resourceConfig = new ResourceConfig(RootResource.class);
resourceConfig.property(ServerProperties.RESOURCE_VALIDATION_DISABLE, "true");
ApplicationHandler applicationHandler = new ApplicationHandler(resourceConfig);
final ContainerResponse response = applicationHandler.apply(RequestContextBuilder.from("/root/sub", "GET").build()).get();
assertEquals(200, response.getStatus());
assertEquals("get", response.getEntity());
}
use of org.glassfish.jersey.server.ResourceConfig in project jersey by jersey.
the class SubResourceValidationTest method testEnable.
@Test
public void testEnable() throws ExecutionException, InterruptedException {
ResourceConfig resourceConfig = new ResourceConfig(RootResource.class);
resourceConfig.property(ServerProperties.RESOURCE_VALIDATION_DISABLE, "false");
ApplicationHandler applicationHandler = new ApplicationHandler(resourceConfig);
try {
final ContainerResponse response = applicationHandler.apply(RequestContextBuilder.from("/root/sub", "GET").build()).get();
// should throw an exception or return 500
Assert.assertEquals(500, response.getStatus());
} catch (Exception e) {
// ok
}
}
use of org.glassfish.jersey.server.ResourceConfig in project jersey by jersey.
the class OptionsTest method testRequestTextPlain.
@Test
public void testRequestTextPlain() throws ExecutionException, InterruptedException {
ApplicationHandler application = new ApplicationHandler(new ResourceConfig(WadlResource.class, ResponseTextFilter.class));
final ContainerResponse response = testOptions(MediaType.TEXT_PLAIN_TYPE, application, "/resource");
final String entity = (String) response.getEntity();
Assert.assertTrue(entity.contains("GET"));
}
use of org.glassfish.jersey.server.ResourceConfig in project jersey by jersey.
the class OptionsTest method testNoHead.
@Test
public void testNoHead() throws ExecutionException, InterruptedException {
ApplicationHandler application = new ApplicationHandler(new ResourceConfig(ResourceWithoutGetMethod.class));
final ContainerResponse response = testOptions(MediaType.TEXT_PLAIN_TYPE, application, "/no-get");
Assert.assertFalse(((String) response.getEntity()).contains("HEAD"));
}
Aggregations