You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ta...@apache.org on 2015/10/14 00:30:57 UTC
qpid-jms git commit: QPIDJMS-125 Add a simpler test for TX Rollback
on session close.
Repository: qpid-jms
Updated Branches:
refs/heads/master 845f75db6 -> dce0b04cb
QPIDJMS-125 Add a simpler test for TX Rollback on session close.
Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/dce0b04c
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/dce0b04c
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/dce0b04c
Branch: refs/heads/master
Commit: dce0b04cbe61bbc55ae991325939b09c13af288d
Parents: 845f75d
Author: Timothy Bish <ta...@gmail.com>
Authored: Tue Oct 13 18:30:52 2015 -0400
Committer: Timothy Bish <ta...@gmail.com>
Committed: Tue Oct 13 18:30:52 2015 -0400
----------------------------------------------------------------------
.../TransactionsIntegrationTest.java | 35 ++++++++++++++++++++
1 file changed, 35 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/dce0b04c/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/TransactionsIntegrationTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/TransactionsIntegrationTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/TransactionsIntegrationTest.java
index 947700b..c844e1e 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/TransactionsIntegrationTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/TransactionsIntegrationTest.java
@@ -73,6 +73,41 @@ public class TransactionsIntegrationTest extends QpidJmsTestCase {
private final IntegrationTestFixture testFixture = new IntegrationTestFixture();
@Test(timeout=20000)
+ public void testTransactionRolledBackOnSessionClose() throws Exception {
+ try (TestAmqpPeer testPeer = new TestAmqpPeer();) {
+ Connection connection = testFixture.establishConnecton(testPeer);
+ connection.start();
+
+ testPeer.expectBegin();
+ CoordinatorMatcher txCoordinatorMatcher = new CoordinatorMatcher();
+ testPeer.expectSenderAttach(txCoordinatorMatcher, false, false);
+
+ // First expect an unsettled 'declare' transfer to the txn coordinator, and
+ // reply with a Declared disposition state containing the txnId.
+ Binary txnId = new Binary(new byte[]{ (byte) 5, (byte) 6, (byte) 7, (byte) 8});
+ TransferPayloadCompositeMatcher declareMatcher = new TransferPayloadCompositeMatcher();
+ declareMatcher.setMessageContentMatcher(new EncodedAmqpValueMatcher(new Declare()));
+ testPeer.expectTransfer(declareMatcher, nullValue(), false, new Declared().setTxnId(txnId), true);
+
+ // Expect an unsettled 'discharge' transfer to the txn coordinator containing the txnId,
+ // and reply with accepted and settled disposition to indicate the rollback succeeded.
+ Discharge discharge = new Discharge();
+ discharge.setFail(true);
+ discharge.setTxnId(txnId);
+ TransferPayloadCompositeMatcher dischargeMatcher = new TransferPayloadCompositeMatcher();
+ dischargeMatcher.setMessageContentMatcher(new EncodedAmqpValueMatcher(discharge));
+ testPeer.expectTransfer(dischargeMatcher, nullValue(), false, new Accepted(), true);
+ testPeer.expectEnd();
+
+ Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
+
+ session.close();
+
+ testPeer.waitForAllHandlersToComplete(1000);
+ }
+ }
+
+ @Test(timeout=20000)
public void testTransactionCommitFailWithEmptyRejectedDisposition() throws Exception {
try (TestAmqpPeer testPeer = new TestAmqpPeer();) {
Connection connection = testFixture.establishConnecton(testPeer);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org