use of org.glassfish.jersey.server.ContainerResponse 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.ContainerResponse 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.ContainerResponse 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());
}
use of org.glassfish.jersey.server.ContainerResponse in project jersey by jersey.
the class AcceptTest method testAcceptNoProduces.
@Test
public void testAcceptNoProduces() throws Exception {
ApplicationHandler app = createApplication(NoProducesResource.class);
// media type order in the accept header does not impose output media type!
ContainerResponse response = app.apply(RequestContextBuilder.from("/", "GET").accept("image/png, text/plain;q=0.9").build()).get();
assertTrue("Status: " + response.getStatus(), response.getStatus() < 300);
assertEquals("GET", response.getEntity());
assertEquals(MediaType.valueOf("image/png"), response.getMediaType());
response = app.apply(RequestContextBuilder.from("/", "GET").accept("text/plain;q=0.5, text/html").build()).get();
assertTrue("Status: " + response.getStatus(), response.getStatus() < 300);
assertEquals("GET", response.getEntity());
assertEquals(MediaType.TEXT_HTML_TYPE, response.getMediaType());
}
use of org.glassfish.jersey.server.ContainerResponse in project jersey by jersey.
the class AcceptTest method test.
private void test(Class<?> c) throws Exception {
ApplicationHandler app = createApplication(c);
ContainerResponse response = app.apply(RequestContextBuilder.from("/", "GET").accept("application/foo").build()).get();
assertTrue("Status: " + response.getStatus(), response.getStatus() < 300);
assertEquals("GET", response.getEntity());
assertEquals(MediaType.valueOf("application/foo"), response.getMediaType());
response = app.apply(RequestContextBuilder.from("/", "GET").accept("application/bar").build()).get();
assertTrue("Status: " + response.getStatus(), response.getStatus() < 300);
assertEquals("GET", response.getEntity());
assertEquals(MediaType.valueOf("application/bar"), response.getMediaType());
response = app.apply(RequestContextBuilder.from("/", "GET").accept("application/foo", "application/bar").build()).get();
assertTrue("Status: " + response.getStatus(), response.getStatus() < 300);
assertEquals("GET", response.getEntity());
assertEquals(MediaType.valueOf("application/foo"), response.getMediaType());
response = app.apply(RequestContextBuilder.from("/", "GET").accept("application/bar", "application/foo").build()).get();
assertTrue("Status: " + response.getStatus(), response.getStatus() < 300);
assertEquals("GET", response.getEntity());
assertEquals(MediaType.valueOf("application/bar"), response.getMediaType());
}
Aggregations