public void testSedaSedaSync() throws Exception {
runTest("seda", "seda", true);
}
private void runTest(String flowName, String subscriptionFlowName, boolean sync) throws Exception {
JBIContainer container = new JBIContainer();
try {
container.getBroker().setFlow(FlowProvider.getFlow(flowName));
if (subscriptionFlowName != null) {
container.getBroker().getSubscriptionManager().setFlow(FlowProvider.getFlow(subscriptionFlowName));
}
// TODO: check why the following line is enabled, there is
// a 5 seconds pause when Management stuff is initialized
//container.setCreateMBeanServer(true);
container.init();
container.start();
SenderListener sender = new SenderListener();
ActivationSpec senderActivationSpec = new ActivationSpec("sender", sender);
senderActivationSpec.setFailIfNoDestinationEndpoint(false);
container.activateComponent(senderActivationSpec);
Receiver receiver1 = new ReceiverComponent();
container.activateComponent(createReceiverAS("receiver1", receiver1));
Receiver receiver2 = new ReceiverComponent();
container.activateComponent(createReceiverAS("receiver2", receiver2));
sender.sendMessages(1, sync);
Thread.sleep(100);
assertEquals(1, receiver1.getMessageList().getMessageCount());
assertEquals(1, receiver2.getMessageList().getMessageCount());
assertEquals(0, sender.responses.size());
} finally {
container.shutDown();
}
}