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 2016/05/25 19:37:29 UTC

[2/3] activemq-artemis git commit: Add STOMP-MQTT cross protocol tests

Add STOMP-MQTT cross protocol tests


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

Branch: refs/heads/master
Commit: 8507a5c6f0487bf6e0d36880d9a4d459ec421fca
Parents: e453aae
Author: Martyn Taylor <mt...@redhat.com>
Authored: Wed May 25 20:32:03 2016 +0100
Committer: Clebert Suconic <cl...@apache.org>
Committed: Wed May 25 15:37:20 2016 -0400

----------------------------------------------------------------------
 .../tests/integration/stomp/StompTest.java      | 57 +++++++++++++++++++-
 .../tests/integration/stomp/StompTestBase.java  |  2 +
 2 files changed, 58 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/8507a5c6/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompTest.java
index 2ad2b9d..81b5511 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompTest.java
@@ -33,9 +33,11 @@ import java.util.regex.Pattern;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.management.ResourceNames;
 import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
+import org.apache.activemq.artemis.core.protocol.stomp.Stomp;
 import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger;
+import org.apache.activemq.artemis.tests.integration.mqtt.imported.FuseMQTTClientProvider;
+import org.apache.activemq.artemis.tests.integration.mqtt.imported.MQTTClientProvider;
 import org.apache.activemq.artemis.utils.RandomUtil;
-import org.apache.activemq.artemis.core.protocol.stomp.Stomp;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -146,6 +148,59 @@ public class StompTest extends StompTestBase {
    }
 
    @Test
+   public void sendSTOMPReceiveMQTT() throws Exception {
+      String address = "myTestAddress";
+
+      // Set up MQTT Subscription
+      MQTTClientProvider clientProvider = new FuseMQTTClientProvider();
+      clientProvider.connect("tcp://localhost:61616");
+      clientProvider.subscribe(address, 0);
+
+      String stompPayload = "This is a test message";
+
+      // Set up STOMP connection and send STOMP Message
+      String frame = "CONNECT\n" + "login: brianm\n" + "passcode: wombats\n\n" + Stomp.NULL;
+      sendFrame(frame);
+
+      frame = "SEND\n" + "destination:" + address + "\n\n" + stompPayload + Stomp.NULL;
+      sendFrame(frame);
+
+      // Recieve MQTT Message
+      byte[] mqttPayload = clientProvider.receive(10000);
+      clientProvider.disconnect();
+
+      assertEquals(stompPayload, new String(mqttPayload, "UTF-8"));
+      clientProvider.disconnect();
+   }
+
+   @Test
+   public void sendMQTTReceiveSTOMP() throws Exception {
+      String address = "myTestAddress";
+      String payload = "This is a test message";
+
+      server.getActiveMQServer().createQueue(new SimpleString(address), new SimpleString(address), null, false, false);
+
+      // Set up STOMP subscription
+      String frame = "CONNECT\n" + "login: brianm\n" + "passcode: wombats\n\n" + Stomp.NULL;
+      sendFrame(frame);
+
+      frame = "SUBSCRIBE\n" + "destination:" + address + "\n" + "ack:auto\n\n" + Stomp.NULL;
+      sendFrame(frame);
+      receiveFrame(1000);
+
+      // Send MQTT Message
+      MQTTClientProvider clientProvider = new FuseMQTTClientProvider();
+      clientProvider.connect("tcp://localhost:61616");
+      clientProvider.publish(address, payload.getBytes(), 0);
+      clientProvider.disconnect();
+
+      // Receive STOMP Message
+      frame = receiveFrame(1000);
+      assertTrue(frame.contains(payload));
+
+   }
+
+   @Test
    public void testSendMessageToNonExistentQueue() throws Exception {
       String nonExistentQueue = RandomUtil.randomString();
       String frame = "CONNECT\n" + "login: brianm\n" + "passcode: wombats\n\n" + Stomp.NULL;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/8507a5c6/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompTestBase.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompTestBase.java
index 4e024ed..827bf68 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompTestBase.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompTestBase.java
@@ -183,8 +183,10 @@ public abstract class StompTestBase extends ActiveMQTestBase {
       params.put(TransportConstants.PORT_PROP_NAME, TransportConstants.DEFAULT_STOMP_PORT);
       params.put(TransportConstants.STOMP_CONSUMERS_CREDIT, "-1");
       TransportConfiguration stompTransport = new TransportConfiguration(NettyAcceptorFactory.class.getName(), params);
+      TransportConfiguration allTransport = new TransportConfiguration(NettyAcceptorFactory.class.getName());
 
       Configuration config = createBasicConfig().setPersistenceEnabled(false).addAcceptorConfiguration(stompTransport).addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
+      config.addAcceptorConfiguration(allTransport);
 
       ActiveMQServer activeMQServer = addServer(ActiveMQServers.newActiveMQServer(config, defUser, defPass));