use of org.glassfish.jersey.server.ApplicationHandler in project jersey by jersey.
the class LayeredFiltersTest method testResourceMethodMultiple.
@Test
public void testResourceMethodMultiple() throws ExecutionException, InterruptedException {
final ResourceConfig resourceConfig = new ResourceConfig(ResourceWithMethodMultiple.class).register(FilterOne.class).register(FilterTwo.class);
final ApplicationHandler application = new ApplicationHandler(resourceConfig);
final ContainerResponse response = application.apply(RequestContextBuilder.from("/", "GET").build()).get();
assertEquals(200, response.getStatus());
assertEquals("onetwo", response.getEntity());
List<Object> xTest = response.getHeaders().get("X-TEST");
assertEquals(2, xTest.size());
assertEquals("two", xTest.get(0));
assertEquals("one", xTest.get(1));
}
use of org.glassfish.jersey.server.ApplicationHandler in project jersey by jersey.
the class UriConnegFilterTest method setUp.
@Before
public void setUp() {
Map<String, MediaType> mediaTypes = new HashMap<>();
mediaTypes.put("foo", MediaType.valueOf("application/foo"));
mediaTypes.put("bar", MediaType.valueOf("application/bar"));
ResourceConfig rc = new ResourceConfig(Resource.class);
rc.property(ServerProperties.MEDIA_TYPE_MAPPINGS, mediaTypes);
handler = new ApplicationHandler(rc);
}
use of org.glassfish.jersey.server.ApplicationHandler in project jersey by jersey.
the class UriModificationFilterTest method testWithInstance.
@Test
public void testWithInstance() throws ExecutionException, InterruptedException {
final ResourceConfig resourceConfig = new ResourceConfig(Resource.class).register(UriModifyFilter.class);
final ApplicationHandler application = new ApplicationHandler(resourceConfig);
final ContainerResponse response = application.apply(RequestContextBuilder.from("/a/b/c", "GET").build()).get();
assertEquals(200, response.getStatus());
assertEquals("/a/b?filter=c", response.getEntity());
}
use of org.glassfish.jersey.server.ApplicationHandler in project jersey by jersey.
the class ResourceContextTest method testGetResource.
@Test
public void testGetResource() throws Exception {
ApplicationHandler app = createApplication(ResourceA.class, ResourceB.class);
assertEquals("B: c", app.apply(RequestContextBuilder.from("/a/b/c", "GET").build()).get().getEntity());
assertEquals("SR: foo", app.apply(RequestContextBuilder.from("/a/foo", "GET").build()).get().getEntity());
assertEquals("null", app.apply(RequestContextBuilder.from("/a/is-null", "GET").build()).get().getEntity());
assertEquals(404, app.apply(RequestContextBuilder.from("/a/non-instantiable", "GET").build()).get().getStatus());
}
use of org.glassfish.jersey.server.ApplicationHandler in project jersey by jersey.
the class CsrfProtectionFilterTest method setUp.
@Before
public void setUp() {
ResourceConfig rc = new ResourceConfig(Resource.class, CsrfProtectionFilter.class);
handler = new ApplicationHandler(rc);
}
Aggregations