summaryrefslogtreecommitdiff
path: root/python/tests
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2006-09-27 13:21:43 +0000
committerGordon Sim <gsim@apache.org>2006-09-27 13:21:43 +0000
commit72aff4cc22932bd98b542ac9dd6393e23985e312 (patch)
treed3159aa7eeba203fea961b7397809ad805c74e1a /python/tests
parentf1745fde1a2164878794f0bcf62fa62aacbe5cae (diff)
downloadqpid-python-72aff4cc22932bd98b542ac9dd6393e23985e312.tar.gz
Initial implementation of basic_ack & basic_recover
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@450434 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python/tests')
-rw-r--r--python/tests/broker.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/python/tests/broker.py b/python/tests/broker.py
index 307d447a6c..1c31767ef8 100644
--- a/python/tests/broker.py
+++ b/python/tests/broker.py
@@ -100,3 +100,48 @@ class BrokerTests(TestBase):
self.fail("Expected error on queue_declare for closed channel")
except Closed, e:
self.assertConnectionException(504, e.args[0])
+
+
+ def test_acknowledgement(self):
+ """
+ Test basic ack/recover behaviour
+ """
+ channel = self.channel
+ channel.queue_declare(queue="test-ack-queue")
+
+ reply = channel.basic_consume(queue="test-ack-queue", no_ack=False)
+ queue = self.client.queue(reply.consumer_tag)
+
+ channel.basic_publish(routing_key="test-ack-queue", content=Content("One"))
+ channel.basic_publish(routing_key="test-ack-queue", content=Content("Two"))
+ channel.basic_publish(routing_key="test-ack-queue", content=Content("Three"))
+ channel.basic_publish(routing_key="test-ack-queue", content=Content("Four"))
+ channel.basic_publish(routing_key="test-ack-queue", content=Content("Five"))
+
+ msg1 = queue.get(timeout=1)
+ msg2 = queue.get(timeout=1)
+ msg3 = queue.get(timeout=1)
+ msg4 = queue.get(timeout=1)
+ msg5 = queue.get(timeout=1)
+
+ self.assertEqual("One", msg1.content.body)
+ self.assertEqual("Two", msg2.content.body)
+ self.assertEqual("Three", msg3.content.body)
+ self.assertEqual("Four", msg4.content.body)
+ self.assertEqual("Five", msg5.content.body)
+
+ channel.basic_ack(delivery_tag=msg2.delivery_tag, multiple=True) #One & Two
+ channel.basic_ack(delivery_tag=msg4.delivery_tag, multiple=False) #Four
+
+ channel.basic_recover(requeue=False)
+
+ msg3b = queue.get(timeout=1)
+ msg5b = queue.get(timeout=1)
+
+ self.assertEqual("Three", msg3b.content.body)
+ self.assertEqual("Five", msg5b.content.body)
+
+ try:
+ extra = queue.get(timeout=1)
+ self.fail("Got unexpected message: " + extra.content.body)
+ except Empty: None