HttpServerHandler extends SimpleChannelInboundHandler<FullHttpRequest> { @Override public void exceptionCaught(final ChannelHandlerContext context, final Throwable cause) { log.warn("Http request handle occur error:", cause); response(GSON.toJson(ResponseContentUtil.handleException(cause.toString())), context, HttpResponseStatus.INTERNAL_SERVER_ERROR); context.close(); }  @Override void exceptionCaught(final ChannelHandlerContext context, final Throwable cause);  }
@Test public void assertExceptionCaught() { Throwable throwable = mock(Throwable.class); httpServerHandler.exceptionCaught(channelHandlerContext, throwable); verify(channelHandlerContext).close(); }