Search in sources :

Example 21 with StompClientConnection

use of org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnection in project activemq-artemis by apache.

the class StompV11Test method testSendAndReceive.

@Test
public void testSendAndReceive() throws Exception {
    conn.connect(defUser, defPass);
    ClientStompFrame response = send(conn, getQueuePrefix() + getQueueName(), "text/plain", "Hello World 1!");
    assertNull(response);
    String uuid = UUID.randomUUID().toString();
    response = send(conn, getQueuePrefix() + getQueueName(), "text/plain", "Hello World 2!", true);
    // subscribe
    StompClientConnection newConn = StompClientConnectionFactory.createClientConnection(uri);
    newConn.connect(defUser, defPass);
    subscribe(newConn, "a-sub");
    ClientStompFrame frame = newConn.receiveFrame();
    IntegrationTestLogger.LOGGER.info("received " + frame);
    assertEquals(Stomp.Responses.MESSAGE, frame.getCommand());
    assertEquals("a-sub", frame.getHeader(Stomp.Headers.Ack.SUBSCRIPTION));
    assertNotNull(frame.getHeader(Stomp.Headers.Message.MESSAGE_ID));
    assertEquals(getQueuePrefix() + getQueueName(), frame.getHeader(Stomp.Headers.Message.DESTINATION));
    assertEquals("Hello World 1!", frame.getBody());
    frame = newConn.receiveFrame();
    IntegrationTestLogger.LOGGER.info("received " + frame);
    unsubscribe(newConn, "a-sub");
    newConn.disconnect();
}
Also used : ClientStompFrame(org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame) StompClientConnection(org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnection) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) Test(org.junit.Test)

Example 22 with StompClientConnection

use of org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnection in project activemq-artemis by apache.

the class StompV11Test method testSendAndReceiveOnDifferentConnections.

@Test
public void testSendAndReceiveOnDifferentConnections() throws Exception {
    conn.connect(defUser, defPass);
    send(conn, getQueuePrefix() + getQueueName(), null, "Hello World");
    StompClientConnection connV11_2 = StompClientConnectionFactory.createClientConnection(uri);
    connV11_2.connect(defUser, defPass);
    subscribe(connV11_2, "sub1", Stomp.Headers.Subscribe.AckModeValues.AUTO);
    ClientStompFrame frame = connV11_2.receiveFrame(2000);
    assertEquals(Stomp.Responses.MESSAGE, frame.getCommand());
    assertEquals("Hello World", frame.getBody());
    conn.disconnect();
    connV11_2.disconnect();
}
Also used : ClientStompFrame(org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame) StompClientConnection(org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnection) Test(org.junit.Test)

Example 23 with StompClientConnection

use of org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnection in project activemq-artemis by apache.

the class StompPluginTest method testStompAutoCreateAddress.

@Test
public void testStompAutoCreateAddress() throws Exception {
    URI uri = new URI(scheme + "://localhost:61613");
    StompClientConnection newConn = StompClientConnectionFactory.createClientConnection(uri);
    newConn.connect(defUser, defPass);
    subscribeQueue(newConn, "a-sub", "autoCreated");
    // unsub
    unsubscribe(newConn, "a-sub");
    newConn.disconnect();
    verifier.validatePluginMethodsAtLeast(1, BEFORE_ADD_ADDRESS, AFTER_ADD_ADDRESS, BEFORE_REMOVE_ADDRESS, AFTER_REMOVE_ADDRESS);
}
Also used : StompClientConnection(org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnection) URI(java.net.URI) Test(org.junit.Test)

Example 24 with StompClientConnection

use of org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnection in project activemq-artemis by apache.

the class StompPluginTest method testConnect.

@Test
public void testConnect() throws Exception {
    URI uri = new URI(scheme + "://localhost:61613");
    StompClientConnection newConn = StompClientConnectionFactory.createClientConnection(uri);
    newConn.connect(defUser, defPass);
    // Make sure session is created on connect
    assertTrue(stompBeforeCreateSession.get());
    newConn.disconnect();
    Thread.sleep(500);
    // Make sure session is removed on disconnect
    assertTrue(stompBeforeRemoveSession.get());
}
Also used : StompClientConnection(org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnection) URI(java.net.URI) Test(org.junit.Test)

Example 25 with StompClientConnection

use of org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnection in project activemq-artemis by apache.

the class StompPluginTest method testSendAndReceive.

@Test
public void testSendAndReceive() throws Exception {
    URI uri = new URI(scheme + "://localhost:61613");
    StompClientConnection newConn = StompClientConnectionFactory.createClientConnection(uri);
    newConn.connect(defUser, defPass);
    subscribe(newConn, "a-sub");
    send(newConn, getQueuePrefix() + getQueueName(), "text/plain", "Hello World 1!");
    ClientStompFrame frame = newConn.receiveFrame();
    System.out.println("received " + frame);
    Assert.assertEquals(Stomp.Responses.MESSAGE, frame.getCommand());
    verifier.validatePluginMethodsAtLeast(1, MESSAGE_ACKED, BEFORE_SEND, AFTER_SEND, BEFORE_MESSAGE_ROUTE, AFTER_MESSAGE_ROUTE, BEFORE_DELIVER, AFTER_DELIVER);
    // unsub
    unsubscribe(newConn, "a-sub");
    newConn.disconnect();
    verifier.validatePluginMethodsEquals(0, MESSAGE_EXPIRED, BEFORE_DEPLOY_BRIDGE, AFTER_DEPLOY_BRIDGE, BEFORE_REMOVE_BINDING, AFTER_REMOVE_BINDING);
    verifier.validatePluginMethodsAtLeast(1, AFTER_CREATE_CONNECTION, AFTER_DESTROY_CONNECTION, BEFORE_CREATE_SESSION, AFTER_CREATE_SESSION, BEFORE_CLOSE_SESSION, AFTER_CLOSE_SESSION, BEFORE_CREATE_CONSUMER, AFTER_CREATE_CONSUMER, BEFORE_CLOSE_CONSUMER, AFTER_CLOSE_CONSUMER, BEFORE_CREATE_QUEUE, AFTER_CREATE_QUEUE, MESSAGE_ACKED, BEFORE_SEND, AFTER_SEND, BEFORE_MESSAGE_ROUTE, AFTER_MESSAGE_ROUTE, BEFORE_DELIVER, AFTER_DELIVER, BEFORE_ADD_ADDRESS, AFTER_ADD_ADDRESS, BEFORE_ADD_BINDING, AFTER_ADD_BINDING);
}
Also used : ClientStompFrame(org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame) StompClientConnection(org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnection) URI(java.net.URI) Test(org.junit.Test)

Aggregations

StompClientConnection (org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnection)44 Test (org.junit.Test)42 ClientStompFrame (org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame)41 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)14 URI (java.net.URI)7 IOException (java.io.IOException)2 MessageConsumer (javax.jms.MessageConsumer)2 TextMessage (javax.jms.TextMessage)2 LargeMessageTestBase (org.apache.activemq.artemis.tests.integration.largemessage.LargeMessageTestBase)2 StompClientConnectionV11 (org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnectionV11)2 ClosedChannelException (java.nio.channels.ClosedChannelException)1 ArrayList (java.util.ArrayList)1 Enumeration (java.util.Enumeration)1 HashSet (java.util.HashSet)1 Message (javax.jms.Message)1 QueueBrowser (javax.jms.QueueBrowser)1 RoutingType (org.apache.activemq.artemis.api.core.RoutingType)1 Packet (org.apache.activemq.artemis.core.protocol.core.Packet)1 AddressInfo (org.apache.activemq.artemis.core.server.impl.AddressInfo)1 AddressSettings (org.apache.activemq.artemis.core.settings.impl.AddressSettings)1