diff options
| author | Gordon Sim <gsim@apache.org> | 2006-09-22 09:53:47 +0000 |
|---|---|---|
| committer | Gordon Sim <gsim@apache.org> | 2006-09-22 09:53:47 +0000 |
| commit | 924764a6a8dbcb0a2dd7a432221987302b389af8 (patch) | |
| tree | 06f5fdf4845fd07fbbbbec24f8de324b37666bef /qpid/python | |
| parent | 69717c3785632ae8c1f85a5e8ee07def87be2ef6 (diff) | |
| download | qpid-python-924764a6a8dbcb0a2dd7a432221987302b389af8.tar.gz | |
Added tests for basic_cancel and for handling of invalid channel ids.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@448881 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/python')
| -rw-r--r-- | qpid/python/tests/basic.py | 24 | ||||
| -rw-r--r-- | qpid/python/tests/broker.py | 18 |
2 files changed, 42 insertions, 0 deletions
diff --git a/qpid/python/tests/basic.py b/qpid/python/tests/basic.py index c3a2414eac..75d49ec805 100644 --- a/qpid/python/tests/basic.py +++ b/qpid/python/tests/basic.py @@ -113,3 +113,27 @@ class BasicTests(TestBase): except Closed, e: self.assertConnectionException(530, e.args[0]) + def test_basic_cancel(self): + """ + Test compliance of the basic.cancel method + """ + channel = self.channel + #setup, declare a queue: + channel.queue_declare(queue="test-queue-4", exclusive=True) + channel.basic_consume(consumer_tag="my-consumer", queue="test-queue-4") + channel.basic_publish(routing_key="test-queue-4", content=Content("One")) + + #cancel should stop messages being delivered + channel.basic_cancel(consumer_tag="my-consumer") + channel.basic_publish(routing_key="test-queue-4", content=Content("Two")) + myqueue = self.client.queue("my-consumer") + msg = myqueue.get(timeout=1) + self.assertEqual("One", msg.content.body) + try: + msg = myqueue.get(timeout=1) + self.fail("Got message after cancellation: " + msg) + except Empty: None + + #cancellation of non-existant consumers should be handled without error + channel.basic_cancel(consumer_tag="my-consumer") + channel.basic_cancel(consumer_tag="this-never-existed") diff --git a/qpid/python/tests/broker.py b/qpid/python/tests/broker.py index 1345076604..307d447a6c 100644 --- a/qpid/python/tests/broker.py +++ b/qpid/python/tests/broker.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from qpid.client import Closed from qpid.queue import Empty from qpid.content import Content from qpid.testlib import testrunner, TestBase @@ -82,3 +83,20 @@ class BrokerTests(TestBase): msg = queue.get(timeout=5) self.assert_(msg.content.body == body) + def test_invalid_channel(self): + other = self.connect() + channel = other.channel(200) + try: + channel.queue_declare(exclusive=True) + self.fail("Expected error on queue_declare for invalid channel") + except Closed, e: + self.assertConnectionException(504, e.args[0]) + + channel = self.client.channel(200) + channel.channel_open() + channel.channel_close() + try: + channel.queue_declare(exclusive=True) + self.fail("Expected error on queue_declare for closed channel") + except Closed, e: + self.assertConnectionException(504, e.args[0]) |
