Author: tabish Date: Thu May 17 13:09:32 2012 New Revision: 1339589 URL: http://svn.apache.org/viewvc?rev=1339589&view=rev Log: Add test to show no issue for: https://issues.apache.org/jira/browse/AMQ-3835
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=1339589&r1=1339588&r2=1339589&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 Thu May 17 13:09:32 2012 @@ -1441,6 +1441,85 @@ public class StompTest extends Combinati assertNull(stompMessage.getHeaders().get("transaction")); } + public void testPrefetchSizeOfOneClientAck() throws Exception { + stompConnection.connect("system", "manager"); + + HashMap<String, String> headers = new HashMap<String, String>(); + headers.put("activemq.prefetchSize", "1"); + stompConnection.subscribe("/queue/" + getQueueName(), "client", headers); + + // send messages using JMS + sendMessage("message 1"); + sendMessage("message 2"); + sendMessage("message 3"); + sendMessage("message 4"); + sendMessage("message 5"); + + StompFrame frame = stompConnection.receive(); + assertEquals(frame.getBody(), "message 1"); + + try { + StompFrame frameNull = stompConnection.receive(500); + if (frameNull != null) { + fail("Should not have received the second message"); + } + } catch (SocketTimeoutException soe) {} + + stompConnection.ack(frame); + + StompFrame frame1 = stompConnection.receive(); + assertEquals(frame1.getBody(), "message 2"); + + try { + StompFrame frameNull = stompConnection.receive(500); + if (frameNull != null) { + fail("Should not have received the third message"); + } + } catch (SocketTimeoutException soe) {} + + stompConnection.ack(frame1); + StompFrame frame2 = stompConnection.receive(); + assertEquals(frame2.getBody(), "message 3"); + + try { + StompFrame frameNull = stompConnection.receive(500); + if (frameNull != null) { + fail("Should not have received the fourth message"); + } + } catch (SocketTimeoutException soe) {} + + stompConnection.ack(frame2); + StompFrame frame3 = stompConnection.receive(); + assertEquals(frame3.getBody(), "message 4"); + + try { + StompFrame frameNull = stompConnection.receive(500); + if (frameNull != null) { + fail("Should not have received the fifth message"); + } + } catch (SocketTimeoutException soe) {} + + stompConnection.ack(frame3); + StompFrame frame4 = stompConnection.receive(); + assertEquals(frame4.getBody(), "message 5"); + + try { + StompFrame frameNull = stompConnection.receive(500); + if (frameNull != null) { + fail("Should not have received any more messages"); + } + } catch (SocketTimeoutException soe) {} + + stompConnection.ack(frame4); + + try { + StompFrame frameNull = stompConnection.receive(500); + if (frameNull != null) { + fail("Should not have received the any more messages"); + } + } catch (SocketTimeoutException soe) {} + } + public void testPrefetchSize() throws Exception { stompConnection.connect("system", "manager");