Search in sources :

Example 1 with MapPropertiesDelegate

use of org.glassfish.jersey.internal.MapPropertiesDelegate in project jersey by jersey.

the class PropertyValidationTest method assertApply.

private void assertApply(int responseStatus, ResourceConfig resourceConfig, URI uri) throws InterruptedException, ExecutionException {
    final ApplicationHandler applicationHandler = new ApplicationHandler(resourceConfig);
    final ContainerRequest requestContext = new ContainerRequest(uri, uri, "POST", null, new MapPropertiesDelegate());
    final ContainerResponse containerResponse = applicationHandler.apply(requestContext).get();
    assertEquals(responseStatus, containerResponse.getStatus());
}
Also used : MapPropertiesDelegate(org.glassfish.jersey.internal.MapPropertiesDelegate) ContainerResponse(org.glassfish.jersey.server.ContainerResponse) ApplicationHandler(org.glassfish.jersey.server.ApplicationHandler) ContainerRequest(org.glassfish.jersey.server.ContainerRequest)

Example 2 with MapPropertiesDelegate

use of org.glassfish.jersey.internal.MapPropertiesDelegate in project jersey by jersey.

the class ContainerRequestTest method testMethod.

@Test
public void testMethod() {
    ContainerRequest r = new ContainerRequest(URI.create("http://example.org/app"), URI.create("http://example.org/app/resource"), "GET", SECURITY_CONTEXT, new MapPropertiesDelegate());
    assertEquals(r.getMethod(), "GET");
}
Also used : MapPropertiesDelegate(org.glassfish.jersey.internal.MapPropertiesDelegate) Test(org.junit.Test)

Example 3 with MapPropertiesDelegate

use of org.glassfish.jersey.internal.MapPropertiesDelegate in project jersey by jersey.

the class ContainerRequestTest method testPreconditionsMatch.

@Test
public void testPreconditionsMatch() {
    ContainerRequest r = new ContainerRequest(URI.create("http://example.org/app"), URI.create("http://example.org/app/resource"), "GET", SECURITY_CONTEXT, new MapPropertiesDelegate());
    r.header(HttpHeaders.IF_MATCH, "\"686897696a7c876b7e\"");
    assertNull(r.evaluatePreconditions(new EntityTag("686897696a7c876b7e")));
    assertEquals(r.evaluatePreconditions(new EntityTag("0")).build().getStatus(), Response.Status.PRECONDITION_FAILED.getStatusCode());
}
Also used : MapPropertiesDelegate(org.glassfish.jersey.internal.MapPropertiesDelegate) EntityTag(javax.ws.rs.core.EntityTag) Test(org.junit.Test)

Example 4 with MapPropertiesDelegate

use of org.glassfish.jersey.internal.MapPropertiesDelegate in project jersey by jersey.

the class ContainerRequestTest method testSelectVariant.

@Test
public void testSelectVariant() {
    ContainerRequest r = new ContainerRequest(URI.create("http://example.org/app"), URI.create("http://example.org/app/resource"), "GET", SECURITY_CONTEXT, new MapPropertiesDelegate());
    r.header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
    r.header(HttpHeaders.ACCEPT_LANGUAGE, "en");
    List<Variant> lv = Variant.mediaTypes(MediaType.APPLICATION_XML_TYPE, MediaType.APPLICATION_JSON_TYPE).languages(Locale.ENGLISH, Locale.FRENCH).add().build();
    assertEquals(r.selectVariant(lv).getMediaType(), MediaType.APPLICATION_JSON_TYPE);
    assertEquals(r.selectVariant(lv).getLanguage(), Locale.ENGLISH);
}
Also used : Variant(javax.ws.rs.core.Variant) MapPropertiesDelegate(org.glassfish.jersey.internal.MapPropertiesDelegate) Test(org.junit.Test)

Example 5 with MapPropertiesDelegate

use of org.glassfish.jersey.internal.MapPropertiesDelegate in project jersey by jersey.

the class JsonProcessingAutoDiscoverableServerTest method _test.

private void _test(final String response, final Boolean globalDisable, final Boolean serverDisable) throws Exception {
    final ResourceConfig resourceConfig = new ResourceConfig(Resource.class, Filter.class);
    if (globalDisable != null) {
        resourceConfig.property(CommonProperties.JSON_PROCESSING_FEATURE_DISABLE, globalDisable);
    }
    if (serverDisable != null) {
        resourceConfig.property(ServerProperties.JSON_PROCESSING_FEATURE_DISABLE, serverDisable);
    }
    final ApplicationHandler app = new ApplicationHandler(resourceConfig);
    final URI baseUri = URI.create("/");
    assertEquals(response, app.apply(new ContainerRequest(baseUri, baseUri, "GET", null, new MapPropertiesDelegate())).get().getEntity());
}
Also used : MapPropertiesDelegate(org.glassfish.jersey.internal.MapPropertiesDelegate) ApplicationHandler(org.glassfish.jersey.server.ApplicationHandler) ContainerRequest(org.glassfish.jersey.server.ContainerRequest) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) URI(java.net.URI)

Aggregations

MapPropertiesDelegate (org.glassfish.jersey.internal.MapPropertiesDelegate)16 Test (org.junit.Test)9 ContainerRequest (org.glassfish.jersey.server.ContainerRequest)6 URI (java.net.URI)4 IOException (java.io.IOException)3 ContainerResponse (org.glassfish.jersey.server.ContainerResponse)3 ContainerResponseWriter (org.glassfish.jersey.server.spi.ContainerResponseWriter)3 URISyntaxException (java.net.URISyntaxException)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Date (java.util.Date)2 EntityTag (javax.ws.rs.core.EntityTag)2 ApplicationHandler (org.glassfish.jersey.server.ApplicationHandler)2 ContainerException (org.glassfish.jersey.server.ContainerException)2 HttpsExchange (com.sun.net.httpserver.HttpsExchange)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 OutputStream (java.io.OutputStream)1 Annotation (java.lang.annotation.Annotation)1 Principal (java.security.Principal)1 ServletException (javax.servlet.ServletException)1