diff options
author | Rafael H. Schloming <rhs@apache.org> | 2009-06-02 20:49:42 +0000 |
---|---|---|
committer | Rafael H. Schloming <rhs@apache.org> | 2009-06-02 20:49:42 +0000 |
commit | 75cd78bc5af13d6ddddd07cc1ff7f36d0807eed4 (patch) | |
tree | cc69b7fbefe339dad411bcf9d6039a3594482c82 /python/qpid/tests/messaging.py | |
parent | 0ecbdd6371c9c3ac05eba03a92b6c977ebb206b5 (diff) | |
download | qpid-python-75cd78bc5af13d6ddddd07cc1ff7f36d0807eed4.tar.gz |
added receiver capacity and tests
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@781161 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python/qpid/tests/messaging.py')
-rw-r--r-- | python/qpid/tests/messaging.py | 55 |
1 files changed, 43 insertions, 12 deletions
diff --git a/python/qpid/tests/messaging.py b/python/qpid/tests/messaging.py index ef82d87f13..fea61f766b 100644 --- a/python/qpid/tests/messaging.py +++ b/python/qpid/tests/messaging.py @@ -22,7 +22,7 @@ import time from qpid.tests import Test -from qpid.messaging import Connection, Disconnected, Empty, Message, uuid4 +from qpid.messaging import Connection, Disconnected, Empty, Message, UNLIMITED, uuid4 from Queue import Queue, Empty as QueueEmpty class Base(Test): @@ -69,6 +69,9 @@ class Base(Test): pass return msgs + def delay(self): + time.sleep(2) + class SetupTests(Base): def testOpen(self): @@ -107,7 +110,6 @@ class ConnectionTests(Base): ssn = self.conn.session() self.ping(ssn) self.conn.disconnect() - import socket try: self.ping(ssn) assert False, "ping succeeded" @@ -296,10 +298,10 @@ class ReceiverTests(Base): def testStart(self): content = self.send("testStart") - time.sleep(2) + self.delay() assert self.rcv.pending() == 0 self.rcv.start() - time.sleep(2) + self.delay() assert self.rcv.pending() == 1 msg = self.rcv.fetch(0) assert msg.content == content @@ -309,7 +311,7 @@ class ReceiverTests(Base): def testStop(self): self.rcv.start() one = self.send("testStop", 1) - time.sleep(2) + self.delay() assert self.rcv.pending() == 1 msg = self.rcv.fetch(0) assert msg.content == one @@ -317,7 +319,7 @@ class ReceiverTests(Base): self.rcv.stop() two = self.send("testStop", 2) - time.sleep(2) + self.delay() assert self.rcv.pending() == 0 msg = self.rcv.fetch(0) assert msg.content == two @@ -326,27 +328,56 @@ class ReceiverTests(Base): def testPending(self): self.rcv.start() - assert self.rcv.pending() == 0 for i in range(3): self.send("testPending", i) - time.sleep(2) - + self.delay() assert self.rcv.pending() == 3 for i in range(3, 10): self.send("testPending", i) - time.sleep(2) - + self.delay() assert self.rcv.pending() == 10 self.drain(self.rcv, limit=3) - assert self.rcv.pending() == 7 self.drain(self.rcv) + assert self.rcv.pending() == 0 + + self.ssn.acknowledge() + def testCapacity(self): + self.rcv.capacity = 5 + self.rcv.start() + assert self.rcv.pending() == 0 + + for i in range(15): + self.send("testCapacity", i) + self.delay() + assert self.rcv.pending() == 5 + + self.drain(self.rcv, limit = 5) + self.delay() + assert self.rcv.pending() == 5 + + self.drain(self.rcv) + assert self.rcv.pending() == 0 + + self.ssn.acknowledge() + + def testCapacityUNLIMITED(self): + self.rcv.capacity = UNLIMITED + self.rcv.start() + assert self.rcv.pending() == 0 + + for i in range(10): + self.send("testCapacityUNLIMITED", i) + self.delay() + assert self.rcv.pending() == 10 + + self.drain(self.rcv) assert self.rcv.pending() == 0 self.ssn.acknowledge() |