Search in sources :

Example 1 with FuseMQTTClientProvider

use of org.apache.activemq.artemis.tests.integration.mqtt.imported.FuseMQTTClientProvider in project activemq-artemis by apache.

the class StompTest method sendMQTTReceiveSTOMP.

@Test
public void sendMQTTReceiveSTOMP() throws Exception {
    String payload = "This is a test message";
    // Set up STOMP subscription
    conn.connect(defUser, defPass);
    subscribe(conn, null, Stomp.Headers.Subscribe.AckModeValues.AUTO);
    // Send MQTT Message
    MQTTClientProvider clientProvider = new FuseMQTTClientProvider();
    clientProvider.connect("tcp://" + hostname + ":" + port);
    clientProvider.publish(getQueuePrefix() + getQueueName(), payload.getBytes(), 0);
    clientProvider.disconnect();
    // Receive STOMP Message
    ClientStompFrame frame = conn.receiveFrame();
    assertTrue(frame.getBody().contains(payload));
}
Also used : ClientStompFrame(org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame) FuseMQTTClientProvider(org.apache.activemq.artemis.tests.integration.mqtt.imported.FuseMQTTClientProvider) MQTTClientProvider(org.apache.activemq.artemis.tests.integration.mqtt.imported.MQTTClientProvider) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) FuseMQTTClientProvider(org.apache.activemq.artemis.tests.integration.mqtt.imported.FuseMQTTClientProvider) Test(org.junit.Test)

Example 2 with FuseMQTTClientProvider

use of org.apache.activemq.artemis.tests.integration.mqtt.imported.FuseMQTTClientProvider in project activemq-artemis by apache.

the class StompTest method sendSTOMPReceiveMQTT.

@Test
public void sendSTOMPReceiveMQTT() throws Exception {
    // Set up MQTT Subscription
    MQTTClientProvider clientProvider = new FuseMQTTClientProvider();
    clientProvider.connect("tcp://" + hostname + ":" + port);
    clientProvider.subscribe(getTopicPrefix() + getTopicName(), 0);
    String stompPayload = "This is a test message";
    // Set up STOMP connection and send STOMP Message
    conn.connect(defUser, defPass);
    send(conn, getTopicPrefix() + getTopicName(), null, stompPayload);
    // Receive MQTT Message
    byte[] mqttPayload = clientProvider.receive(10000);
    clientProvider.disconnect();
    assertEquals(stompPayload, new String(mqttPayload, "UTF-8"));
    clientProvider.disconnect();
}
Also used : FuseMQTTClientProvider(org.apache.activemq.artemis.tests.integration.mqtt.imported.FuseMQTTClientProvider) MQTTClientProvider(org.apache.activemq.artemis.tests.integration.mqtt.imported.MQTTClientProvider) FuseMQTTClientProvider(org.apache.activemq.artemis.tests.integration.mqtt.imported.FuseMQTTClientProvider) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) Test(org.junit.Test)

Aggregations

SimpleString (org.apache.activemq.artemis.api.core.SimpleString)2 FuseMQTTClientProvider (org.apache.activemq.artemis.tests.integration.mqtt.imported.FuseMQTTClientProvider)2 MQTTClientProvider (org.apache.activemq.artemis.tests.integration.mqtt.imported.MQTTClientProvider)2 Test (org.junit.Test)2 ClientStompFrame (org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame)1