### Question:
NettyHttpDestination extends AbstractHTTPDestination { protected void doService(HttpServletRequest req, HttpServletResponse resp) throws IOException { doService(servletContext, req, resp); } NettyHttpDestination(Bus b, DestinationRegistry registry,
                                EndpointInfo ei, NettyHttpServerEngineFactory serverEngineFactory); void finalizeConfig(); ServerEngine getEngine(); ServletContext getServletContext(); void setServletContext(ServletContext servletContext);  }### Answer:
@Test public void testSuspendedException() throws Exception { destination = setUpDestination(false, false); setUpDoService(false); final RuntimeException ex = new RuntimeException(); observer = new MessageObserver() { public void onMessage(Message m) { throw new SuspendedInvocationException(ex); } }; destination.setMessageObserver(observer); try { destination.doService(request, response); fail("Suspended invocation swallowed"); } catch (RuntimeException runtimeEx) { assertSame("Original exception is not preserved", ex, runtimeEx); } }
@Test public void testDoServiceRedirectURL() throws Exception { destination = setUpDestination(false, false); setUpDoService(true); destination.doService(request, response); }
@Test public void testDoService() throws Exception { Bus defaultBus = new ExtensionManagerBus(); assertSame("Default thread bus has not been set", defaultBus, BusFactory.getThreadDefaultBus()); destination = setUpDestination(false, false); setUpDoService(false); assertSame("Default thread bus has been unexpectedly reset", defaultBus, BusFactory.getThreadDefaultBus()); destination.doService(request, response); verifyDoService(); assertSame("Default thread bus has not been reset", defaultBus, BusFactory.getThreadDefaultBus()); }
@Test public void testDoServiceWithHttpGET() throws Exception { destination = setUpDestination(false, false); setUpDoService(false, false, false, "GET", "?customerId=abc&cutomerAdd=def", 200); destination.doService(request, response); assertNotNull("unexpected null message", inMessage); assertEquals("unexpected method", inMessage.get(Message.HTTP_REQUEST_METHOD), "GET"); assertEquals("unexpected path", inMessage.get(Message.PATH_INFO), "/bar/foo"); assertEquals("unexpected query", inMessage.get(Message.QUERY_STRING), "?customerId=abc&cutomerAdd=def"); }
@Test public void testGetBackChannelSend() throws Exception { destination = setUpDestination(false, false); setUpDoService(false, true); destination.doService(request, response); setUpInMessage(); Conduit backChannel = destination.getBackChannel(inMessage); outMessage = setUpOutMessage(); backChannel.prepare(outMessage); verifyBackChannelSend(backChannel, outMessage, 200); }
@Test public void testGetBackChannelSendFault() throws Exception { destination = setUpDestination(false, false); setUpDoService(false, true, 500); destination.doService(request, response); setUpInMessage(); Conduit backChannel = destination.getBackChannel(inMessage); outMessage = setUpOutMessage(); backChannel.prepare(outMessage); verifyBackChannelSend(backChannel, outMessage, 500); }
@Test public void testGetBackChannelSendOneway() throws Exception { destination = setUpDestination(false, false); setUpDoService(false, true, 500); destination.doService(request, response); setUpInMessage(); Conduit backChannel = destination.getBackChannel(inMessage); outMessage = setUpOutMessage(); backChannel.prepare(outMessage); verifyBackChannelSend(backChannel, outMessage, 500, true); }
@Test public void testGetBackChannelSendDecoupled() throws Exception { destination = setUpDestination(false, false); setUpDoService(false, true, true, 202); destination.doService(request, response); setUpInMessage(); Message partialResponse = setUpOutMessage(); partialResponse.put(Message.PARTIAL_RESPONSE_MESSAGE, Boolean.TRUE); Conduit partialBackChannel = destination.getBackChannel(inMessage); partialBackChannel.prepare(partialResponse); verifyBackChannelSend(partialBackChannel, partialResponse, 202); outMessage = setUpOutMessage(); Conduit fullBackChannel = destination.getBackChannel(inMessage); fullBackChannel.prepare(outMessage); }