use of org.glassfish.jersey.server.RequestContextBuilder in project jersey by jersey.
the class AcceptAnnotatedReaderWriterTest method _test.
private void _test(ApplicationHandler app, String expected, String method, Object entity, String mediaType, String... accept) throws ExecutionException, InterruptedException {
RequestContextBuilder requestContextBuilder = RequestContextBuilder.from("/", method);
if (entity != null) {
requestContextBuilder.entity(entity).type(mediaType);
}
ContainerRequest requestContext = requestContextBuilder.accept(accept).build();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
final ContainerResponse response = app.apply(requestContext, baos).get();
assertThat(response.getStatus(), equalTo(Response.Status.OK.getStatusCode()));
assertThat(baos.toString(), equalTo(expected));
}
use of org.glassfish.jersey.server.RequestContextBuilder in project jersey by jersey.
the class AcceptWriterTest method _test.
private void _test(ApplicationHandler app, String expected, String method, Object entity, String mediaType, String... accept) throws ExecutionException, InterruptedException {
RequestContextBuilder requestContextBuilder = RequestContextBuilder.from("/", method);
if (entity != null) {
requestContextBuilder.entity(entity).type(mediaType);
}
ContainerRequest requestContext = requestContextBuilder.accept(accept).build();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
app.apply(requestContext, baos);
assertEquals(expected, baos.toString());
}
use of org.glassfish.jersey.server.RequestContextBuilder in project jersey by jersey.
the class EncodedParamsTest method testEncodedOnFormParameters.
@Test
public void testEncodedOnFormParameters() throws ExecutionException, InterruptedException {
initiateWebApplication(EncodedOnFormParameters.class);
final RequestContextBuilder requestBuilder = RequestContextBuilder.from("/", "POST").type(MediaType.APPLICATION_FORM_URLENCODED).entity(new Form("u", "ลก"));
apply(requestBuilder.build());
}
use of org.glassfish.jersey.server.RequestContextBuilder in project jersey by jersey.
the class AbstractTest method getResponseContext.
protected ContainerResponse getResponseContext(String requestUri, String accept, Cookie... cookies) throws ExecutionException, InterruptedException {
RequestContextBuilder requestBuilder = RequestContextBuilder.from(requestUri, "GET");
if (accept != null) {
requestBuilder = requestBuilder.accept(accept);
}
requestBuilder = requestBuilder.cookies(cookies);
return apply(requestBuilder.build());
}
use of org.glassfish.jersey.server.RequestContextBuilder in project jersey by jersey.
the class EncodedParamsTest method testEncodedOnPostClass.
@Test
public void testEncodedOnPostClass() throws ExecutionException, InterruptedException {
initiateWebApplication(EncodedOnPostClass.class);
Form form = new Form();
form.param("f", ":f");
RequestContextBuilder requestBuilder = RequestContextBuilder.from("/%20u;m=%20m?q=%20q", "POST").type(MediaType.APPLICATION_FORM_URLENCODED_TYPE).entity(form);
assertEquals("content", apply(requestBuilder.build()).getEntity());
}
Aggregations