Repository: activemq-artemis
Updated Branches:
  refs/heads/master 9723eed83 -> 9d62e1d85


NO-JIRA Fixing another test race on JMSConsumer11Test


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

Branch: refs/heads/master
Commit: 9d62e1d8547aa9cd64cb357ddb7705f26a057c54
Parents: 9723eed
Author: Clebert Suconic <[email protected]>
Authored: Thu May 10 09:03:29 2018 -0400
Committer: Clebert Suconic <[email protected]>
Committed: Thu May 10 09:05:30 2018 -0400

----------------------------------------------------------------------
 .../integration/openwire/amq/JMSConsumer11Test.java    | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/9d62e1d8/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer11Test.java
----------------------------------------------------------------------
diff --git 
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer11Test.java
 
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer11Test.java
index 870338f..28f15d8 100644
--- 
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer11Test.java
+++ 
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer11Test.java
@@ -18,13 +18,14 @@ package 
org.apache.activemq.artemis.tests.integration.openwire.amq;
 
 import javax.jms.DeliveryMode;
 import javax.jms.Message;
-import javax.jms.MessageConsumer;
 import javax.jms.Session;
 import java.util.Arrays;
 import java.util.Collection;
 
 import org.apache.activemq.ActiveMQConnection;
+import org.apache.activemq.ActiveMQMessageConsumer;
 import 
org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest;
+import org.apache.activemq.artemis.tests.util.Wait;
 import org.apache.activemq.command.ActiveMQDestination;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -55,7 +56,7 @@ public class JMSConsumer11Test extends BasicOpenWireTest {
 
       Session session = connection.createSession(true, 0);
       ActiveMQDestination destination = createDestination(session, 
ActiveMQDestination.QUEUE_TYPE);
-      MessageConsumer consumer = session.createConsumer(destination);
+      ActiveMQMessageConsumer consumer = 
(ActiveMQMessageConsumer)session.createConsumer(destination);
 
       // Send 2 messages to the destination.
       sendMessages(session, destination, 2);
@@ -68,7 +69,13 @@ public class JMSConsumer11Test extends BasicOpenWireTest {
       ActiveMQConnection connection2 = (ActiveMQConnection) 
factory.createConnection();
       connection2.start();
       Session session2 = connection2.createSession(true, 0);
-      MessageConsumer consumer2 = session2.createConsumer(destination);
+      ActiveMQMessageConsumer consumer2 = 
(ActiveMQMessageConsumer)session2.createConsumer(destination);
+
+      // On a test race you could have a scenario where the message only 
arrived at the first consumer and
+      // if the test is not fast enough the first consumer will receive the 
message againt
+      // This will guarantee the test is correctly balanced.
+      Wait.assertEquals(1, consumer::getMessageSize);
+      Wait.assertEquals(1, consumer2::getMessageSize);
 
       System.out.println("consumer receiving ...");
       // Pick up the first message.

Reply via email to