AckCollector ac=new AckCollector(null, list);
ac.waitForAllAcks(200);
}
public void testWaitForAllAcksWithTimeout() {
final AckCollector ac=new AckCollector(null, list);
new Thread() {
public void run() {
ac.ack("one");
System.out.println("AckCollector: " + ac);
Util.sleep(100);
ac.ack("two");
System.out.println("AckCollector: " + ac);
Util.sleep(100);
ac.ack("three");
System.out.println("AckCollector: " + ac);
Util.sleep(100);
ac.ack("four");
System.out.println("AckCollector: " + ac);
Util.sleep(100);
ac.ack("five");
System.out.println("AckCollector: " + ac);
}
}.start();
try {
ac.waitForAllAcks(5000);
assert true : "we should not get a timeout exception here";
}
catch(TimeoutException e) {
assert false : "we should not get a timeout exception here";
}
Assert.assertEquals(0, ac.size());
}