use of org.minijax.rs.MinijaxUriInfo in project minijax by minijax.
the class Connection method process.
private void process() throws IOException {
final MinijaxApplication application = minijax.getDefaultApplication();
try (final MinijaxNioRequestContext ctx = new MinijaxNioRequestContext(application, method, new MinijaxUriInfo(uri), new MinijaxNioHttpHeaders(requestHeaders), requestEntityStream)) {
response = application.handle(ctx);
if (onlyHeader) {
bufferedOutputStream = null;
} else {
bufferedOutputStream = new ByteArrayOutputStream();
EntityUtils.writeEntity(response.getEntity(), response.getMediaType(), ctx.getProviders(), bufferedOutputStream);
}
}
}
use of org.minijax.rs.MinijaxUriInfo in project minijax by minijax.
the class MinijaxTestInvocationBuilder method method.
@Override
public Response method(final String name) {
final Minijax container = target.getServer();
final MinijaxApplication application = container.getApplication(target.getUri());
final MinijaxUriInfo uriInfo = new MinijaxUriInfo(target.getUri());
if (!cookies.isEmpty()) {
headers.add("Cookie", cookies.values().stream().map(c -> c.getName() + "=" + c.getValue()).collect(Collectors.joining("; ")));
}
try (final MinijaxRequestContext clientContext = new MinijaxTestRequestContext(application, name, uriInfo);
final InputStream entityStream = EntityUtils.writeEntity(entity, clientContext.getProviders());
final MinijaxRequestContext serverContext = new MinijaxTestRequestContext(application, name, new MinijaxUriInfo(target.getUri()), new MinijaxTestHttpHeaders(headers), entityStream)) {
return application.handle(serverContext);
} catch (final IOException ex) {
throw ExceptionUtils.toWebAppException(ex);
}
}
Aggregations