You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by GitBox <gi...@apache.org> on 2019/01/24 18:45:12 UTC

[GitHub] clebertsuconic commented on a change in pull request #2518: NO-JIRA fix race condition in QueueQueryTest

clebertsuconic commented on a change in pull request #2518: NO-JIRA fix race condition in QueueQueryTest
URL: https://github.com/apache/activemq-artemis/pull/2518#discussion_r250731204
 
 

 ##########
 File path: tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/QueueQueryTest.java
 ##########
 @@ -155,19 +156,22 @@ public void testQueueQueryOnAutoCreatedQueueWithFQQN() throws Exception {
       SimpleString addressName = SimpleString.toSimpleString(UUID.randomUUID().toString());
       SimpleString queueName = SimpleString.toSimpleString(UUID.randomUUID().toString());
       SimpleString fqqn = addressName.concat("::").concat(queueName);
-      JMSContext c = new ActiveMQConnectionFactory("vm://0").createContext();
-      c.createProducer().send(c.createQueue(fqqn.toString()), c.createMessage());
-      QueueQueryResult queueQueryResult = server.queueQuery(fqqn);
-      assertEquals(queueName, queueQueryResult.getName());
-      assertEquals(addressName, queueQueryResult.getAddress());
-      assertEquals(1, queueQueryResult.getMessageCount());
-      queueQueryResult = server.queueQuery(queueName);
-      assertEquals(queueName, queueQueryResult.getName());
-      assertEquals(addressName, queueQueryResult.getAddress());
-      assertEquals(1, queueQueryResult.getMessageCount());
-      c.createProducer().send(c.createQueue(addressName.toString()), c.createMessage());
-      assertEquals(2, server.queueQuery(fqqn).getMessageCount());
-      assertEquals(2, server.queueQuery(queueName).getMessageCount());
+      try (JMSContext c = new ActiveMQConnectionFactory("vm://0").createContext()) {
+         c.createProducer().send(c.createQueue(fqqn.toString()), c.createMessage());
+         assertTrue(Wait.waitFor(() -> server.locateQueue(queueName).getMessageCount() == 1, 2000, 100));
+         QueueQueryResult queueQueryResult = server.queueQuery(fqqn);
+         assertEquals(queueName, queueQueryResult.getName());
+         assertEquals(addressName, queueQueryResult.getAddress());
+         assertEquals(1, queueQueryResult.getMessageCount());
+         queueQueryResult = server.queueQuery(queueName);
+         assertEquals(queueName, queueQueryResult.getName());
+         assertEquals(addressName, queueQueryResult.getAddress());
+         assertEquals(1, queueQueryResult.getMessageCount());
+         c.createProducer().send(c.createQueue(addressName.toString()), c.createMessage());
+         assertTrue(Wait.waitFor(() -> server.locateQueue(queueName).getMessageCount() == 2, 2000, 100));
 
 Review comment:
   you could have used: Wait.assertEquals(100, server.locateQueue(queueName)::getMessageCount) ?
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services