make test more tolerant to slower machines, replace sleep with timed wait : https://issues.apache.org/activemq/browse/AMQ-1936

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@798859 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary Tully 2009-07-29 11:35:41 +00:00
parent 763e331318
commit a27709b086
1 changed files with 6 additions and 2 deletions

View File

@ -18,6 +18,7 @@ package org.apache.activemq.bugs;
import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.util.Wait;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
@ -187,8 +188,11 @@ public class AMQ1936Test extends TestCase{
} }
// allow some time for messages to be delivered to receivers. // allow some time for messages to be delivered to receivers.
Thread.sleep( 5000 ); Wait.waitFor(new Wait.Condition() {
public boolean isSatisified() throws Exception {
return TEST_MESSAGE_COUNT == messages.size();
}
});
assertEquals( "Number of messages received does not match the number sent", TEST_MESSAGE_COUNT, messages.size( ) ); assertEquals( "Number of messages received does not match the number sent", TEST_MESSAGE_COUNT, messages.size( ) );
assertEquals( TEST_MESSAGE_COUNT, messageCount.get() ); assertEquals( TEST_MESSAGE_COUNT, messageCount.get() );
} }