Search in sources :

Example 21 with ContainerResponse

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

the class OptionsTest method testNoHead.

@Test
public void testNoHead() throws ExecutionException, InterruptedException {
    ApplicationHandler application = new ApplicationHandler(new ResourceConfig(ResourceWithoutGetMethod.class));
    final ContainerResponse response = testOptions(MediaType.TEXT_PLAIN_TYPE, application, "/no-get");
    Assert.assertFalse(((String) response.getEntity()).contains("HEAD"));
}
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 ContainerResponse

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

the class RMBuilderTest method testHelloWorld.

@Test
public void testHelloWorld() throws Exception {
    ApplicationHandler app = createApplication(HelloWorldResource.class);
    ContainerResponse response = app.apply(RequestContextBuilder.from("/helloworld", "GET").build()).get();
    assertEquals("hello", response.getEntity());
}
Also used : ContainerResponse(org.glassfish.jersey.server.ContainerResponse) ApplicationHandler(org.glassfish.jersey.server.ApplicationHandler) Test(org.junit.Test)

Example 23 with ContainerResponse

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

the class ConsumeProduceSimpleTest method testImplicitProduces.

@Test
public void testImplicitProduces() throws Exception {
    final ApplicationHandler application = createApplication(ImplicitProducesResource.class);
    final ContainerResponse response = application.apply(RequestContextBuilder.from("/", "GET").accept(MediaType.TEXT_PLAIN_TYPE).build()).get();
    assertEquals("text/plain", response.getEntity());
    assertEquals("text-plain", response.getHeaderString("HEAD"));
}
Also used : ContainerResponse(org.glassfish.jersey.server.ContainerResponse) ApplicationHandler(org.glassfish.jersey.server.ApplicationHandler) Test(org.junit.Test)

Example 24 with ContainerResponse

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

the class DynamicFeatureTest method testSubResourceFeature.

@Test
public void testSubResourceFeature() throws Exception {
    final ApplicationHandler application = createApplication(SubResourceDynamicFeature.class);
    ContainerResponse response;
    response = application.apply(RequestContextBuilder.from("/resource/sub", "GET").build()).get();
    assertEquals(200, response.getStatus());
    assertEquals("sub-get-filtered", response.getEntity());
    response = application.apply(RequestContextBuilder.from("/resource", "GET").build()).get();
    assertEquals(200, response.getStatus());
    assertEquals("get", response.getEntity());
}
Also used : ContainerResponse(org.glassfish.jersey.server.ContainerResponse) ApplicationHandler(org.glassfish.jersey.server.ApplicationHandler) Test(org.junit.Test)

Example 25 with ContainerResponse

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

the class DynamicFeatureTest method testInjectedConfigurable.

@Test
public void testInjectedConfigurable() throws Exception {
    final ResourceConfig resourceConfig = getTestResourceConfig(InjectConfigurableDynamicFeature.class);
    resourceConfig.property("hello", "world");
    final ApplicationHandler application = createApplication(resourceConfig);
    assertNull(application.getConfiguration().getProperty("foo"));
    final ContainerResponse response = application.apply(RequestContextBuilder.from("/resource", "GET").build()).get();
    assertEquals(200, response.getStatus());
    assertEquals("get", response.getEntity());
    assertNull(application.getConfiguration().getProperty("foo"));
    assertEquals("world", application.getConfiguration().getProperty("hello"));
}
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

ContainerResponse (org.glassfish.jersey.server.ContainerResponse)211 Test (org.junit.Test)190 ApplicationHandler (org.glassfish.jersey.server.ApplicationHandler)95 ResourceConfig (org.glassfish.jersey.server.ResourceConfig)58 MediaType (javax.ws.rs.core.MediaType)16 Form (javax.ws.rs.core.Form)14 ContainerRequest (org.glassfish.jersey.server.ContainerRequest)14 Cookie (javax.ws.rs.core.Cookie)7 Response (javax.ws.rs.core.Response)5 Ignore (org.junit.Ignore)4 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 ContainerRequestContext (javax.ws.rs.container.ContainerRequestContext)2 ContainerResponseFilter (javax.ws.rs.container.ContainerResponseFilter)2 ContainerException (org.glassfish.jersey.server.ContainerException)2 RequestContextBuilder (org.glassfish.jersey.server.RequestContextBuilder)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 ParameterizedType (java.lang.reflect.ParameterizedType)1 URI (java.net.URI)1 HashSet (java.util.HashSet)1