use of org.glassfish.jersey.server.ResourceConfig in project jersey by jersey.
the class AmbiguousTemplateTest method testPathParamOnAmbiguousTemplateTroughSubResourceLocator2.
@Test
public void testPathParamOnAmbiguousTemplateTroughSubResourceLocator2() throws ExecutionException, InterruptedException {
final ApplicationHandler applicationHandler = new ApplicationHandler(new ResourceConfig(SimpleLocator.class));
final ContainerResponse response = applicationHandler.apply(RequestContextBuilder.from("/locator/abc/a", "GET").build()).get();
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals("a-abc:null", response.getEntity());
}
use of org.glassfish.jersey.server.ResourceConfig in project jersey by jersey.
the class ConstrainedToServerTest method testFiltersAnnotated.
@Test
public void testFiltersAnnotated() throws ExecutionException, InterruptedException {
final ResourceConfig resourceConfig = new ResourceConfig(MyServerFilter.class, MyClientFilter.class, MyServerWrongFilter.class, MyServerFilterWithoutConstraint.class, Resource.class);
resourceConfig.registerInstances(new MyServerWrongFilter2(), new MyServerFilter2());
ApplicationHandler handler = new ApplicationHandler(resourceConfig);
final ContainerResponse response = handler.apply(RequestContextBuilder.from("/resource", "GET").build()).get();
assertEquals("called", response.getHeaderString("MyServerFilter"));
assertEquals("called", response.getHeaderString("MyServerFilter2"));
assertEquals("called", response.getHeaderString("MyServerFilterWithoutConstraint"));
}
use of org.glassfish.jersey.server.ResourceConfig 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.ResourceConfig 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.ResourceConfig in project jersey by jersey.
the class AcceptWriterTest method testAcceptGet.
@Test
public void testAcceptGet() throws Exception {
final ResourceConfig resourceConfig = new ResourceConfig(Resource.class, FooStringWriter.class, BarStringWriter.class);
final ApplicationHandler app = new ApplicationHandler(resourceConfig);
_test(app, "foo: content", "GET", null, null, "application/foo");
_test(app, "foo: content", "GET", null, null, "applcation/baz, application/foo;q=0.8");
_test(app, "bar: content", "GET", null, null, "application/bar");
_test(app, "bar: content", "GET", null, null, "applcation/baz, application/bar;q=0.8");
}
Aggregations