ServerErrorHandler serverErrorHandler = (context, throwable1) -> {
DefaultHandlingResult.this.throwable = throwable1;
latch.countDown();
};
final Registry userRegistry = Registries.registry().
add(ClientErrorHandler.class, clientErrorHandler).
add(ServerErrorHandler.class, serverErrorHandler).
build()
.join(registry);
final RenderController renderController = (object, context) -> {
rendered = object;
latch.countDown();
};
Stopper stopper = () -> {
throw new UnsupportedOperationException("stopping not supported while unit testing");
};
ResponseTransmitter responseTransmitter = new ResponseTransmitter() {
@Override
public void transmit(HttpResponseStatus status, ByteBuf byteBuf) {
sentResponse = true;
body = new byte[byteBuf.readableBytes()];
byteBuf.readBytes(body);
byteBuf.release();
eventController.fire(new DefaultRequestOutcome(request, new DefaultSentResponse(headers, new DefaultStatus(status)), System.currentTimeMillis()));
latch.countDown();
}
@Override
public void transmit(HttpResponseStatus responseStatus, BasicFileAttributes basicFileAttributes, Path file) {
sentFile = file;
eventController.fire(new DefaultRequestOutcome(request, new DefaultSentResponse(headers, status), System.currentTimeMillis()));
latch.countDown();
}
@Override
public Subscriber<ByteBuf> transmitter(HttpResponseStatus status) {
throw new UnsupportedOperationException("streaming not supported while unit testing");
}
};
ExecControl execControl = launchConfig.getExecController().getControl();
Registry baseRegistry = NettyHandlerAdapter.buildBaseRegistry(stopper, launchConfig);
Registry effectiveRegistry = baseRegistry.join(userRegistry);
Response response = new DefaultResponse(execControl, responseHeaders, launchConfig.getBufferAllocator(), responseTransmitter);
DefaultContext.ApplicationConstants applicationConstants = new DefaultContext.ApplicationConstants(launchConfig, renderController, next);
requestConstants = new DefaultContext.RequestConstants(
applicationConstants, bindAddress, request, response, null, eventController.getRegistry()
);