Search in sources :

Example 41 with ApplicationHandler

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

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

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

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

the class ResourceInfoTest method testInfoGetChild.

@Test
public void testInfoGetChild() throws ExecutionException, InterruptedException {
    ApplicationHandler handler = getApplication();
    final ContainerResponse response = handler.apply(RequestContextBuilder.from("/info/child", "GET").build()).get();
    assertEquals(200, response.getStatus());
    assertEquals("get-info-child", response.getEntity());
    assertResponseHeaders(response, "ResourceTestingInfo", "getChildInfo");
}
Also used : ContainerResponse(org.glassfish.jersey.server.ContainerResponse) ApplicationHandler(org.glassfish.jersey.server.ApplicationHandler) Test(org.junit.Test)

Example 45 with ApplicationHandler

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

the class ResourceInfoTest method test404.

@Test
public void test404() throws ExecutionException, InterruptedException {
    ApplicationHandler handler = getApplication();
    final ContainerResponse response = handler.apply(RequestContextBuilder.from("/NOT_FOUND", "GET").build()).get();
    assertEquals(404, response.getStatus());
    assertResponseHeaders(response, "<null>", "<null>");
}
Also used : ContainerResponse(org.glassfish.jersey.server.ContainerResponse) ApplicationHandler(org.glassfish.jersey.server.ApplicationHandler) Test(org.junit.Test)

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