@Test public void testNormalTwoIntercptors() throws Exception { MessageContext messageContext = createMock(MessageContext.class); WebServiceMessageReceiver messageReceiver = createMock(WebServiceMessageReceiver.class); ClientInterceptor interceptor1 = createMock(ClientInterceptor.class); ClientInterceptor interceptor2 = createMock(ClientInterceptor.class); messageReceiver.receive(messageContext); expect(interceptor1.handleRequest(messageContext)).andReturn(true); expect(interceptor1.handleResponse(messageContext)).andReturn(true); expect(interceptor2.handleRequest(messageContext)).andReturn(true); expect(interceptor2.handleResponse(messageContext)).andReturn(true); expect(messageContext.hasResponse()).andReturn(false); expect(messageContext.hasResponse()).andReturn(true).atLeastOnce(); expect(messageContext.getResponse()).andReturn(null); replay(messageReceiver, interceptor1, interceptor2, messageContext); InterceptingTemplate template = new InterceptingTemplate(new ClientInterceptor[]{interceptor1, interceptor2}); template.interceptRequest(messageContext, messageReceiver); verify(messageReceiver, interceptor1, interceptor2, messageContext); }
public void interceptRequest(MessageContext messageContext, WebServiceMessageReceiver messageReceiver) throws Exception { int interceptorIndex = -1; if (interceptors != null) { for (int i = 0; i < interceptors.length; i++) { interceptorIndex = i; if (!interceptors[i].handleRequest(messageContext)) { break; } } } if (!messageContext.hasResponse()) { messageReceiver.receive(messageContext); } if (messageContext.hasResponse()) { if (!hasFault(messageContext.getResponse())) { triggerHandleResponse(interceptorIndex, messageContext); } else { triggerHandleFault(interceptorIndex, messageContext); } } }
InterceptingTemplate { public void interceptRequest(MessageContext messageContext, WebServiceMessageReceiver messageReceiver) throws Exception { int interceptorIndex = -1; if (interceptors != null) { for (int i = 0; i < interceptors.length; i++) { interceptorIndex = i; if (!interceptors[i].handleRequest(messageContext)) { break; } } } if (!messageContext.hasResponse()) { messageReceiver.receive(messageContext); } if (messageContext.hasResponse()) { if (!hasFault(messageContext.getResponse())) { triggerHandleResponse(interceptorIndex, messageContext); } else { triggerHandleFault(interceptorIndex, messageContext); } } } }
InterceptingTemplate { public void interceptRequest(MessageContext messageContext, WebServiceMessageReceiver messageReceiver) throws Exception { int interceptorIndex = -1; if (interceptors != null) { for (int i = 0; i < interceptors.length; i++) { interceptorIndex = i; if (!interceptors[i].handleRequest(messageContext)) { break; } } } if (!messageContext.hasResponse()) { messageReceiver.receive(messageContext); } if (messageContext.hasResponse()) { if (!hasFault(messageContext.getResponse())) { triggerHandleResponse(interceptorIndex, messageContext); } else { triggerHandleFault(interceptorIndex, messageContext); } } } InterceptingTemplate(ClientInterceptor[] interceptors); }
InterceptingTemplate { public void interceptRequest(MessageContext messageContext, WebServiceMessageReceiver messageReceiver) throws Exception { int interceptorIndex = -1; if (interceptors != null) { for (int i = 0; i < interceptors.length; i++) { interceptorIndex = i; if (!interceptors[i].handleRequest(messageContext)) { break; } } } if (!messageContext.hasResponse()) { messageReceiver.receive(messageContext); } if (messageContext.hasResponse()) { if (!hasFault(messageContext.getResponse())) { triggerHandleResponse(interceptorIndex, messageContext); } else { triggerHandleFault(interceptorIndex, messageContext); } } } InterceptingTemplate(ClientInterceptor[] interceptors); void interceptRequest(MessageContext messageContext, WebServiceMessageReceiver messageReceiver); }
InterceptingTemplate { public void interceptRequest(MessageContext messageContext, WebServiceMessageReceiver messageReceiver) throws Exception { int interceptorIndex = -1; if (interceptors != null) { for (int i = 0; i < interceptors.length; i++) { interceptorIndex = i; if (!interceptors[i].handleRequest(messageContext)) { break; } } } if (!messageContext.hasResponse()) { messageReceiver.receive(messageContext); } if (messageContext.hasResponse()) { if (!hasFault(messageContext.getResponse())) { triggerHandleResponse(interceptorIndex, messageContext); } else { triggerHandleFault(interceptorIndex, messageContext); } } } InterceptingTemplate(ClientInterceptor[] interceptors); void interceptRequest(MessageContext messageContext, WebServiceMessageReceiver messageReceiver);  }