activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From martyntay...@apache.org
Subject [2/3] activemq-artemis git commit: Add MQTT Test for MaxConsumer threshold
Date Tue, 01 Nov 2016 12:34:40 GMT
Add MQTT Test for MaxConsumer threshold


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

Branch: refs/heads/ARTEMIS-780
Commit: d43c5769208fcc81c9b9cf3ee590ac2af0b40e3e
Parents: fc11b3b
Author: Martyn Taylor <mtaylor@redhat.com>
Authored: Tue Nov 1 11:40:29 2016 +0000
Committer: Martyn Taylor <mtaylor@redhat.com>
Committed: Tue Nov 1 12:34:19 2016 +0000

----------------------------------------------------------------------
 .../integration/mqtt/imported/MQTTTest.java     | 27 ++++++++++++++++++++
 .../mqtt/imported/MQTTTestSupport.java          |  4 +++
 2 files changed, 31 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d43c5769/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/MQTTTest.java
----------------------------------------------------------------------
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 b809df0..6406955 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
@@ -22,6 +22,7 @@ import javax.jms.Destination;
 import javax.jms.MessageConsumer;
 import javax.jms.MessageProducer;
 import javax.jms.Session;
+import java.io.EOFException;
 import java.lang.reflect.Field;
 import java.net.ProtocolException;
 import java.util.ArrayList;
@@ -34,8 +35,10 @@ import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 import java.util.regex.Pattern;
 
+import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.protocol.mqtt.MQTTConnectionManager;
 import org.apache.activemq.artemis.core.protocol.mqtt.MQTTSession;
+import org.apache.activemq.artemis.core.server.impl.AddressInfo;
 import org.apache.activemq.artemis.tests.integration.mqtt.imported.util.Wait;
 import org.fusesource.mqtt.client.BlockingConnection;
 import org.fusesource.mqtt.client.MQTT;
@@ -1612,4 +1615,28 @@ public class MQTTTest extends MQTTTestSupport {
 
       connection.disconnect();
    }
+
+   @Test(timeout = 60 * 1000)
+   public void testClientDisconnectedOnMaxConsumerLimitReached() throws Exception {
+      Exception peerDisconnectedException = null;
+      try {
+         SimpleString coreAddress = new SimpleString("foo.bar");
+         Topic[] mqttSubscription = new Topic[]{new Topic("foo/bar", QoS.AT_LEAST_ONCE)};
+
+         AddressInfo addressInfo = new AddressInfo(coreAddress);
+         addressInfo.setDefaultMaxConsumers(0);
+         getServer().createOrUpdateAddressInfo(addressInfo);
+
+         MQTT mqtt = createMQTTConnection();
+         mqtt.setClientId("test-mqtt");
+         mqtt.setKeepAlive((short) 2);
+         final BlockingConnection connection = mqtt.blockingConnection();
+         connection.connect();
+         connection.subscribe(mqttSubscription);
+      } catch (EOFException e) {
+         peerDisconnectedException = e;
+      }
+      assertNotNull(peerDisconnectedException);
+      assertTrue(peerDisconnectedException.getMessage().contains("Peer disconnected"));
+   }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d43c5769/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/MQTTTestSupport.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/MQTTTestSupport.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/MQTTTestSupport.java
index 27ebde0..15cb8b6 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/MQTTTestSupport.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/MQTTTestSupport.java
@@ -92,6 +92,10 @@ public class MQTTTestSupport extends ActiveMQTestBase {
       return name.getMethodName();
    }
 
+   public ActiveMQServer getServer() {
+      return server;
+   }
+
    @Override
    @Before
    public void setUp() throws Exception {


Mime
View raw message