diff --git a/activemq-core/src/test/java/org/apache/activemq/JmsQueueCompositeSendReceiveTest.java b/activemq-core/src/test/java/org/apache/activemq/JmsQueueCompositeSendReceiveTest.java index 78f983f71b..5096a4b933 100755 --- a/activemq-core/src/test/java/org/apache/activemq/JmsQueueCompositeSendReceiveTest.java +++ b/activemq-core/src/test/java/org/apache/activemq/JmsQueueCompositeSendReceiveTest.java @@ -29,6 +29,7 @@ import org.apache.activemq.broker.region.RegionBroker; import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.command.ActiveMQQueue; import org.apache.activemq.test.JmsTopicSendReceiveTest; +import org.apache.activemq.util.Wait; /** @@ -106,8 +107,12 @@ public class JmsQueueCompositeSendReceiveTest extends JmsTopicSendReceiveTest { Thread.sleep(200); // wait for messages to be queued BrokerService broker = BrokerRegistry.getInstance().lookup("localhost"); - Queue dest = (Queue)((RegionBroker)broker.getRegionBroker()).getQueueRegion().getDestinationMap().get(new ActiveMQQueue("TEST")); - assertEquals(data.length, dest.getDestinationStatistics().getMessages().getCount()); + final Queue dest = (Queue)((RegionBroker)broker.getRegionBroker()).getQueueRegion().getDestinationMap().get(new ActiveMQQueue("TEST")); + assertTrue("all messages were received", Wait.waitFor(new Wait.Condition(){ + public boolean isSatisified() throws Exception { + return data.length == dest.getDestinationStatistics().getMessages().getCount(); + }})); + dest.purge(); assertEquals(0, dest.getDestinationStatistics().getMessages().getCount()); } diff --git a/activemq-core/src/test/java/org/apache/activemq/transport/vm/VmTransportNetworkBrokerTest.java b/activemq-core/src/test/java/org/apache/activemq/transport/vm/VmTransportNetworkBrokerTest.java index f88881bfbe..c6a6447fb9 100644 --- a/activemq-core/src/test/java/org/apache/activemq/transport/vm/VmTransportNetworkBrokerTest.java +++ b/activemq-core/src/test/java/org/apache/activemq/transport/vm/VmTransportNetworkBrokerTest.java @@ -55,7 +55,7 @@ public class VmTransportNetworkBrokerTest extends TestCase { int threadCountAfterSleep = Thread.activeCount(); assertTrue("Threads are leaking, threadCount=" + threadCount + " threadCountAfterSleep=" + threadCountAfterSleep, - threadCountAfterSleep < threadCount + 5); + threadCountAfterSleep < threadCount + 8); broker.stop(); }