@Test public void testInvokeSetsTimeout() { MessageContext messageContext = new MessageContext(axisEngine); messageContext.setRequestMessage(requestMessage); messageContext.setProperty(MessageContext.TRANS_URL, "https: MockLowLevelHttpResponse lowLevelHttpResponse = new MockLowLevelHttpResponse(); lowLevelHttpResponse.setContent("Intentional failure"); lowLevelHttpResponse.setStatusCode(302); int timeout = 1234567; messageContext.setTimeout(timeout); final int[] actualTimeouts = new int[] {Integer.MIN_VALUE, Integer.MIN_VALUE}; MockLowLevelHttpRequest lowLevelHttpRequest = new MockLowLevelHttpRequest() { @Override public void setTimeout(int connectTimeout, int readTimeout) throws IOException { actualTimeouts[0] = connectTimeout; actualTimeouts[1] = readTimeout; super.setTimeout(connectTimeout, readTimeout); } }; lowLevelHttpRequest.setResponse(lowLevelHttpResponse); MockHttpTransport mockTransport = new MockHttpTransport.Builder().setLowLevelHttpRequest(lowLevelHttpRequest).build(); httpHandler = new HttpHandler(mockTransport, streamListener); try { httpHandler.invoke(messageContext); fail("Expected an AxisFault"); } catch (AxisFault e) { assertThat(e.getFaultString(), Matchers.containsString("302")); } assertArrayEquals( "Timeouts not set to expected values", new int[] {timeout, timeout}, actualTimeouts); }
@Override public void invoke(MessageContext msgContext) throws AxisFault { if (msgContext == null) { throw AxisFault.makeFault(new NullPointerException("Null message context")); } try { HttpResponse response = null; HttpRequest postRequest = createHttpRequest(msgContext); response = postRequest.execute(); msgContext.setResponseMessage(createResponseMessage(response)); } catch (RuntimeException | SOAPException | IOException e) { throw AxisFault.makeFault(e); } }
HttpHandler extends BasicHandler implements HttpRequestInitializer { @Override public void invoke(MessageContext msgContext) throws AxisFault { if (msgContext == null) { throw AxisFault.makeFault(new NullPointerException("Null message context")); } try { HttpResponse response = null; HttpRequest postRequest = createHttpRequest(msgContext); response = postRequest.execute(); msgContext.setResponseMessage(createResponseMessage(response)); } catch (RuntimeException | SOAPException | IOException e) { throw AxisFault.makeFault(e); } } }
HttpHandler extends BasicHandler implements HttpRequestInitializer { @Override public void invoke(MessageContext msgContext) throws AxisFault { if (msgContext == null) { throw AxisFault.makeFault(new NullPointerException("Null message context")); } try { HttpResponse response = null; HttpRequest postRequest = createHttpRequest(msgContext); response = postRequest.execute(); msgContext.setResponseMessage(createResponseMessage(response)); } catch (RuntimeException | SOAPException | IOException e) { throw AxisFault.makeFault(e); } } HttpHandler(); @VisibleForTesting  HttpHandler(HttpTransport transport, InputStreamEventListener inputStreamEventListener); }
HttpHandler extends BasicHandler implements HttpRequestInitializer { @Override public void invoke(MessageContext msgContext) throws AxisFault { if (msgContext == null) { throw AxisFault.makeFault(new NullPointerException("Null message context")); } try { HttpResponse response = null; HttpRequest postRequest = createHttpRequest(msgContext); response = postRequest.execute(); msgContext.setResponseMessage(createResponseMessage(response)); } catch (RuntimeException | SOAPException | IOException e) { throw AxisFault.makeFault(e); } } HttpHandler(); @VisibleForTesting  HttpHandler(HttpTransport transport, InputStreamEventListener inputStreamEventListener); @Override void invoke(MessageContext msgContext); @Override void initialize(HttpRequest httpRequest); }
HttpHandler extends BasicHandler implements HttpRequestInitializer { @Override public void invoke(MessageContext msgContext) throws AxisFault { if (msgContext == null) { throw AxisFault.makeFault(new NullPointerException("Null message context")); } try { HttpResponse response = null; HttpRequest postRequest = createHttpRequest(msgContext); response = postRequest.execute(); msgContext.setResponseMessage(createResponseMessage(response)); } catch (RuntimeException | SOAPException | IOException e) { throw AxisFault.makeFault(e); } } HttpHandler(); @VisibleForTesting  HttpHandler(HttpTransport transport, InputStreamEventListener inputStreamEventListener); @Override void invoke(MessageContext msgContext); @Override void initialize(HttpRequest httpRequest);  }