/**
* Verifies an invocation with a source and target interceptor
*/
public void testSourceTargetInterceptor() throws Exception {
ConnectorImpl connector = new ConnectorImpl();
MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor();
List<Interceptor> sourceInterceptors = new ArrayList<Interceptor>();
sourceInterceptors.add(sourceInterceptor);
MockSyncInterceptor targetInterceptor = new MockSyncInterceptor();
List<Interceptor> targetInterceptors = new ArrayList<Interceptor>();
targetInterceptors.add(targetInterceptor);
OutboundInvocationChain outboundChain = setupOutbound(sourceInterceptors);
InboundInvocationChain inboundChain = setupInbound(targetInterceptors);
Message msg = new MessageImpl();
TargetInvoker invoker = createNiceMock(TargetInvoker.class);
expect(invoker.invoke(EasyMock.eq(msg))).andReturn(msg);
replay(invoker);
assertEquals(0, sourceInterceptor.getCount());
assertEquals(0, targetInterceptor.getCount());
connector.connect(inboundChain, outboundChain);
inboundChain.setTargetInvoker(invoker);
inboundChain.prepare();
msg.setTargetInvoker(inboundChain.getTargetInvoker());
assertEquals(msg, inboundChain.getHeadInterceptor().invoke(msg));
assertEquals(1, sourceInterceptor.getCount());
assertEquals(1, targetInterceptor.getCount());
verify(invoker);
}