diff options
| author | Martin Ritchie <ritchiem@apache.org> | 2007-10-01 15:31:00 +0000 |
|---|---|---|
| committer | Martin Ritchie <ritchiem@apache.org> | 2007-10-01 15:31:00 +0000 |
| commit | 95f531a2e97c7566be7fc07c259f81c9d7ff2842 (patch) | |
| tree | 55dfe5aef0bbf63fc1238c9a10db8b6a7ab1b5a9 /java/client/src | |
| parent | f07cc9da6e3f138efe5c6d1b76968a9b8eee5bf0 (diff) | |
| download | qpid-python-95f531a2e97c7566be7fc07c259f81c9d7ff2842.tar.gz | |
QPID-611 QPID-620. DurableSubscriptionTest was failing due to a race condition when using NO_ACK. This is due to the Queue Total Size being updated after the send, but after the send and NO_ACK the msg data is purged and so there is no size to retrieve. Changed all references to msg.dequeue to queue.dequeue where appropriate so we can use that single point in the future for updating the Queue Total Size.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/M2.1@580993 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/client/src')
| -rw-r--r-- | java/client/src/test/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java index c8d43a47a5..a9c93d7227 100644 --- a/java/client/src/test/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java +++ b/java/client/src/test/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java @@ -114,18 +114,28 @@ public class DurableSubscriptionTest extends TestCase con.close(); } - public void testDurability() throws AMQException, JMSException, URLSyntaxException + public void testDurabilityNOACK() throws AMQException, JMSException, URLSyntaxException + { + durabilityImpl(AMQSession.NO_ACKNOWLEDGE); + } + + public void testDurabilityAUTOACK() throws AMQException, JMSException, URLSyntaxException + { + durabilityImpl(Session.AUTO_ACKNOWLEDGE); + } + + private void durabilityImpl(int ackMode) throws AMQException, JMSException, URLSyntaxException { AMQConnection con = new AMQConnection("vm://:1", "guest", "guest", "test", "test"); AMQTopic topic = new AMQTopic(con, "MyTopic"); - Session session1 = con.createSession(false, AMQSession.NO_ACKNOWLEDGE); + Session session1 = con.createSession(false, ackMode); MessageConsumer consumer1 = session1.createConsumer(topic); - Session sessionProd = con.createSession(false, AMQSession.NO_ACKNOWLEDGE); + Session sessionProd = con.createSession(false, ackMode); MessageProducer producer = sessionProd.createProducer(topic); - Session session2 = con.createSession(false, AMQSession.NO_ACKNOWLEDGE); + Session session2 = con.createSession(false, ackMode); TopicSubscriber consumer2 = session2.createDurableSubscriber(topic, "MySubscription"); con.start(); @@ -133,36 +143,41 @@ public class DurableSubscriptionTest extends TestCase producer.send(session1.createTextMessage("A")); Message msg; - msg = consumer1.receive(); - assertEquals("A", ((TextMessage) msg).getText()); msg = consumer1.receive(100); - assertEquals(null, msg); + assertNotNull("Message should be available", msg); + assertEquals("Message Text doesn't match", "A", ((TextMessage) msg).getText()); + + msg = consumer1.receive(100); + assertNull("There should be no more messages for consumption on consumer1.", msg); msg = consumer2.receive(); - assertEquals("A", ((TextMessage) msg).getText()); + assertNotNull(msg); + assertEquals("Consumer 2 should also received the first msg.", "A", ((TextMessage) msg).getText()); msg = consumer2.receive(100); - assertEquals(null, msg); + assertNull("There should be no more messages for consumption on consumer2.", msg); consumer2.close(); - Session session3 = con.createSession(false, AMQSession.NO_ACKNOWLEDGE); + Session session3 = con.createSession(false, ackMode); MessageConsumer consumer3 = session3.createDurableSubscriber(topic, "MySubscription"); producer.send(session1.createTextMessage("B")); _logger.info("Receive message on consumer 1 :expecting B"); msg = consumer1.receive(100); - assertEquals("B", ((TextMessage) msg).getText()); + assertNotNull("Consumer 1 should get message 'B'.", msg); + assertEquals("Incorrect Message recevied on consumer1.", "B", ((TextMessage) msg).getText()); _logger.info("Receive message on consumer 1 :expecting null"); msg = consumer1.receive(100); - assertEquals(null, msg); + assertNull("There should be no more messages for consumption on consumer1.", msg); _logger.info("Receive message on consumer 3 :expecting B"); msg = consumer3.receive(100); - assertEquals("B", ((TextMessage) msg).getText()); + assertNotNull("Consumer 3 should get message 'B'.", msg); + assertEquals("Incorrect Message recevied on consumer4.", "B", ((TextMessage) msg).getText()); _logger.info("Receive message on consumer 3 :expecting null"); msg = consumer3.receive(100); - assertEquals(null, msg); + assertNull("There should be no more messages for consumption on consumer3.", msg); con.close(); } |
