Search in sources :

Example 56 with ResourceConfig

use of org.glassfish.jersey.server.ResourceConfig 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());
}
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 57 with ResourceConfig

use of org.glassfish.jersey.server.ResourceConfig 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);
}
Also used : ApplicationHandler(org.glassfish.jersey.server.ApplicationHandler) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) Before(org.junit.Before)

Example 58 with ResourceConfig

use of org.glassfish.jersey.server.ResourceConfig 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 59 with ResourceConfig

use of org.glassfish.jersey.server.ResourceConfig 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 60 with ResourceConfig

use of org.glassfish.jersey.server.ResourceConfig 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)

Aggregations

ResourceConfig (org.glassfish.jersey.server.ResourceConfig)357 Test (org.junit.Test)135 ApplicationHandler (org.glassfish.jersey.server.ApplicationHandler)105 ContainerResponse (org.glassfish.jersey.server.ContainerResponse)62 LoggingFeature (org.glassfish.jersey.logging.LoggingFeature)33 ServletContainer (org.glassfish.jersey.servlet.ServletContainer)29 Response (javax.ws.rs.core.Response)28 HttpServer (org.glassfish.grizzly.http.server.HttpServer)28 Resource (org.glassfish.jersey.server.model.Resource)24 URI (java.net.URI)23 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)23 IOException (java.io.IOException)22 ContainerRequestContext (javax.ws.rs.container.ContainerRequestContext)22 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)18 Server (org.eclipse.jetty.server.Server)17 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 MetricRegistry (com.codahale.metrics.MetricRegistry)15 ContainerRequest (org.glassfish.jersey.server.ContainerRequest)15