use of org.glassfish.jersey.server.ApplicationHandler in project jersey by jersey.
the class ConsumeProduceSimpleTest method testConsumeSimpleBean.
@Test
public void testConsumeSimpleBean() throws Exception {
ApplicationHandler app = createApplication(ConsumeSimpleBean.class);
assertEquals("HTML", app.apply(RequestContextBuilder.from("/a/b", "POST").entity("").type("text/html").build()).get().getEntity());
assertEquals("XHTML", app.apply(RequestContextBuilder.from("/a/b", "POST").entity("").type("text/xhtml").build()).get().getEntity());
}
use of org.glassfish.jersey.server.ApplicationHandler in project jersey by jersey.
the class OptionsTest method testNoHeadInSub.
@Test
public void testNoHeadInSub() throws ExecutionException, InterruptedException {
ApplicationHandler application = new ApplicationHandler(new ResourceConfig(ResourceWithoutGetMethod.class));
final MediaType requestType = MediaType.TEXT_PLAIN_TYPE;
final ContainerResponse response = testOptions(requestType, application, "/no-get/sub");
Assert.assertFalse(((String) response.getEntity()).contains("HEAD"));
}
use of org.glassfish.jersey.server.ApplicationHandler in project jersey by jersey.
the class OptionsTest method testNoHeadWildcard.
@Test
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);
for (String allow : strings) {
Assert.assertFalse(allow.contains("HEAD"));
}
}
use of org.glassfish.jersey.server.ApplicationHandler in project jersey by jersey.
the class AcceptTest method testAcceptMultiple2.
@Test
public void testAcceptMultiple2() throws Exception {
ApplicationHandler app = createApplication(MultipleResource.class);
MediaType foo = MediaType.valueOf("application/foo");
ContainerResponse response;
response = app.apply(RequestContextBuilder.from("/", "GET").accept("*/*").build()).get();
assertTrue("Status: " + response.getStatus(), response.getStatus() < 300);
assertEquals("GET", response.getEntity());
assertEquals(foo, response.getMediaType());
}
use of org.glassfish.jersey.server.ApplicationHandler in project jersey by jersey.
the class AcceptTest method testQualityErrorGreaterThanOne.
@Test
public void testQualityErrorGreaterThanOne() throws Exception {
ApplicationHandler app = createApplication(Resource.class);
ContainerResponse response = app.apply(RequestContextBuilder.from("/", "GET").accept("application/foo;q=1.1").build()).get();
assertEquals(400, response.getStatus());
}
Aggregations