You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2013/08/20 17:22:05 UTC
svn commit: r1515843 - in /activemq/trunk/activemq-stomp/src:
main/java/org/apache/activemq/transport/stomp/ProtocolConverter.java
test/java/org/apache/activemq/transport/stomp/Stomp12Test.java
Author: tabish
Date: Tue Aug 20 15:22:05 2013
New Revision: 1515843
URL: http://svn.apache.org/r1515843
Log:
fix and add test for: https://issues.apache.org/jira/browse/AMQ-4686
Modified:
activemq/trunk/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/ProtocolConverter.java
activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/Stomp12Test.java
Modified: activemq/trunk/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/ProtocolConverter.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/ProtocolConverter.java?rev=1515843&r1=1515842&r2=1515843&view=diff
==============================================================================
--- activemq/trunk/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/ProtocolConverter.java (original)
+++ activemq/trunk/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/ProtocolConverter.java Tue Aug 20 15:22:05 2013
@@ -554,8 +554,8 @@ public class ProtocolConverter {
String browser = headers.get(Stomp.Headers.Subscribe.BROWSER);
if (browser != null && browser.equals(Stomp.TRUE)) {
- if (!this.version.equals(Stomp.V1_1)) {
- throw new ProtocolException("Queue Browser feature only valid for Stomp v1.1 clients!");
+ if (this.version.equals(Stomp.V1_0)) {
+ throw new ProtocolException("Queue Browser feature only valid for Stomp v1.1+ clients!");
}
consumerInfo.setBrowser(true);
Modified: activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/Stomp12Test.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/Stomp12Test.java?rev=1515843&r1=1515842&r2=1515843&view=diff
==============================================================================
--- activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/Stomp12Test.java (original)
+++ activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/Stomp12Test.java Tue Aug 20 15:22:05 2013
@@ -357,4 +357,71 @@ public class Stomp12Test extends StompTe
stompConnection.sendFrame(disconnect);
}
+ @Test
+ public void testQueueBrowerSubscription() throws Exception {
+
+ final int MSG_COUNT = 10;
+
+ String connectFrame = "STOMP\n" +
+ "login:system\n" +
+ "passcode:manager\n" +
+ "accept-version:1.2\n" +
+ "host:localhost\n" +
+ "\n" + Stomp.NULL;
+
+ stompConnection.sendFrame(connectFrame);
+
+ String f = stompConnection.receiveFrame();
+ LOG.debug("Broker sent: " + f);
+
+ assertTrue(f.startsWith("CONNECTED"));
+
+ for(int i = 0; i < MSG_COUNT; ++i) {
+ String message = "SEND\n" + "destination:/queue/" + getQueueName() + "\n" +
+ "receipt:0\n" +
+ "\n" + "Hello World {" + i + "}" + Stomp.NULL;
+ stompConnection.sendFrame(message);
+ StompFrame repsonse = stompConnection.receive();
+ assertEquals("0", repsonse.getHeaders().get(Stomp.Headers.Response.RECEIPT_ID));
+ }
+
+ String subscribe = "SUBSCRIBE\n" + "destination:/queue/" + getQueueName() + "\n" +
+ "id:12345\n" + "browser:true\n\n" + Stomp.NULL;
+ stompConnection.sendFrame(subscribe);
+
+ for(int i = 0; i < MSG_COUNT; ++i) {
+ StompFrame message = stompConnection.receive();
+ assertEquals(Stomp.Responses.MESSAGE, message.getAction());
+ assertEquals("12345", message.getHeaders().get(Stomp.Headers.Message.SUBSCRIPTION));
+ }
+
+ // We should now get a browse done message
+ StompFrame browseDone = stompConnection.receive();
+ LOG.debug("Browse Done: " + browseDone.toString());
+ assertEquals(Stomp.Responses.MESSAGE, browseDone.getAction());
+ assertEquals("12345", browseDone.getHeaders().get(Stomp.Headers.Message.SUBSCRIPTION));
+ assertEquals("end", browseDone.getHeaders().get(Stomp.Headers.Message.BROWSER));
+ assertTrue(browseDone.getHeaders().get(Stomp.Headers.Message.DESTINATION) != null);
+
+ String unsub = "UNSUBSCRIBE\n" + "destination:/queue/" + getQueueName() + "\n" +
+ "id:12345\n\n" + Stomp.NULL;
+ stompConnection.sendFrame(unsub);
+
+ Thread.sleep(2000);
+
+ subscribe = "SUBSCRIBE\n" + "destination:/queue/" + getQueueName() + "\n" + "id:12345\n\n" + Stomp.NULL;
+ stompConnection.sendFrame(subscribe);
+
+ for(int i = 0; i < MSG_COUNT; ++i) {
+ StompFrame message = stompConnection.receive();
+ assertEquals(Stomp.Responses.MESSAGE, message.getAction());
+ assertEquals("12345", message.getHeaders().get(Stomp.Headers.Message.SUBSCRIPTION));
+ }
+
+ stompConnection.sendFrame(unsub);
+
+ String frame = "DISCONNECT\n" + "\n\n" + Stomp.NULL;
+ stompConnection.sendFrame(frame);
+ }
+
}