activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r882510 - /activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/ExpiredMessagesTest.java
Date Fri, 20 Nov 2009 11:34:15 GMT
Author: gtully
Date: Fri Nov 20 11:34:14 2009
New Revision: 882510

URL: http://svn.apache.org/viewvc?rev=882510&view=rev
Log:
some more resiliance to slow hardware for this test

Modified:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/ExpiredMessagesTest.java

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/ExpiredMessagesTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/ExpiredMessagesTest.java?rev=882510&r1=882509&r2=882510&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/ExpiredMessagesTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/ExpiredMessagesTest.java
Fri Nov 20 11:34:14 2009
@@ -37,6 +37,7 @@
 import javax.jms.MessageConsumer;
 import javax.jms.MessageProducer;
 import javax.jms.Session;
+import javax.management.InstanceNotFoundException;
 import javax.management.ObjectName;
 import junit.framework.Test;
 
@@ -243,25 +244,27 @@
         final boolean deleteAllMessages = false;
         broker = createBroker(deleteAllMessages, 5000);
         
-        view = createView(destination);
-        LOG.info("Stats: size: " + view.getQueueSize() + ", enqueues: "
-                + view.getDequeueCount() + ", dequeues: "
-                + view.getDequeueCount() + ", dispatched: "
-                + view.getDispatchCount() + ", inflight: "
-                + view.getInFlightCount() + ", expiries: "
-                + view.getExpiredCount());
+        Wait.waitFor(new Wait.Condition() {
+            public boolean isSatisified() throws Exception {
+                boolean result = false;
+                try {
+                    DestinationViewMBean view = createView(destination);
+                    LOG.info("Stats: size: " + view.getQueueSize() + ", enqueues: "
+                            + view.getDequeueCount() + ", dequeues: "
+                            + view.getDequeueCount() + ", dispatched: "
+                            + view.getDispatchCount() + ", inflight: "
+                            + view.getInFlightCount() + ", expiries: "
+                            + view.getExpiredCount());
 
-        long expiry = System.currentTimeMillis() + 30000;
-        while (view.getQueueSize() > 0 && System.currentTimeMillis() < expiry)
{
-            Thread.sleep(500);
-        }
-        LOG.info("Stats: size: " + view.getQueueSize() + ", enqueues: "
-                + view.getDequeueCount() + ", dequeues: "
-                + view.getDequeueCount() + ", dispatched: "
-                + view.getDispatchCount() + ", inflight: "
-                + view.getInFlightCount() + ", expiries: "
-                + view.getExpiredCount());
-        assertEquals("Wrong QueueSize: ", 0, view.getQueueSize());
+                    result = view.getQueueSize() == 0;
+                } catch (InstanceNotFoundException expectedOnSlowMachines) {
+                }
+                return result;
+            }
+        });
+        
+        view = createView(destination);
+        assertEquals("Expect empty queue, QueueSize: ", 0, view.getQueueSize());
         assertEquals("all dequeues were expired", view.getDequeueCount(), view.getExpiredCount());
     }
 



Mime
View raw message