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);
}
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());
}
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());
}
use of org.glassfish.jersey.internal.MapPropertiesDelegate in project jersey by jersey.
the class ContainerRequestTest method testPreconditionsUnModified.
@Test
public void testPreconditionsUnModified() throws ParseException {
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_UNMODIFIED_SINCE, "Sat, 29 Oct 2011 19:43:31 GMT");
SimpleDateFormat f = new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss Z", Locale.ENGLISH);
Date date = f.parse("Sat, 29 Oct 2011 19:43:31 GMT");
assertNull(r.evaluatePreconditions(date));
date = f.parse("Sat, 30 Oct 2011 19:43:31 GMT");
assertEquals(r.evaluatePreconditions(date).build().getStatus(), Response.Status.PRECONDITION_FAILED.getStatusCode());
}
use of org.glassfish.jersey.internal.MapPropertiesDelegate in project jersey by jersey.
the class ContainerRequestTest method testUri.
@Test
public void testUri() throws URISyntaxException {
ContainerRequest r = new ContainerRequest(URI.create("http://example.org/app"), URI.create("http://example.org/app/resource"), "GET", SECURITY_CONTEXT, new MapPropertiesDelegate());
assertEquals(r.getRequestUri(), URI.create("http://example.org/app/resource"));
}
Aggregations