activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [2/2] activemq-artemis git commit: ARTEMIS-429 - [Artemis Testsuite] TopicControlUsingJMSTest#testGetXXXMessagesCount fails
Date Thu, 10 Mar 2016 13:50:30 GMT
ARTEMIS-429 - [Artemis Testsuite] TopicControlUsingJMSTest#testGetXXXMessagesCount fails


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

Branch: refs/heads/master
Commit: b6922c25f9e6b4ebf858253f97b673becec0a1bf
Parents: 4fb51ef
Author: Erich Duda <eduda@redhat.com>
Authored: Thu Mar 10 14:05:05 2016 +0100
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Thu Mar 10 08:50:13 2016 -0500

----------------------------------------------------------------------
 .../management/TopicControlUsingJMSTest.java    | 26 +++++++++++++++-----
 1 file changed, 20 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b6922c25/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/TopicControlUsingJMSTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/TopicControlUsingJMSTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/TopicControlUsingJMSTest.java
index 8e310ee..560b945 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/TopicControlUsingJMSTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/TopicControlUsingJMSTest.java
@@ -124,9 +124,9 @@ public class TopicControlUsingJMSTest extends ManagementTestBase {
 
       JMSUtil.sendMessages(topic, 2);
 
-      Assert.assertEquals(3 * 2, proxy.retrieveAttributeValue("messageCount"));
-      Assert.assertEquals(1 * 2, proxy.retrieveAttributeValue("nonDurableMessageCount"));
-      Assert.assertEquals(2 * 2, proxy.retrieveAttributeValue("durableMessageCount"));
+      waitForAttributeEqualsValue("messageCount", 3 * 2, 3000);
+      waitForAttributeEqualsValue("nonDurableMessageCount", 1 * 2, 3000);
+      waitForAttributeEqualsValue("durableMessageCount", 2 * 2, 3000);
 
       connection_1.close();
       connection_2.close();
@@ -167,7 +167,7 @@ public class TopicControlUsingJMSTest extends ManagementTestBase {
       JMSUtil.sendMessageWithProperty(session, topic, key, unmatchingValue);
       JMSUtil.sendMessageWithProperty(session, topic, key, matchingValue);
 
-      Assert.assertEquals(3, proxy.retrieveAttributeValue("messageCount"));
+      waitForAttributeEqualsValue("messageCount", 3, 3000);
 
       Assert.assertEquals(2, proxy.invokeOperation("countMessagesForSubscription", clientID,
subscriptionName, key + " =" +
                              matchingValue));
@@ -267,7 +267,7 @@ public class TopicControlUsingJMSTest extends ManagementTestBase {
 
       JMSUtil.sendMessages(topic, 3);
 
-      Assert.assertEquals(3 * 2, proxy.retrieveAttributeValue("messageCount"));
+      waitForAttributeEqualsValue("messageCount", 3 * 2, 3000);
 
       int removedCount = (Integer) proxy.invokeOperation("removeMessages", "");
       Assert.assertEquals(3 * 2, removedCount);
@@ -328,7 +328,7 @@ public class TopicControlUsingJMSTest extends ManagementTestBase {
 
       JMSUtil.sendMessages(topic, 2);
 
-      assertEquals(3 * 2, proxy.retrieveAttributeValue("messagesAdded"));
+      waitForAttributeEqualsValue("messagesAdded", 3 * 2, 3000);
 
       connection_1.close();
       connection_2.close();
@@ -416,6 +416,20 @@ public class TopicControlUsingJMSTest extends ManagementTestBase {
 
    // Private -------------------------------------------------------
 
+   private void waitForAttributeEqualsValue(String attribute, Object expected, long timeout)
throws Exception {
+      long timeToWait = System.currentTimeMillis() + timeout;
+      Object actual = null;
+
+      while (System.currentTimeMillis() < timeToWait) {
+         actual = proxy.retrieveAttributeValue(attribute);
+         if (expected.equals(actual)) {
+            return;
+         }
+         Thread.sleep(100);
+      }
+      Assert.assertEquals(expected, actual);
+   }
+
    // Inner classes -------------------------------------------------
 
 }


Mime
View raw message