use of org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame in project activemq-artemis by apache.
the class StompV12Test method testTwoSubscribers.
@Test
public void testTwoSubscribers() throws Exception {
conn.connect(defUser, defPass, CLIENT_ID);
subscribeTopic(conn, "sub1", Stomp.Headers.Subscribe.AckModeValues.AUTO, null);
StompClientConnection newConn = StompClientConnectionFactory.createClientConnection(v11Uri);
newConn.connect(defUser, defPass, "myclientid2");
subscribeTopic(newConn, "sub2", Stomp.Headers.Subscribe.AckModeValues.AUTO, null);
send(conn, getTopicPrefix() + getTopicName(), null, "Hello World");
// receive message from socket
ClientStompFrame frame = conn.receiveFrame(1000);
System.out.println("received frame : " + frame);
Assert.assertEquals("Hello World", frame.getBody());
Assert.assertEquals("sub1", frame.getHeader(Stomp.Headers.Message.SUBSCRIPTION));
frame = newConn.receiveFrame(1000);
System.out.println("received 2 frame : " + frame);
Assert.assertEquals("Hello World", frame.getBody());
Assert.assertEquals("sub2", frame.getHeader(Stomp.Headers.Message.SUBSCRIPTION));
// remove suscription
unsubscribe(conn, "sub1", true);
unsubscribe(newConn, "sub2", true);
conn.disconnect();
newConn.disconnect();
}
use of org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame in project activemq-artemis by apache.
the class StompV12Test method testSendAndReceiveWithEscapedCharactersInSenderId.
@Test
public void testSendAndReceiveWithEscapedCharactersInSenderId() throws Exception {
conn.connect(defUser, defPass);
ClientStompFrame response = send(conn, getQueuePrefix() + getQueueName(), "text/plain", "Hello World 1!");
Assert.assertNull(response);
// subscribe
subscribe(conn, "ID\\cMYMACHINE-50616-635482262727823605-1\\c1\\c1\\c1");
ClientStompFrame frame = conn.receiveFrame();
System.out.println("Received: " + frame);
Assert.assertEquals(Stomp.Responses.MESSAGE, frame.getCommand());
Assert.assertEquals("ID:MYMACHINE-50616-635482262727823605-1:1:1:1", frame.getHeader(Stomp.Headers.Message.SUBSCRIPTION));
Assert.assertNotNull(frame.getHeader(Stomp.Headers.Message.MESSAGE_ID));
Assert.assertEquals(getQueuePrefix() + getQueueName(), frame.getHeader(Stomp.Headers.Subscribe.DESTINATION));
Assert.assertEquals("Hello World 1!", frame.getBody());
// unsub
unsubscribe(conn, "ID\\cMYMACHINE-50616-635482262727823605-1\\c1\\c1\\c1");
conn.disconnect();
}
use of org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame in project activemq-artemis by apache.
the class StompV12Test method testSubscribeWithAutoAckAndSelector.
@Test
public void testSubscribeWithAutoAckAndSelector() throws Exception {
conn.connect(defUser, defPass);
subscribe(conn, "sub1", Stomp.Headers.Subscribe.AckModeValues.AUTO, null, "foo = 'zzz'");
sendJmsMessage("Ignored message", "foo", "1234");
sendJmsMessage("Real message", "foo", "zzz");
ClientStompFrame frame = conn.receiveFrame();
Assert.assertTrue("Should have received the real message but got: " + frame, frame.getBody().equals("Real message"));
conn.disconnect();
}
use of org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame in project activemq-artemis by apache.
the class StompV12Test 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 StompV12Test method testAckWithWrongMessageId.
@Test
public void testAckWithWrongMessageId() throws Exception {
conn.connect(defUser, defPass);
subscribe(conn, "sub1", "client");
sendJmsMessage(getName());
ClientStompFrame frame = conn.receiveFrame();
Assert.assertNotNull(frame);
ack(conn, "someother");
ClientStompFrame error = conn.receiveFrame();
System.out.println("Receiver error: " + error);
waitDisconnect(conn);
Assert.assertFalse("Should be disconnected in STOMP 1.2 after ERROR", conn.isConnected());
// message should still there
MessageConsumer consumer = session.createConsumer(queue);
Message message = consumer.receive(1000);
Assert.assertNotNull(message);
}
Aggregations