*/
public void testInvokeWithHandlers() throws Exception {
SourceInvocationConfiguration source = new SourceInvocationConfiguration(hello);
MockHandler sourceRequestHandler = new MockHandler();
MockHandler sourceResponseHandler = new MockHandler();
MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor();
source.addRequestHandler(sourceRequestHandler);
source.addResponseHandler(sourceResponseHandler);
source.addInterceptor(sourceInterceptor);
TargetInvocationConfiguration target = new TargetInvocationConfiguration(hello);
MockHandler targetRequestHandler = new MockHandler();
MockHandler targetResponseHandler = new MockHandler();
MockSyncInterceptor targetInterceptor = new MockSyncInterceptor();
target.addRequestHandler(targetRequestHandler);
target.addResponseHandler(targetResponseHandler);
target.addInterceptor(targetInterceptor);
target.addInterceptor(new InvokerInterceptor());
// connect the source to the target
source.setTargetRequestChannel(new MessageChannelImpl(target.getRequestHandlers()));
source.setTargetResponseChannel(new MessageChannelImpl(target.getResponseHandlers()));
source.build();
target.build();
MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl());
source.setTargetInvoker(invoker);
Message msg = factory.createMessage();
msg.setBody("foo");
msg.setTargetInvoker(invoker);
Message response = source.getHeadInterceptor().invoke(msg);
Assert.assertEquals("foo", response.getBody());
Assert.assertEquals(1, sourceRequestHandler.getCount());
Assert.assertEquals(1, sourceResponseHandler.getCount());
Assert.assertEquals(1, sourceInterceptor.getCount());
Assert.assertEquals(1, targetRequestHandler.getCount());
Assert.assertEquals(1, targetResponseHandler.getCount());
Assert.assertEquals(1, targetInterceptor.getCount());
}