use of org.glassfish.jersey.server.ContainerResponse in project jersey by jersey.
the class OptionsSubResourceMethodTest method testNoOptionsDifferentSub.
@Test
public void testNoOptionsDifferentSub() throws Exception {
initiateWebApplication(ResourceNoOptionsDifferentSub.class);
ContainerResponse response = app.apply(RequestContextBuilder.from("/sub1", "OPTIONS").build()).get();
assertEquals(200, response.getStatus());
String allow = response.getHeaderString("Allow");
assertTrue(allow.contains("OPTIONS"));
assertTrue(allow.contains("GET"));
assertFalse(allow.contains("PUT"));
response = app.apply(RequestContextBuilder.from("/sub2", "OPTIONS").build()).get();
assertEquals(200, response.getStatus());
allow = response.getHeaderString("Allow");
assertTrue(allow.contains("OPTIONS"));
assertTrue(allow.contains("PUT"));
assertFalse(allow.contains("GET"));
}
use of org.glassfish.jersey.server.ContainerResponse in project jersey by jersey.
the class OptionsSubResourceMethodTest method testWithOptions.
@Test
public void testWithOptions() throws Exception {
initiateWebApplication(ResourceWithOptions.class);
ContainerResponse response = app.apply(RequestContextBuilder.from("/sub", "OPTIONS").build()).get();
assertEquals(200, response.getStatus());
String allow = response.getHeaderString("Allow");
assertTrue(allow.contains("OPTIONS"));
assertTrue(allow.contains("GET"));
assertTrue(allow.contains("PUT"));
assertTrue(allow.contains("POST"));
assertTrue(allow.contains("DELETE"));
assertTrue(allow.contains("PATCH"));
}
use of org.glassfish.jersey.server.ContainerResponse in project jersey by jersey.
the class OptionsTest method testWithOptions.
@Test
public void testWithOptions() throws Exception {
initiateWebApplication(ResourceWithOptions.class);
ContainerResponse response = app.apply(RequestContextBuilder.from("/", "OPTIONS").build()).get();
assertEquals(200, response.getStatus());
String allow = response.getHeaderString("Allow");
assertTrue(allow.contains("OPTIONS"));
assertTrue(allow.contains("GET"));
assertTrue(allow.contains("PUT"));
assertTrue(allow.contains("POST"));
assertTrue(allow.contains("DELETE"));
assertTrue(allow.contains("PATCH"));
assertEquals("OVERRIDE", response.getHeaderString("X-TEST"));
}
use of org.glassfish.jersey.server.ContainerResponse in project jersey by jersey.
the class OptionsTest method testOptions.
private ContainerResponse testOptions(MediaType requestType, ApplicationHandler application, String path) throws InterruptedException, ExecutionException {
final ContainerRequest request = RequestContextBuilder.from(path, "OPTIONS").accept(requestType).build();
final ContainerResponse response = application.apply(request).get();
Assert.assertEquals(200, response.getStatus());
final MediaType type = response.getMediaType();
Assert.assertEquals(requestType, type);
return response;
}
use of org.glassfish.jersey.server.ContainerResponse 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"));
}
Aggregations