Search in sources :

Example 46 with ApplicationHandler

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

the class ResourceInfoTest method testGetSubResource.

@Test
public void testGetSubResource() throws ExecutionException, InterruptedException {
    ApplicationHandler handler = getApplication();
    final ContainerResponse response = handler.apply(RequestContextBuilder.from("/resource/locator", "GET").build()).get();
    assertEquals(200, response.getStatus());
    assertEquals("get-sub-resource", response.getEntity());
    assertResponseHeaders(response, "SubResource", "getFromSubResource");
}
Also used : ContainerResponse(org.glassfish.jersey.server.ContainerResponse) ApplicationHandler(org.glassfish.jersey.server.ApplicationHandler) Test(org.junit.Test)

Example 47 with ApplicationHandler

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

the class ResourceInfoTest method testGetMultiple.

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

Example 48 with ApplicationHandler

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

the class ResourceInfoTest method testGetChild.

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

Example 49 with ApplicationHandler

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

the class ResourceInfoTest method testInfoGet.

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

Example 50 with ApplicationHandler

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

the class ParamConverterInternalTest method testLazyConverter.

@Test
public void testLazyConverter() throws Exception {
    final ApplicationHandler application = new ApplicationHandler(new ResourceConfig(MyLazyParamProvider.class, Resource.class));
    final ContainerResponse response = application.apply(RequestContextBuilder.from("/resource", "GET").build()).get();
    assertEquals(400, 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)

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