activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1195988 - /activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ1853Test.java
Date Tue, 01 Nov 2011 13:26:26 GMT
Author: tabish
Date: Tue Nov  1 13:26:26 2011
New Revision: 1195988

URL: http://svn.apache.org/viewvc?rev=1195988&view=rev
Log:
Fix timing dependent assertion.

Modified:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ1853Test.java

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ1853Test.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ1853Test.java?rev=1195988&r1=1195987&r2=1195988&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ1853Test.java (original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ1853Test.java Tue
Nov  1 13:26:26 2011
@@ -42,6 +42,8 @@ import org.apache.activemq.ActiveMQSessi
 import org.apache.activemq.RedeliveryPolicy;
 import org.apache.activemq.broker.BrokerFactory;
 import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.util.Wait;
+import org.apache.activemq.util.Wait.Condition;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -75,6 +77,7 @@ public class AMQ1853Test {
     public void setUp() throws Exception {
         broker = BrokerFactory.createBroker(new URI("broker:()/localhost?persistent=false"));
         broker.setUseJmx(false);
+        broker.setDeleteAllMessagesOnStartup(true);
         broker.start();
         broker.waitUntilStarted();
     }
@@ -115,10 +118,16 @@ public class AMQ1853Test {
             producerAllFail.getLatch().await();
 
             LOG.info("producer successful, count = " + producerAllFail.getLatch().getCount());
-
-            assertTrue("message list size =  " + messageList.size(), totalNumberMessages
== messageList.size());
             LOG.info("final message list size =  " + messageList.size());
 
+            assertTrue("message list size =  " + messageList.size() + " exptected:" + totalNumberMessages,
+                Wait.waitFor(new Condition() {
+                    @Override
+                    public boolean isSatisified() throws Exception {
+                        return totalNumberMessages == messageList.size();
+                    }
+                }));
+
             consumerAllFail.getLatch().await();
 
             LOG.info("consumerAllFail successful, count = " + consumerAllFail.getLatch().getCount());
@@ -126,8 +135,8 @@ public class AMQ1853Test {
             Iterator<String> keys = messageList.keySet().iterator();
             for (AtomicInteger counter : messageList.values()) {
                 String message = keys.next();
-                assertTrue("for message " + message + " counter =  " + counter.get(), counter.get()
== maxRedeliveries + 1);
                 LOG.info("final count for message " + message + " counter =  " + counter.get());
+                assertTrue("for message " + message + " counter =  " + counter.get(), counter.get()
== maxRedeliveries + 1);
             }
 
             assertFalse(consumerAllFail.messageReceiptIsOrdered());



Mime
View raw message