### Question:
HttpHandlerGenerator { HttpHandlerGenerator(TransactionControl defaultTxControl) { this.defaultTxControl = defaultTxControl; } HttpHandlerGenerator(TransactionControl defaultTxControl);   }### Answer:
@Test public void testHttpHandlerGenerator() throws Exception { HttpHandlerFactory factory = new HttpHandlerFactory("/prefix", TransactionControl.IMPLICIT); HttpHandler httpHandler = factory.createHttpHandler( TypeToken.of(MyHttpHandler.class), new AbstractDelegatorContext<MyHttpHandler>() { @Override protected MyHttpHandler createHandler() { return new MyHttpHandler(); } }, new NoopMetricsContext()); HttpHandler httpHandlerWithoutAnnotation = factory.createHttpHandler( TypeToken.of(NoAnnotationHandler.class), new AbstractDelegatorContext<NoAnnotationHandler>() { @Override protected NoAnnotationHandler createHandler() { return new NoAnnotationHandler(); } }, new NoopMetricsContext()); NettyHttpService service = NettyHttpService.builder("test-handler-generator") .setHttpHandlers(httpHandler, httpHandlerWithoutAnnotation) .build(); service.start(); try { InetSocketAddress bindAddress = service.getBindAddress(); URLConnection urlConn = new URL(String.format("http: bindAddress.getHostName(), bindAddress.getPort())).openConnection(); urlConn.setReadTimeout(2000); Assert.assertEquals("Hello World", new String(ByteStreams.toByteArray(urlConn.getInputStream()), Charsets.UTF_8)); urlConn = new URL(String.format("http: bindAddress.getHostName(), bindAddress.getPort())).openConnection(); urlConn.setReadTimeout(2000); urlConn.setDoOutput(true); ByteStreams.copy(ByteStreams.newInputStreamSupplier("Hello".getBytes(Charsets.UTF_8)), urlConn.getOutputStream()); Assert.assertEquals("Hello test", new String(ByteStreams.toByteArray(urlConn.getInputStream()), Charsets.UTF_8)); urlConn = new URL(String.format("http: .openConnection(); urlConn.setReadTimeout(2000); Assert.assertEquals("OK", new String(ByteStreams.toByteArray(urlConn.getInputStream()), Charsets.UTF_8)); urlConn = new URL(String.format("http: bindAddress.getHostName(), bindAddress.getPort())).openConnection(); Assert.assertEquals(500, ((HttpURLConnection) urlConn).getResponseCode()); Assert.assertEquals("Exception occurred while handling request: exception", new String(ByteStreams.toByteArray(((HttpURLConnection) urlConn).getErrorStream()), "UTF-8")); urlConn = new URL(String.format("http: bindAddress.getHostName(), bindAddress.getPort())).openConnection(); Assert.assertEquals(500, ((HttpURLConnection) urlConn).getResponseCode()); Assert.assertEquals("Exception occurred while handling request: exceptionNoTx", new String(ByteStreams.toByteArray(((HttpURLConnection) urlConn).getErrorStream()), "UTF-8")); } finally { service.stop(); } }