final SenderComponent sender = new SenderComponent();
final ReceiverComponent receiver1 = new ReceiverComponent();
final ReceiverComponent receiver2 = new ReceiverComponent();
sender.setResolver(new ServiceNameEndpointResolver(ReceiverComponent.SERVICE));
senderContainer.activateComponent(new ActivationSpec("sender", sender));
senderContainer.activateComponent(new ActivationSpec("receiver", receiver1));
receiverContainer.activateComponent(new ActivationSpec("receiver", receiver2));
Thread.sleep(1000);
sender.sendMessages(NUM_MESSAGES);
Thread.sleep(3000);
assertTrue(receiver1.getMessageList().hasReceivedMessage());
assertTrue(receiver2.getMessageList().hasReceivedMessage());
receiver1.getMessageList().flushMessages();
receiver2.getMessageList().flushMessages();
senderContainer.deactivateComponent("receiver");
Thread.sleep(1000);
sender.sendMessages(NUM_MESSAGES);
Thread.sleep(3000);
assertFalse(receiver1.getMessageList().hasReceivedMessage());
assertTrue(receiver2.getMessageList().hasReceivedMessage());
receiver1.getMessageList().flushMessages();
receiver2.getMessageList().flushMessages();
senderContainer.activateComponent(new ActivationSpec("receiver", receiver1));
receiverContainer.deactivateComponent("receiver");
Thread.sleep(1000);
sender.sendMessages(NUM_MESSAGES);
Thread.sleep(3000);