You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2019/07/26 17:55:11 UTC

[activemq-artemis] 02/05: NO-JIRA Speeding up MQTTTest

This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git

commit 70e6c17bd98f6f03be03748806d08f177716b18e
Author: Clebert Suconic <cl...@apache.org>
AuthorDate: Thu Jul 25 18:17:10 2019 -0400

    NO-JIRA Speeding up MQTTTest
---
 .../tests/integration/mqtt/imported/MQTTTest.java  | 22 +++++-----------------
 1 file changed, 5 insertions(+), 17 deletions(-)

diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/MQTTTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/MQTTTest.java
index 7821a30..d323554 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/MQTTTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/MQTTTest.java
@@ -477,7 +477,7 @@ public class MQTTTest extends MQTTTestSupport {
             assertTrue("RETAINED prefix " + wildcard + " msg " + msgPayload, msgPayload.startsWith(RETAINED));
             assertTrue("RETAINED matching " + wildcard + " " + msg.getTopic(), pattern.matcher(msg.getTopic()).matches());
             msg.ack();
-            msg = connection.receive(5000, TimeUnit.MILLISECONDS);
+            msg = connection.receive(500, TimeUnit.MILLISECONDS);
          }
          while (msg != null);
 
@@ -490,7 +490,7 @@ public class MQTTTest extends MQTTTestSupport {
             assertNotNull("Non-retained Null " + wildcard, msg);
             assertTrue("Non-retained matching " + wildcard + " " + msg.getTopic(), pattern.matcher(msg.getTopic()).matches());
             msg.ack();
-            msg = connection.receive(1000, TimeUnit.MILLISECONDS);
+            msg = connection.receive(500, TimeUnit.MILLISECONDS);
          }
          while (msg != null);
 
@@ -528,12 +528,8 @@ public class MQTTTest extends MQTTTestSupport {
          final Message msg = connection.receive(5000, TimeUnit.MILLISECONDS);
          assertNotNull(msg);
          assertEquals(topic, new String(msg.getPayload()));
-         int waitCount = 0;
-         while (actualQoS[0] == -1 && waitCount < 10) {
-            Thread.sleep(1000);
-            waitCount++;
-         }
-         assertEquals(i, actualQoS[0]);
+
+         Wait.assertEquals(i, () -> actualQoS[0]);
          msg.ack();
 
          connection.unsubscribe(new String[]{topic});
@@ -573,12 +569,7 @@ public class MQTTTest extends MQTTTestSupport {
          assertNotNull("No message for " + qos, msg);
          assertEquals(RETAIN, new String(msg.getPayload()));
          msg.ack();
-         int waitCount = 0;
-         while (actualQoS[0] == -1 && waitCount < 10) {
-            Thread.sleep(1000);
-            waitCount++;
-         }
-         assertEquals(qos.ordinal(), actualQoS[0]);
+         Wait.assertEquals(qos.ordinal(), () -> actualQoS[0]);
          actualQoS[0] = -1;
       }
 
@@ -1022,9 +1013,6 @@ public class MQTTTest extends MQTTTestSupport {
       // kill transport
       connection.kill();
 
-      // FIXME Wait for the previous connection to timeout.  This is not required in ActiveMQ.  Needs investigating.
-      Thread.sleep(10000);
-
       final BlockingConnection newConnection = mqtt.blockingConnection();
       newConnection.connect();
       Wait.waitFor(() -> newConnection.isConnected());