activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1190615 - in /activemq/trunk/activemq-core/src/test/java/org/apache/activemq: broker/region/DestinationGCTest.java bugs/AMQ2383Test.java
Date Fri, 28 Oct 2011 21:57:38 GMT
Author: tabish
Date: Fri Oct 28 21:57:37 2011
New Revision: 1190615

URL: http://svn.apache.org/viewvc?rev=1190615&view=rev
Log:
Fix a couple of tests that sleep for longer than necessary, use the Wait object when possible.

Modified:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/region/DestinationGCTest.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ2383Test.java

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/region/DestinationGCTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/region/DestinationGCTest.java?rev=1190615&r1=1190614&r2=1190615&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/region/DestinationGCTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/region/DestinationGCTest.java
Fri Oct 28 21:57:37 2011
@@ -22,6 +22,8 @@ import org.apache.activemq.broker.region
 import org.apache.activemq.broker.region.policy.PolicyMap;
 import org.apache.activemq.command.ActiveMQDestination;
 import org.apache.activemq.command.ActiveMQQueue;
+import org.apache.activemq.util.Wait;
+import org.apache.activemq.util.Wait.Condition;
 
 public class DestinationGCTest extends EmbeddedBrokerTestSupport {
 
@@ -44,8 +46,12 @@ public class DestinationGCTest extends E
 
     public void testDestinationGc() throws Exception {
         assertEquals(1, broker.getAdminView().getQueues().length);
-        Thread.sleep(7000);
-        assertEquals(0, broker.getAdminView().getQueues().length);
+        assertTrue("After GC runs the Queue should be empty.", Wait.waitFor(new Condition()
{
+            @Override
+            public boolean isSatisified() throws Exception {
+                return broker.getAdminView().getQueues().length == 0;
+            }
+        }));
     }
 
     public void testDestinationGcLimit() throws Exception {
@@ -59,7 +65,11 @@ public class DestinationGCTest extends E
         Thread.sleep(7000);
         int queues = broker.getAdminView().getQueues().length;
         assertTrue(queues > 0 && queues < 5);
-        Thread.sleep(10000);
-        assertEquals(0, broker.getAdminView().getQueues().length);
+        assertTrue("After GC runs the Queue should be empty.", Wait.waitFor(new Condition()
{
+            @Override
+            public boolean isSatisified() throws Exception {
+                return broker.getAdminView().getQueues().length == 0;
+            }
+        }));
     }
 }

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ2383Test.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ2383Test.java?rev=1190615&r1=1190614&r2=1190615&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ2383Test.java (original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ2383Test.java Fri
Oct 28 21:57:37 2011
@@ -57,8 +57,6 @@ public class AMQ2383Test {
 
         assertEquals(sentMsg, receivedMsg);
 
-        Thread.sleep(10000);
-
         producerConnection.close();
         consumerConnection.close();
     }



Mime
View raw message