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));
}
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);
}
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();
}
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();
}
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();
}
Aggregations