Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 86478200A5B for ; Wed, 25 May 2016 21:57:48 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 84DDB160A29; Wed, 25 May 2016 19:57:48 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id A61E0160A0F for ; Wed, 25 May 2016 21:57:47 +0200 (CEST) Received: (qmail 73873 invoked by uid 500); 25 May 2016 19:39:21 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 72886 invoked by uid 99); 25 May 2016 19:37:28 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 May 2016 19:37:28 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id C5595DFDEF; Wed, 25 May 2016 19:37:28 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: clebertsuconic@apache.org To: commits@activemq.apache.org Date: Wed, 25 May 2016 19:37:29 -0000 Message-Id: <7eb59a8215ae41f698cb7bb0696dc951@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [2/3] activemq-artemis git commit: Add STOMP-MQTT cross protocol tests archived-at: Wed, 25 May 2016 19:57:48 -0000 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 Authored: Wed May 25 20:32:03 2016 +0100 Committer: Clebert Suconic 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));