summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael H. Schloming <rhs@apache.org>2009-06-04 17:33:25 +0000
committerRafael H. Schloming <rhs@apache.org>2009-06-04 17:33:25 +0000
commit2d42d8bb32d0ac6b195a23e00b42b9d2dcbd73f3 (patch)
treef7a9cf723674bf28f12bc1678a8f60eec963e93b
parent03e9ba8e51bae6344c73ba263d1c8a0c86dbbdb1 (diff)
downloadqpid-python-2d42d8bb32d0ac6b195a23e00b42b9d2dcbd73f3.tar.gz
Streamlined transaction tests and added some additional coverage.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@781806 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--python/qpid/tests/messaging.py101
1 files changed, 68 insertions, 33 deletions
diff --git a/python/qpid/tests/messaging.py b/python/qpid/tests/messaging.py
index 2346dbb050..aa2ec7fd87 100644
--- a/python/qpid/tests/messaging.py
+++ b/python/qpid/tests/messaging.py
@@ -244,58 +244,93 @@ class SessionTests(Base):
snd.close()
return contents
- def testCommitSend(self):
+ def txTest(self, commit):
txssn = self.conn.session(transactional=True)
- contents = self.send(txssn, "test-commit-send-queue", "testCommitSend", 3)
- rcv = self.ssn.receiver("test-commit-send-queue")
- self.assertEmpty(rcv)
- txssn.commit()
- assert contents == self.drain(rcv)
+ contents = self.send(self.ssn, "test-tx-queue", "txTest", 3)
+ txrcv = txssn.receiver("test-tx-queue")
+ txsnd = txssn.sender("test-tx-queue-copy")
+ rcv = self.ssn.receiver(txrcv.source)
+ copy_rcv = self.ssn.receiver(txsnd.target)
+ self.assertEmpty(copy_rcv)
+ for i in range(3):
+ m = txrcv.fetch(0)
+ txsnd.send(m)
+ self.assertEmpty(copy_rcv)
+ txssn.acknowledge()
+ if commit:
+ txssn.commit()
+ self.assertEmpty(rcv)
+ assert contents == self.drain(copy_rcv)
+ else:
+ txssn.rollback()
+ assert contents == self.drain(rcv)
+ self.assertEmpty(copy_rcv)
self.ssn.acknowledge()
- def testCommitAck(self):
- txssn = self.conn.session(transactional=True)
- txrcv = txssn.receiver("test-commit-ack-queue")
- self.assertEmpty(txrcv)
- contents = self.send(self.ssn, "test-commit-ack-queue", "testCommitAck", 3)
- assert contents == self.drain(txrcv)
- txssn.acknowledge()
- txssn.close()
+ def testCommit(self):
+ self.txTest(True)
+ def testRollback(self):
+ self.txTest(False)
+
+ def txTestSend(self, commit):
txssn = self.conn.session(transactional=True)
- txrcv = txssn.receiver("test-commit-ack-queue")
- assert contents == self.drain(txrcv)
- txssn.acknowledge()
- txssn.commit()
- rcv = self.ssn.receiver("test-commit-ack-queue")
- self.assertEmpty(rcv)
- txssn.close()
+ contents = self.send(txssn, "test-tx-send-queue", "txTestSend", 3)
+ rcv = self.ssn.receiver("test-tx-send-queue")
self.assertEmpty(rcv)
- def testRollbackAck(self):
+ if commit:
+ txssn.commit()
+ assert contents == self.drain(rcv)
+ self.ssn.acknowledge()
+ else:
+ txssn.rollback()
+ self.assertEmpty(rcv)
+ txssn.commit()
+ self.assertEmpty(rcv)
+
+ def testCommitSend(self):
+ self.txTestSend(True)
+
+ def testRollbackSend(self):
+ self.txTestSend(False)
+
+ def txTestAck(self, commit):
txssn = self.conn.session(transactional=True)
- txrcv = txssn.receiver("test-rollback-ack-queue")
+ txrcv = txssn.receiver("test-tx-ack-queue")
self.assertEmpty(txrcv)
- contents = self.send(self.ssn, "test-rollback-ack-queue", "testRollbackAck", 3)
- assert contents == self.drain(txrcv)
- txssn.rollback()
- assert contents == self.drain(txrcv)
- txssn.acknowledge()
- txssn.rollback()
+ contents = self.send(self.ssn, "test-tx-ack-queue", "txTestAck", 3)
assert contents == self.drain(txrcv)
- txssn.commit() # commit without ack
- self.assertEmpty(txrcv)
+
+ if commit:
+ txssn.acknowledge()
+ else:
+ txssn.rollback()
+ assert contents == self.drain(txrcv)
+ txssn.acknowledge()
+ txssn.rollback()
+ assert contents == self.drain(txrcv)
+ txssn.commit() # commit without ack
+ self.assertEmpty(txrcv)
+
txssn.close()
+
txssn = self.conn.session(transactional=True)
- txrcv = txssn.receiver("test-rollback-ack-queue")
+ txrcv = txssn.receiver("test-tx-ack-queue")
assert contents == self.drain(txrcv)
txssn.acknowledge()
txssn.commit()
- rcv = self.ssn.receiver("test-rollback-ack-queue")
+ rcv = self.ssn.receiver("test-tx-ack-queue")
self.assertEmpty(rcv)
txssn.close()
self.assertEmpty(rcv)
+ def testCommitAck(self):
+ self.txTestAck(True)
+
+ def testRollbackAck(self):
+ self.txTestAck(False)
+
def testClose(self):
self.ssn.close()
try: