Search in sources :

Example 76 with ClientStompFrame

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

the class StompV11Test method testBeginSameTransactionTwice.

// ----------------Note: tests below are adapted from StompTest
@Test
public void testBeginSameTransactionTwice() throws Exception {
    conn.connect(defUser, defPass);
    beginTransaction(conn, "tx1");
    beginTransaction(conn, "tx1");
    ClientStompFrame f = conn.receiveFrame();
    Assert.assertTrue(f.getCommand().equals(Stomp.Responses.ERROR));
}
Also used : ClientStompFrame(org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame) Test(org.junit.Test)

Example 77 with ClientStompFrame

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

the class StompV11Test method testErrorWithReceipt2.

@Test
public void testErrorWithReceipt2() throws Exception {
    conn.connect(defUser, defPass);
    subscribe(conn, "sub1", Stomp.Headers.Subscribe.AckModeValues.CLIENT);
    sendJmsMessage(getName());
    ClientStompFrame frame = conn.receiveFrame();
    String messageID = frame.getHeader(Stomp.Headers.Message.MESSAGE_ID);
    // give it a wrong sub id
    ClientStompFrame ackFrame = conn.createFrame(Stomp.Commands.ACK).addHeader(Stomp.Headers.Ack.SUBSCRIPTION, "sub1").addHeader(Stomp.Headers.Message.MESSAGE_ID, String.valueOf(Long.valueOf(messageID) + 1)).addHeader(Stomp.Headers.RECEIPT_REQUESTED, "answer-me");
    ClientStompFrame error = conn.sendFrame(ackFrame);
    IntegrationTestLogger.LOGGER.info("Receiver error: " + error);
    assertEquals(Stomp.Responses.ERROR, error.getCommand());
    assertEquals("answer-me", error.getHeader(Stomp.Headers.Response.RECEIPT_ID));
    unsubscribe(conn, "sub1");
    conn.disconnect();
    // message should still there
    MessageConsumer consumer = session.createConsumer(queue);
    Message message = consumer.receive(1000);
    Assert.assertNotNull(message);
}
Also used : ClientStompFrame(org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame) MessageConsumer(javax.jms.MessageConsumer) Message(javax.jms.Message) TextMessage(javax.jms.TextMessage) BytesMessage(javax.jms.BytesMessage) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) Test(org.junit.Test)

Example 78 with ClientStompFrame

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

the class StompV11Test method testSubscribeToTopic.

@Test
public void testSubscribeToTopic() throws Exception {
    conn.connect(defUser, defPass);
    subscribeTopic(conn, "sub1", null, null, true);
    sendJmsMessage(getName(), topic);
    ClientStompFrame frame = conn.receiveFrame();
    Assert.assertTrue(frame.getCommand().equals(Stomp.Responses.MESSAGE));
    Assert.assertTrue(frame.getHeader(Stomp.Headers.Message.DESTINATION).equals(getTopicPrefix() + getTopicName()));
    Assert.assertTrue(frame.getBody().equals(getName()));
    unsubscribe(conn, "sub1", true);
    sendJmsMessage(getName(), topic);
    frame = conn.receiveFrame(1000);
    assertNull(frame);
    conn.disconnect();
}
Also used : ClientStompFrame(org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame) Test(org.junit.Test)

Example 79 with ClientStompFrame

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

the class StompV11Test method testSubscribeWithID.

@Test
public void testSubscribeWithID() throws Exception {
    conn.connect(defUser, defPass);
    subscribe(conn, "mysubid", Stomp.Headers.Subscribe.AckModeValues.AUTO);
    sendJmsMessage(getName());
    ClientStompFrame frame = conn.receiveFrame();
    Assert.assertTrue(frame.getHeader(Stomp.Headers.Ack.SUBSCRIPTION) != null);
    conn.disconnect();
}
Also used : ClientStompFrame(org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame) Test(org.junit.Test)

Example 80 with ClientStompFrame

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

the class StompV11Test method testMessagesAreInOrder.

@Test
public void testMessagesAreInOrder() throws Exception {
    int ctr = 10;
    String[] data = new String[ctr];
    conn.connect(defUser, defPass);
    subscribe(conn, "sub1", Stomp.Headers.Subscribe.AckModeValues.AUTO);
    for (int i = 0; i < ctr; ++i) {
        data[i] = getName() + i;
        sendJmsMessage(data[i]);
    }
    ClientStompFrame frame = null;
    for (int i = 0; i < ctr; ++i) {
        frame = conn.receiveFrame();
        Assert.assertTrue("Message not in order", frame.getBody().equals(data[i]));
    }
    for (int i = 0; i < ctr; ++i) {
        data[i] = getName() + ":second:" + i;
        sendJmsMessage(data[i]);
    }
    for (int i = 0; i < ctr; ++i) {
        frame = conn.receiveFrame();
        Assert.assertTrue("Message not in order", frame.getBody().equals(data[i]));
    }
    conn.disconnect();
}
Also used : ClientStompFrame(org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) Test(org.junit.Test)

Aggregations

ClientStompFrame (org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame)195 Test (org.junit.Test)173 MessageConsumer (javax.jms.MessageConsumer)67 TextMessage (javax.jms.TextMessage)62 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)51 BytesMessage (javax.jms.BytesMessage)43 StompClientConnection (org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnection)41 Message (javax.jms.Message)37 IOException (java.io.IOException)7 URI (java.net.URI)5 MessageProducer (javax.jms.MessageProducer)5 ClientMessage (org.apache.activemq.artemis.api.core.client.ClientMessage)4 ClosedChannelException (java.nio.channels.ClosedChannelException)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 Matcher (java.util.regex.Matcher)2 Pattern (java.util.regex.Pattern)2 AddressSettings (org.apache.activemq.artemis.core.settings.impl.AddressSettings)2 LargeMessageTestBase (org.apache.activemq.artemis.tests.integration.largemessage.LargeMessageTestBase)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ArrayList (java.util.ArrayList)1