### Question:
DefaultDispatch extends AbstractGatewayDispatch { protected void executeRequest( HttpUriRequest outboundRequest, HttpServletRequest inboundRequest, HttpServletResponse outboundResponse) throws IOException { HttpResponse inboundResponse = executeOutboundRequest(outboundRequest); writeOutboundResponse(outboundRequest, inboundRequest, outboundResponse, inboundResponse); }  @Override void destroy(); String getServiceRole(); void setServiceRole(String serviceRole); @Override void doGet(URI url, HttpServletRequest request, HttpServletResponse response); @Override void doOptions(URI url, HttpServletRequest request, HttpServletResponse response); @Override void doPut(URI url, HttpServletRequest request, HttpServletResponse response); @Override void doPatch(URI url, HttpServletRequest request, HttpServletResponse response); @Override void doPost(URI url, HttpServletRequest request, HttpServletResponse response); @Override void doDelete(URI url, HttpServletRequest request, HttpServletResponse response); @Override void doHead(URI url, HttpServletRequest request, HttpServletResponse response); void copyResponseHeaderFields(HttpServletResponse outboundResponse, HttpResponse inboundResponse); Set<String> getOutboundResponseExcludeHeaders(); Set<String> getOutboundResponseExcludedSetCookieHeaderDirectives();  }### Answer:
@Test public void testJiraKnox58() throws URISyntaxException, IOException { URI uri = new URI( "http: BasicHttpParams params = new BasicHttpParams(); HttpUriRequest outboundRequest = EasyMock.createNiceMock( HttpUriRequest.class ); EasyMock.expect( outboundRequest.getMethod() ).andReturn( "GET" ).anyTimes(); EasyMock.expect( outboundRequest.getURI() ).andReturn( uri ).anyTimes(); RequestLine requestLine = EasyMock.createNiceMock( RequestLine.class ); EasyMock.expect( requestLine.getMethod() ).andReturn( "GET" ).anyTimes(); EasyMock.expect( requestLine.getProtocolVersion() ).andReturn( HttpVersion.HTTP_1_1 ).anyTimes(); EasyMock.expect( outboundRequest.getRequestLine() ).andReturn( requestLine ).anyTimes(); EasyMock.expect( outboundRequest.getParams() ).andReturn( params ).anyTimes(); HttpServletRequest inboundRequest = EasyMock.createNiceMock( HttpServletRequest.class ); HttpServletResponse outboundResponse = EasyMock.createNiceMock( HttpServletResponse.class ); EasyMock.expect( outboundResponse.getOutputStream() ).andAnswer( new IAnswer<SynchronousServletOutputStreamAdapter>() { @Override public SynchronousServletOutputStreamAdapter answer() throws Throwable { return new SynchronousServletOutputStreamAdapter() { @Override public void write( int b ) throws IOException { throw new IOException( "unreachable-host.invalid" ); } }; } }); EasyMock.replay( outboundRequest, inboundRequest, outboundResponse, requestLine ); DefaultDispatch dispatch = new DefaultDispatch(); HttpClientBuilder builder = HttpClientBuilder.create(); CloseableHttpClient client = builder.build(); dispatch.setHttpClient(client); try { dispatch.executeRequest( outboundRequest, inboundRequest, outboundResponse ); fail( "Should have thrown IOException" ); } catch( IOException e ) { assertThat( e.getMessage(), not( containsString( "unreachable-host.invalid" ) ) ); assertThat( e, not( instanceOf( UnknownHostException.class ) ) ) ; assertThat( "Message needs meaningful content.", e.getMessage().trim().length(), greaterThan( 12 ) ); } }