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/22 23:46:32 UTC
qpid-jms git commit: QPIDJMS-125 adds a rollback test for close with
no messages.
Repository: qpid-jms
Updated Branches:
refs/heads/master e05794a5e -> e2c147d66
QPIDJMS-125 adds a rollback test for close with no messages.
Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/e2c147d6
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/e2c147d6
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/e2c147d6
Branch: refs/heads/master
Commit: e2c147d669e13e37f1a644280d187949c86cc792
Parents: e05794a
Author: Timothy Bish <ta...@gmail.com>
Authored: Thu Oct 22 17:46:23 2015 -0400
Committer: Timothy Bish <ta...@gmail.com>
Committed: Thu Oct 22 17:46:23 2015 -0400
----------------------------------------------------------------------
.../TransactionsIntegrationTest.java | 43 ++++++++++++++++++++
1 file changed, 43 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/e2c147d6/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 7aeaedc..d880761 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
@@ -423,6 +423,49 @@ public class TransactionsIntegrationTest extends QpidJmsTestCase {
}
}
+ @Test(timeout = 20000)
+ public void testConsumerWithNoMessageCanCloseBeforeRollback() throws Exception {
+ try (TestAmqpPeer testPeer = new TestAmqpPeer();) {
+ Connection connection = testFixture.establishConnecton(testPeer);
+ connection.start();
+
+ testPeer.expectBegin();
+ testPeer.expectCoordinatorAttach();
+
+ // 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) 1, (byte) 2, (byte) 3, (byte) 4});
+ testPeer.expectDeclare(txnId);
+
+ Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
+ Queue queue = session.createQueue("myQueue");
+
+ testPeer.expectReceiverAttach();
+ testPeer.expectLinkFlow();
+ testPeer.expectLinkFlow(true, true, equalTo(UnsignedInteger.valueOf(JmsPrefetchPolicy.DEFAULT_QUEUE_PREFETCH)));
+ testPeer.expectLinkFlow(false, false, equalTo(UnsignedInteger.valueOf(JmsPrefetchPolicy.DEFAULT_QUEUE_PREFETCH)));
+ testPeer.expectDetach(true, true, true);
+
+ MessageConsumer messageConsumer = session.createConsumer(queue);
+ assertNull(messageConsumer.receiveNoWait());
+
+ messageConsumer.close();
+
+ // Expect an unsettled 'discharge' transfer to the txn coordinator containing the txnId,
+ // and reply with accepted and settled disposition to indicate the commit succeeded
+ testPeer.expectDischarge(txnId, true);
+
+ // Then expect an unsettled 'declare' transfer to the txn coordinator, and
+ // reply with a declared disposition state containing the txnId.
+ txnId = new Binary(new byte[]{ (byte) 1, (byte) 2, (byte) 3, (byte) 4});
+ testPeer.expectDeclare(txnId);
+
+ session.rollback();
+
+ testPeer.waitForAllHandlersToComplete(1000);
+ }
+ }
+
@Test(timeout=20000)
public void testProducedMessagesOnTransactedSessionCarryTxnId() throws Exception {
try (TestAmqpPeer testPeer = new TestAmqpPeer();) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org