use of org.glassfish.jersey.server.RequestContextBuilder in project jersey by jersey.
the class EncodedParamsTest method testCombinedEncodedOnPostClass.
@Test
public void testCombinedEncodedOnPostClass() throws ExecutionException, InterruptedException {
initiateWebApplication(EncodedOnPostClass.class);
Form form = new Form();
form.param("f", ":f");
form.param("f2", ":f2");
RequestContextBuilder requestBuilder = RequestContextBuilder.from("/%20u/combined;m=%20m?q=%20q", "POST").type(MediaType.APPLICATION_FORM_URLENCODED_TYPE).entity(form);
assertEquals("content", apply(requestBuilder.build()).getEntity());
}
use of org.glassfish.jersey.server.RequestContextBuilder in project jersey by jersey.
the class EncodingFilterTest method testEncoding.
private void testEncoding(String expected, String... accepted) throws IOException {
EncodingFilter filter = initializeAndGetFilter();
RequestContextBuilder builder = RequestContextBuilder.from("/resource", "GET");
for (String a : accepted) {
builder.header(HttpHeaders.ACCEPT_ENCODING, a);
}
ContainerRequest request = builder.build();
ContainerResponse response = new ContainerResponse(request, Response.ok("OK!").build());
filter.filter(request, response);
if (response.getStatus() != 200) {
throw new WebApplicationException(Response.status(response.getStatus()).build());
}
assertEquals(expected, response.getHeaderString(HttpHeaders.CONTENT_ENCODING));
assertEquals(HttpHeaders.ACCEPT_ENCODING, response.getHeaderString(HttpHeaders.VARY));
}
Aggregations