### Question:
PassThroughHttpSender extends AbstractHandler implements TransportSender { public InvocationResponse invoke(org.apache.axis2.context.MessageContext msgContext) throws AxisFault { PassThroughTransportUtils.removeUnwantedHeaders(msgContext, targetConfiguration); if (AddressingHelper.isReplyRedirected(msgContext) && !msgContext.getReplyTo().hasNoneAddress()) { msgContext.setProperty(PassThroughConstants.IGNORE_SC_ACCEPTED, Constants.VALUE_TRUE); } EndpointReference epr = PassThroughTransportUtils.getDestinationEPR(msgContext); if (epr != null) { if (!epr.hasNoneAddress()) { if (msgContext.getProperty(PassThroughConstants.PASS_THROUGH_PIPE) == null) { Pipe pipe = new Pipe(targetConfiguration.getBufferFactory().getBuffer(), "Test", targetConfiguration); msgContext.setProperty(PassThroughConstants.PASS_THROUGH_PIPE, pipe); msgContext.setProperty(PassThroughConstants.MESSAGE_BUILDER_INVOKED, Boolean.TRUE); } boolean forceContentLength = msgContext.isPropertyTrue(NhttpConstants.FORCE_HTTP_CONTENT_LENGTH); boolean forceContentLengthCopy = msgContext .isPropertyTrue(PassThroughConstants.COPY_CONTENT_LENGTH_FROM_INCOMING); if (forceContentLength && forceContentLengthCopy && msgContext.getProperty(PassThroughConstants.ORGINAL_CONTEN_LENGTH) != null) { msgContext.setProperty(PassThroughConstants.PASSTROUGH_MESSAGE_LENGTH, Long.parseLong( (String) msgContext.getProperty(PassThroughConstants.ORGINAL_CONTEN_LENGTH))); } sendRequestContent(msgContext, epr); } else { handleException("Cannot send message to " + AddressingConstants.Final.WSA_NONE_URI); } } else { if (msgContext.getProperty(Constants.OUT_TRANSPORT_INFO) != null) { if (msgContext.getProperty(Constants.OUT_TRANSPORT_INFO) instanceof ServerWorker) { try { submitResponse(msgContext); } catch (Exception e) { handleException("Failed to submit the response", e); } }else { sendUsingOutputStream(msgContext); } } else { handleException("No valid destination EPR to send message"); } } if (msgContext.getOperationContext() != null) { msgContext.getOperationContext().setProperty( Constants.RESPONSE_WRITTEN, Constants.VALUE_TRUE); } return InvocationResponse.CONTINUE; } PassThroughHttpSender(); void init(ConfigurationContext configurationContext,
                     TransportOutDescription transportOutDescription); void cleanup(org.apache.axis2.context.MessageContext messageContext); void stop(); InvocationResponse invoke(org.apache.axis2.context.MessageContext msgContext); void addPreserveHttpHeader(String headerName); void removePreserveHttpHeader(String headerName); void submitResponse(MessageContext msgContext); void pause(); void resume(); void maintenanceShutdown(long millis); void reloadDynamicSSLConfig(TransportOutDescription transport); void setContentType(MessageContext msgContext, SourceResponse sourceResponse, MessageFormatter formatter,
                               OMOutputFormat format, SourceConfiguration sourceConfiguration);  }### Answer:
@Test public void testInvoke() throws Exception { MockitoAnnotations.initMocks(this); MessageContext messageContext = new MessageContext(); messageContext.setProperty(Constants.Configuration.TRANSPORT_URL, "http: messageContext.setProperty(NhttpConstants.FORCE_HTTP_CONTENT_LENGTH, true); messageContext.setProperty(PassThroughConstants.COPY_CONTENT_LENGTH_FROM_INCOMING, true); messageContext.setProperty(PassThroughConstants.ORGINAL_CONTEN_LENGTH, "1000"); messageContext.setOperationContext(new OperationContext()); sender = PowerMockito.spy(sender); PowerMockito.when(targetConfiguration.getBufferFactory()).thenReturn(factory); PowerMockito.doNothing().when(sender, "sendRequestContent", any(MessageContext.class), any(EndpointReference.class)); Handler.InvocationResponse response = sender.invoke(messageContext); Assert.assertNotNull("PassThrough Http Sender not invoked!", response); }