Repository: activemq
Updated Branches:
  refs/heads/master e5b7c9fba -> 578eacab4


[AMQ-6824] remove time dependency in test assertion


Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/578eacab
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/578eacab
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/578eacab

Branch: refs/heads/master
Commit: 578eacab455d82989da2ac26980379a04eeb2ad0
Parents: e5b7c9f
Author: gtully <gary.tu...@gmail.com>
Authored: Thu Sep 28 11:34:03 2017 +0100
Committer: gtully <gary.tu...@gmail.com>
Committed: Thu Sep 28 11:36:11 2017 +0100

----------------------------------------------------------------------
 .../org/apache/activemq/JMSConsumerTest.java    | 23 ++++++++++++++------
 1 file changed, 16 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/578eacab/activemq-unit-tests/src/test/java/org/apache/activemq/JMSConsumerTest.java
----------------------------------------------------------------------
diff --git 
a/activemq-unit-tests/src/test/java/org/apache/activemq/JMSConsumerTest.java 
b/activemq-unit-tests/src/test/java/org/apache/activemq/JMSConsumerTest.java
index abf9f62..36a4aac 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/JMSConsumerTest.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/JMSConsumerTest.java
@@ -48,6 +48,7 @@ import org.apache.activemq.broker.region.Subscription;
 import org.apache.activemq.broker.region.TopicSubscription;
 import org.apache.activemq.command.ActiveMQDestination;
 import org.apache.activemq.command.ActiveMQQueue;
+import org.apache.activemq.util.Wait;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -251,7 +252,7 @@ public class JMSConsumerTest extends JmsTestSupport {
 
         final List<Subscription> subscriptions = 
getDestinationConsumers(broker, destination);
 
-        assertTrue("prefetch extension back to 0",
+        assertTrue("prefetch extension..",
                 subscriptions.stream().
                         filter(s -> s instanceof TopicSubscription).
                         mapToInt(s -> 
((TopicSubscription)s).getPrefetchExtension().get()).
@@ -260,11 +261,15 @@ public class JMSConsumerTest extends JmsTestSupport {
         assertNull(consumer.receiveNoWait());
         message.acknowledge();
 
-        assertTrue("prefetch extension back to 0",
-                subscriptions.stream().
+        assertTrue("prefetch extension back to 0", Wait.waitFor(new 
Wait.Condition() {
+            @Override
+            public boolean isSatisified() throws Exception {
+                return subscriptions.stream().
                         filter(s -> s instanceof TopicSubscription).
                         mapToInt(s -> 
((TopicSubscription)s).getPrefetchExtension().get()).
-                        allMatch(e -> e == 0));
+                        allMatch(e -> e == 0);
+            }
+        }));
 
     }
 
@@ -299,11 +304,15 @@ public class JMSConsumerTest extends JmsTestSupport {
         assertNull(consumer.receiveNoWait());
         message.acknowledge();
 
-        assertTrue("prefetch extension back to 0",
-                subscriptions.stream().
+        assertTrue("prefetch extension back to 0", Wait.waitFor(new 
Wait.Condition() {
+            @Override
+            public boolean isSatisified() throws Exception {
+                return subscriptions.stream().
                         filter(s -> s instanceof QueueSubscription).
                         mapToInt(s -> 
((QueueSubscription)s).getPrefetchExtension().get()).
-                        allMatch(e -> e == 0));
+                        allMatch(e -> e == 0);
+            }
+        }));
     }
 
     public void initCombosForTestDurableConsumerSelectorChange() {

Reply via email to