Search in sources :

Example 51 with ResourceConfig

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

the class LayeredFiltersTest method testResourceSubresourceMethod.

@Test
@Ignore("JERSEY-2414 - not yet implemented")
public void testResourceSubresourceMethod() throws ExecutionException, InterruptedException {
    final ResourceConfig resourceConfig = new ResourceConfig(ResourceWithSubresourceLocator.class).register(FilterOne.class).register(FilterTwo.class);
    final ApplicationHandler application = new ApplicationHandler(resourceConfig);
    final ContainerResponse response = application.apply(RequestContextBuilder.from("/sub/submethod", "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));
}
Also used : ContainerResponse(org.glassfish.jersey.server.ContainerResponse) ApplicationHandler(org.glassfish.jersey.server.ApplicationHandler) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 52 with ResourceConfig

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

the class LayeredFiltersTest method testResourceMethodOnClass.

@Test
@Ignore("JERSEY-2414 - not yet implemented")
public void testResourceMethodOnClass() throws ExecutionException, InterruptedException {
    final ResourceConfig resourceConfig = new ResourceConfig(ResourceWithSubresourceLocatorOnClass.class).register(FilterOne.class).register(FilterTwo.class);
    final ApplicationHandler application = new ApplicationHandler(resourceConfig);
    final ContainerResponse response = application.apply(RequestContextBuilder.from("/sub", "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));
}
Also used : ContainerResponse(org.glassfish.jersey.server.ContainerResponse) ApplicationHandler(org.glassfish.jersey.server.ApplicationHandler) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 53 with ResourceConfig

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

the class LayeredFiltersTest method testResourceSubresourceMethodOnClass.

@Test
@Ignore("JERSEY-2414 - not yet implemented")
public void testResourceSubresourceMethodOnClass() throws ExecutionException, InterruptedException {
    final ResourceConfig resourceConfig = new ResourceConfig(ResourceWithSubresourceLocatorOnClass.class).register(FilterOne.class).register(FilterTwo.class);
    final ApplicationHandler application = new ApplicationHandler(resourceConfig);
    final ContainerResponse response = application.apply(RequestContextBuilder.from("/sub/submethod", "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));
}
Also used : ContainerResponse(org.glassfish.jersey.server.ContainerResponse) ApplicationHandler(org.glassfish.jersey.server.ApplicationHandler) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 54 with ResourceConfig

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

use of org.glassfish.jersey.server.ResourceConfig 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);
}
Also used : HashMap(java.util.HashMap) ApplicationHandler(org.glassfish.jersey.server.ApplicationHandler) MediaType(javax.ws.rs.core.MediaType) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) Before(org.junit.Before)

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