use of org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame in project activemq-artemis by apache.
the class StompTest method testSubscribeToNonExistentQueue.
@Test
public void testSubscribeToNonExistentQueue() throws Exception {
String nonExistentQueue = RandomUtil.randomString();
conn.connect(defUser, defPass);
subscribe(conn, null, null, null, null, getQueuePrefix() + nonExistentQueue, true);
sendJmsMessage(getName(), ActiveMQJMSClient.createQueue(nonExistentQueue));
ClientStompFrame frame = conn.receiveFrame(1000);
Assert.assertEquals(Stomp.Responses.MESSAGE, frame.getCommand());
Assert.assertEquals(getQueuePrefix() + nonExistentQueue, frame.getHeader(Stomp.Headers.Send.DESTINATION));
Assert.assertEquals(getName(), frame.getBody());
assertNotNull(server.getActiveMQServer().getPostOffice().getBinding(new SimpleString(nonExistentQueue)));
final Queue subscription = ((LocalQueueBinding) server.getActiveMQServer().getPostOffice().getBinding(new SimpleString(nonExistentQueue))).getQueue();
assertTrue(Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisfied() throws Exception {
if (subscription.getMessageCount() == 0)
return true;
else
return false;
}
}, 1000, 50));
unsubscribe(conn, null, getQueuePrefix() + nonExistentQueue, true, false);
assertNull(server.getActiveMQServer().getPostOffice().getBinding(new SimpleString(nonExistentQueue)));
sendJmsMessage(getName(), ActiveMQJMSClient.createQueue(nonExistentQueue));
frame = conn.receiveFrame(1000);
log.info("Received frame: " + frame);
Assert.assertNull("No message should have been received since subscription was removed", frame);
conn.disconnect();
}
use of org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame in project activemq-artemis by apache.
the class StompTest method testSendMessageWithCustomHeadersAndHyphenatedSelector.
@Test
public void testSendMessageWithCustomHeadersAndHyphenatedSelector() throws Exception {
MessageConsumer consumer = session.createConsumer(queue, "hyphenated_props:b-ar = '123'");
conn.connect(defUser, defPass);
ClientStompFrame frame = conn.createFrame(Stomp.Commands.SEND).addHeader(Stomp.Headers.Send.DESTINATION, getQueuePrefix() + getQueueName()).addHeader("foo", "abc").addHeader("b-ar", "123").setBody("Hello World");
conn.sendFrame(frame);
TextMessage message = (TextMessage) consumer.receive(1000);
Assert.assertNotNull(message);
Assert.assertEquals("Hello World", message.getText());
Assert.assertEquals("foo", "abc", message.getStringProperty("foo"));
Assert.assertEquals("b-ar", "123", message.getStringProperty("b-ar"));
}
use of org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame in project activemq-artemis by apache.
the class StompTest method testRoutingSemantics.
public void testRoutingSemantics(String routingType, String destination) throws Exception {
conn.connect(defUser, defPass);
String uuid = UUID.randomUUID().toString();
ClientStompFrame frame = conn.createFrame(Stomp.Commands.SUBSCRIBE).addHeader(Stomp.Headers.Subscribe.SUBSCRIPTION_TYPE, routingType).addHeader(Stomp.Headers.Subscribe.DESTINATION, destination).addHeader(Stomp.Headers.RECEIPT_REQUESTED, uuid);
frame = conn.sendFrame(frame);
assertEquals(Stomp.Responses.ERROR, frame.getCommand());
uuid = UUID.randomUUID().toString();
frame = conn.createFrame(Stomp.Commands.SEND).addHeader(Stomp.Headers.Send.DESTINATION_TYPE, RoutingType.MULTICAST.toString()).addHeader(Stomp.Headers.Send.DESTINATION, getQueuePrefix() + getQueueName()).addHeader(Stomp.Headers.RECEIPT_REQUESTED, uuid);
frame = conn.sendFrame(frame);
assertEquals(Stomp.Responses.ERROR, frame.getCommand());
}
use of org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame in project activemq-artemis by apache.
the class StompTest method testInvokeOperationFromStomp.
@Test
public void testInvokeOperationFromStomp() throws Exception {
conn.connect(defUser, defPass);
subscribe(conn, null);
ClientStompFrame frame = conn.createFrame(Stomp.Commands.SEND).addHeader(Stomp.Headers.Send.DESTINATION, ActiveMQDefaultConfiguration.getDefaultManagementAddress().toString()).addHeader(Stomp.Headers.Send.REPLY_TO, getQueuePrefix() + getQueueName()).addHeader(ManagementHelper.HDR_RESOURCE_NAME.toString(), ResourceNames.QUEUE + getQueuePrefix() + getQueueName()).addHeader(ManagementHelper.HDR_OPERATION_NAME.toString(), "countMessages").setBody("[\"color = 'blue'\"]");
conn.sendFrame(frame);
frame = conn.receiveFrame(10000);
IntegrationTestLogger.LOGGER.info("Received: " + frame);
Assert.assertEquals(Boolean.TRUE.toString(), frame.getHeader(ManagementHelper.HDR_OPERATION_SUCCEEDED.toString()));
// there is no such messages => 0 returned in a JSON array
Assert.assertEquals("[0]", frame.getBody());
unsubscribe(conn, null);
conn.disconnect();
}
use of org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame in project activemq-artemis by apache.
the class StompTest method testMessagesAreInOrder.
@Test
public void testMessagesAreInOrder() throws Exception {
int ctr = 10;
String[] data = new String[ctr];
conn.connect(defUser, defPass);
subscribe(conn, null, Stomp.Headers.Subscribe.AckModeValues.AUTO);
for (int i = 0; i < ctr; ++i) {
data[i] = getName() + i;
sendJmsMessage(data[i]);
}
for (int i = 0; i < ctr; ++i) {
ClientStompFrame frame = conn.receiveFrame(1000);
Assert.assertTrue("Message not in order", frame.getBody().equals(data[i]));
}
// sleep a while before publishing another set of messages
Thread.sleep(200);
for (int i = 0; i < ctr; ++i) {
data[i] = getName() + Stomp.Headers.SEPARATOR + "second:" + i;
sendJmsMessage(data[i]);
}
for (int i = 0; i < ctr; ++i) {
ClientStompFrame frame = conn.receiveFrame(1000);
Assert.assertTrue("Message not in order", frame.getBody().equals(data[i]));
}
conn.disconnect();
}
Aggregations