}
public void testDispatchersLifecycle() throws Exception
{
//using sync endpoint so that any calls to 'process()' will be blocking and avoid timing issues
OutboundEndpoint out = getTestOutboundEndpoint("out",
"test://out?exchangePattern=request-response", null, null, null, connector);
// attempts to send/dispatch/request are made on a stopped/stopping connector
// This should fail because the connector is not started!
try
{
out.process(getTestEvent("data"));
fail("cannot send on a connector that is not started");
}
catch (LifecycleException e)
{
// expected
}
assertEquals(0, connector.dispatchers.getNumIdle());
// Dispatcher is not started or connected
assertDispatcherStartedConnected(out, false, false);
connector.start();
//This causes the first instance out dispatcher to be created
assertDispatcherStartedConnected(out, true, true);
OutboundEndpoint out2 = getTestOutboundEndpoint("out2",
"test://out2?exchangePattern=request-response", null, null, null, connector);
//This causes the first instance out2 dispatcher to be created
out2.process(getTestEvent("data"));
//At this point there should be two idle, but the build server reports one, I suspect its a timing issues
assertEquals(2, connector.dispatchers.getNumIdle());
assertDispatcherStartedConnected(out, true, true);
assertDispatcherStartedConnected(out2, true, true);