From 0e1d63269d9d39852f6fdca02394a0783d33ed82 Mon Sep 17 00:00:00 2001 From: Gary Tully Date: Tue, 11 May 2010 11:50:22 +0000 Subject: [PATCH] make tests more resiliant to running on slower/loaded machines git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@943091 13f79535-47bb-0310-9956-ffa450edef68 --- .../activemq/JmsQueueCompositeSendReceiveTest.java | 9 +++++++-- .../transport/vm/VmTransportNetworkBrokerTest.java | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) 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(); }