deployment.start();
// we want to invoke a mock so we can check for messages received
final ServiceReference reference = domain.getServiceReference(svcName);
domain.getServices(svcName).get(0).unregister();
final MockHandler service = new MockHandler();
domain.registerService(svcName, new InOnlyService(), service);
final int NUM_SENDS = 5;
for (int i = 0; i < NUM_SENDS; i++) {
new Thread(new Runnable() {
public void run() {
Exchange exchange = reference.createExchange();
Message message = exchange.createMessage();
exchange.send(message);
}
}).start();
}
Thread.sleep(4000);
Assert.assertEquals("Received more than one message per minute - throttling policy violated!",
1, service.getMessages().size());
}