Search in sources :

Example 21 with ResourceConfig

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

the class AmbiguousTemplateTest method testPathParamOnAmbiguousTemplate3.

@Test
public void testPathParamOnAmbiguousTemplate3() throws ExecutionException, InterruptedException {
    final ApplicationHandler applicationHandler = new ApplicationHandler(new ResourceConfig(ResourceABC.class, ResourceXYZ.class));
    final ContainerResponse response = applicationHandler.apply(RequestContextBuilder.from("/uuu", "GET").build()).get();
    Assert.assertEquals(200, response.getStatus());
    Assert.assertEquals("abc:uuu", 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 22 with ResourceConfig

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

the class AmbiguousTemplateTest method testPathParamOnAmbiguousTemplateTroughSubResourceLocator1.

@Test
public void testPathParamOnAmbiguousTemplateTroughSubResourceLocator1() throws ExecutionException, InterruptedException {
    final ApplicationHandler applicationHandler = new ApplicationHandler(new ResourceConfig(SimpleLocator.class));
    final ContainerResponse response = applicationHandler.apply(RequestContextBuilder.from("/locator/abc/uuu/a", "GET").build()).get();
    Assert.assertEquals(404, response.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 23 with ResourceConfig

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

the class AmbiguousTemplateTest method testGetOnChild.

@Test
public void testGetOnChild() throws ExecutionException, InterruptedException {
    ResourceConfig resourceConfig = new ResourceConfig(ResourceA.class, ResourceB.class, ResourceQ.class);
    ApplicationHandler app = new ApplicationHandler(resourceConfig);
    final ContainerResponse containerResponse = app.apply(RequestContextBuilder.from("/resq/a", "GET").build()).get();
    Assert.assertEquals(200, containerResponse.getStatus());
    Assert.assertEquals("getA", containerResponse.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 24 with ResourceConfig

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

the class AmbiguousTemplateTest method testOptionsOnRoot.

@Test
public void testOptionsOnRoot() throws ExecutionException, InterruptedException {
    ResourceConfig resourceConfig = new ResourceConfig(ResourceA.class, ResourceB.class, ResourceQ.class);
    ApplicationHandler app = new ApplicationHandler(resourceConfig);
    final ContainerResponse containerResponse = app.apply(RequestContextBuilder.from("/aaa", "OPTIONS").accept(MediaType.TEXT_PLAIN).build()).get();
    Assert.assertEquals(200, containerResponse.getStatus());
    final List<String> methods = Arrays.asList(containerResponse.getEntity().toString().split(", "));
    assertThat(methods, hasItems("POST", "GET", "OPTIONS", "HEAD"));
    assertThat(methods.size(), is(4));
}
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 25 with ResourceConfig

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

the class SpringDevProfileResourceTest method configure.

@Override
protected Application configure() {
    System.setProperty("spring.profiles.active", "dev");
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext("org.glassfish.jersey.server.spring.profiles");
    return new ResourceConfig().register(RequestContextFilter.class).register(LoggingFeature.class).packages("org.glassfish.jersey.server.spring.profiles").property("contextConfig", context);
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) RequestContextFilter(org.glassfish.jersey.server.spring.scope.RequestContextFilter) ResourceConfig(org.glassfish.jersey.server.ResourceConfig)

Aggregations

ResourceConfig (org.glassfish.jersey.server.ResourceConfig)358 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 URI (java.net.URI)24 Resource (org.glassfish.jersey.server.model.Resource)24 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