You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by gt...@apache.org on 2011/09/15 01:41:42 UTC
svn commit: r1170901 -
/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/StompTest.java
Author: gtully
Date: Wed Sep 14 23:41:42 2011
New Revision: 1170901
URL: http://svn.apache.org/viewvc?rev=1170901&view=rev
Log:
https://issues.apache.org/jira/browse/AMQ-3497 - make test case more deterministic using receipts on unsub such that a sub only gets one message
Modified:
activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/StompTest.java
Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/StompTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/StompTest.java?rev=1170901&r1=1170900&r2=1170901&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/StompTest.java (original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/StompTest.java Wed Sep 14 23:41:42 2011
@@ -380,6 +380,7 @@ public class StompTest extends Combinati
public void testSubscriptionReceipts() throws Exception {
final int done = 500;
int count = 0;
+ int receiptId = 0;
URI connectUri = new URI(bindAddress);
@@ -393,8 +394,10 @@ public class StompTest extends Combinati
frame = sender.receiveFrame();
assertTrue(frame.startsWith("CONNECTED"));
- frame = "SEND\n" + "destination:/queue/" + getQueueName() + "\n\n" + "Hello World:" + count + Stomp.NULL;
+ frame = "SEND\n" + "destination:/queue/" + getQueueName() + "\n" + "receipt: " + (receiptId++) + "\n\n" + "Hello World:" + (count++) + Stomp.NULL;
sender.sendFrame(frame);
+ frame = sender.receiveFrame();
+ assertTrue("" + frame, frame.startsWith("RECEIPT"));
sender.disconnect();
@@ -407,15 +410,21 @@ public class StompTest extends Combinati
frame = receiver.receiveFrame();
assertTrue(frame.startsWith("CONNECTED"));
- frame = "SUBSCRIBE\n" + "destination:/queue/" + getQueueName() + "\n" + "receipt: " + (count++) + "\n\n" + Stomp.NULL;
+ frame = "SUBSCRIBE\n" + "destination:/queue/" + getQueueName() + "\n" + "receipt: " + (receiptId++) + "\n\n" + Stomp.NULL;
receiver.sendFrame(frame);
frame = receiver.receiveFrame();
assertTrue("" + frame, frame.startsWith("RECEIPT"));
assertTrue("Receipt contains receipt-id", frame.indexOf(Stomp.Headers.Response.RECEIPT_ID) >= 0);
- LOG.info("received: " + frame.substring(frame.indexOf(Stomp.Headers.Response.RECEIPT_ID)));
frame = receiver.receiveFrame();
assertTrue("" + frame, frame.startsWith("MESSAGE"));
+
+ // remove suscription so we don't hang about and get next message
+ frame = "UNSUBSCRIBE\n" + "destination:/queue/" + getQueueName() + "\n" + "receipt: " + (receiptId++) + "\n\n" + Stomp.NULL;
+ receiver.sendFrame(frame);
+ frame = receiver.receiveFrame();
+ assertTrue("" + frame, frame.startsWith("RECEIPT"));
+
receiver.disconnect();
} while (count < done);