Search in sources :

Example 61 with ApplicationHandler

use of org.glassfish.jersey.server.ApplicationHandler in project jersey by jersey.

the class EncodingFilterTest method initializeAndGetFilter.

@SuppressWarnings("unchecked")
private EncodingFilter initializeAndGetFilter() {
    ResourceConfig rc = new ResourceConfig();
    EncodingFilter.enableFor(rc, FooEncoding.class, GZipEncoder.class);
    return (EncodingFilter) new ApplicationHandler(rc).getInjectionManager().getInstance(ContainerResponseFilter.class);
}
Also used : ContainerResponseFilter(javax.ws.rs.container.ContainerResponseFilter) ApplicationHandler(org.glassfish.jersey.server.ApplicationHandler) ResourceConfig(org.glassfish.jersey.server.ResourceConfig)

Example 62 with ApplicationHandler

use of org.glassfish.jersey.server.ApplicationHandler in project jersey by jersey.

the class EntityTypeFilterTest method test.

@Test
public void test() throws ExecutionException, InterruptedException {
    ApplicationHandler handler = new ApplicationHandler(new ResourceConfig(Resource.class, ResponseFilter.class));
    final ContainerResponse response = handler.apply(RequestContextBuilder.from("/resource/getentitytype", "GET").build()).get();
    assertEquals(200, response.getStatus());
}
Also used : ContainerResponse(org.glassfish.jersey.server.ContainerResponse) ApplicationHandler(org.glassfish.jersey.server.ApplicationHandler) ContainerResponseFilter(javax.ws.rs.container.ContainerResponseFilter) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) Test(org.junit.Test)

Example 63 with ApplicationHandler

use of org.glassfish.jersey.server.ApplicationHandler in project jersey by jersey.

the class FilterSetMethodTest method testResource.

@Test
public void testResource() throws ExecutionException, InterruptedException {
    ApplicationHandler handler = new ApplicationHandler(new ResourceConfig(Resource.class, PostMatchFilter.class));
    ContainerResponse res = handler.apply(RequestContextBuilder.from("", "/resource/setMethodInResource", "GET").build()).get();
    assertEquals(200, res.getStatus());
}
Also used : ContainerResponse(org.glassfish.jersey.server.ContainerResponse) ApplicationHandler(org.glassfish.jersey.server.ApplicationHandler) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) Test(org.junit.Test)

Example 64 with ApplicationHandler

use of org.glassfish.jersey.server.ApplicationHandler in project jersey by jersey.

the class FilterSetMethodTest method testPreMatchingFilter.

@Test
public void testPreMatchingFilter() throws ExecutionException, InterruptedException {
    ApplicationHandler handler = new ApplicationHandler(new ResourceConfig(Resource.class, PreMatchFilter.class));
    ContainerResponse res = handler.apply(RequestContextBuilder.from("", "/resource/setMethod", "GET").build()).get();
    assertEquals(200, res.getStatus());
}
Also used : ContainerResponse(org.glassfish.jersey.server.ContainerResponse) ApplicationHandler(org.glassfish.jersey.server.ApplicationHandler) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) Test(org.junit.Test)

Example 65 with ApplicationHandler

use of org.glassfish.jersey.server.ApplicationHandler in project jersey by jersey.

the class PropertyValidationTest method assertApply.

private void assertApply(int responseStatus, ResourceConfig resourceConfig, URI uri) throws InterruptedException, ExecutionException {
    final ApplicationHandler applicationHandler = new ApplicationHandler(resourceConfig);
    final ContainerRequest requestContext = new ContainerRequest(uri, uri, "POST", null, new MapPropertiesDelegate());
    final ContainerResponse containerResponse = applicationHandler.apply(requestContext).get();
    assertEquals(responseStatus, containerResponse.getStatus());
}
Also used : MapPropertiesDelegate(org.glassfish.jersey.internal.MapPropertiesDelegate) ContainerResponse(org.glassfish.jersey.server.ContainerResponse) ApplicationHandler(org.glassfish.jersey.server.ApplicationHandler) ContainerRequest(org.glassfish.jersey.server.ContainerRequest)

Aggregations

ApplicationHandler (org.glassfish.jersey.server.ApplicationHandler)162 Test (org.junit.Test)142 ResourceConfig (org.glassfish.jersey.server.ResourceConfig)104 ContainerResponse (org.glassfish.jersey.server.ContainerResponse)99 ApplicationInfoListener (org.glassfish.jersey.server.internal.monitoring.ApplicationInfoListener)17 MonitoringEventListener (org.glassfish.jersey.server.internal.monitoring.MonitoringEventListener)17 MBeanExposer (org.glassfish.jersey.server.internal.monitoring.jmx.MBeanExposer)17 ContainerRequestContext (javax.ws.rs.container.ContainerRequestContext)12 Response (javax.ws.rs.core.Response)10 MediaType (javax.ws.rs.core.MediaType)8 ContainerRequest (org.glassfish.jersey.server.ContainerRequest)7 MonitoringFeature (org.glassfish.jersey.server.internal.monitoring.MonitoringFeature)6 Resource (org.glassfish.jersey.server.model.Resource)6 ContainerResponseFilter (javax.ws.rs.container.ContainerResponseFilter)5 ArrayList (java.util.ArrayList)4 Ignore (org.junit.Ignore)4 IOException (java.io.IOException)3 ContainerRequestFilter (javax.ws.rs.container.ContainerRequestFilter)3 Inflector (org.glassfish.jersey.process.Inflector)3 Before (org.junit.Before)3