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/23 00:29:43 UTC

qpid-jms git commit: QPIDJMS-125 Adds a couple more tests for consumer closed during TX for the commit and rollback cases.

Repository: qpid-jms
Updated Branches:
  refs/heads/master e2c147d66 -> cadf9c33a


QPIDJMS-125 Adds a couple more tests for consumer closed during TX for
the commit and rollback cases.  

Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/cadf9c33
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/cadf9c33
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/cadf9c33

Branch: refs/heads/master
Commit: cadf9c33a5765030ea0c2f5f62e23a75b5a4a963
Parents: e2c147d
Author: Timothy Bish <ta...@gmail.com>
Authored: Thu Oct 22 18:29:35 2015 -0400
Committer: Timothy Bish <ta...@gmail.com>
Committed: Thu Oct 22 18:29:35 2015 -0400

----------------------------------------------------------------------
 .../TransactionsIntegrationTest.java            | 38 +++++++++++++++-----
 1 file changed, 30 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/cadf9c33/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 d880761..e2d62b6 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
@@ -313,13 +313,18 @@ public class TransactionsIntegrationTest extends QpidJmsTestCase {
     }
 
     @Test(timeout=20000)
+    public void testCommitTransactedSessionWithConsumerReceivingAllMessagesAndClose() throws Exception {
+        doCommitTransactedSessionWithConsumerTestImpl(1, 1, true);
+    }
+
+    @Test(timeout=20000)
     public void testCommitTransactedSessionWithConsumerReceivingSomeMessages() throws Exception {
         doCommitTransactedSessionWithConsumerTestImpl(5, 2, false);
     }
 
     @Test(timeout=20000)
-    public void testCommitTransactedSessionWithConsumerReceivingAllMessagesAndClose() throws Exception {
-        doCommitTransactedSessionWithConsumerTestImpl(1, 1, true);
+    public void testCommitTransactedSessionWithConsumerReceivingSomeMessagesAndCloses() throws Exception {
+        doCommitTransactedSessionWithConsumerTestImpl(5, 2, true);
     }
 
     private void doCommitTransactedSessionWithConsumerTestImpl(int transferCount, int consumeCount, boolean closeConsumer) throws Exception {
@@ -366,6 +371,13 @@ public class TransactionsIntegrationTest extends QpidJmsTestCase {
             // Expect the consumer to close now
             if (closeConsumer) {
                 testPeer.expectDetach(true, true, true);
+
+                // Expect the messages that were not consumed to be released
+                int unconsumed = transferCount - consumeCount;
+                for (int i = 1; i <= unconsumed; i++) {
+                    testPeer.expectDispositionThatIsReleasedAndSettled();
+                }
+
                 messageConsumer.close();
             }
 
@@ -525,6 +537,11 @@ public class TransactionsIntegrationTest extends QpidJmsTestCase {
         doRollbackTransactedSessionWithConsumerTestImpl(5, 2, false);
     }
 
+    @Test(timeout=20000)
+    public void testRollbackTransactedSessionWithConsumerReceivingSomeMessagesThenCloses() throws Exception {
+        doRollbackTransactedSessionWithConsumerTestImpl(5, 2, true);
+    }
+
     private void doRollbackTransactedSessionWithConsumerTestImpl(int transferCount, int consumeCount, boolean closeConsumer) throws Exception {
         try (TestAmqpPeer testPeer = new TestAmqpPeer();) {
             Connection connection = testFixture.establishConnecton(testPeer);
@@ -571,6 +588,11 @@ public class TransactionsIntegrationTest extends QpidJmsTestCase {
 
             if (closeConsumer) {
                 testPeer.expectDetach(true, true, true);
+                int unconsumed = transferCount - consumeCount;
+                for (int i = 1; i <= unconsumed; i++) {
+                    testPeer.expectDisposition(true, new ReleasedMatcher());
+                }
+
                 messageConsumer.close();
             }
 
@@ -579,13 +601,13 @@ public class TransactionsIntegrationTest extends QpidJmsTestCase {
             txnId = new Binary(new byte[]{ (byte) 5, (byte) 6, (byte) 7, (byte) 8});
             testPeer.expectDeclare(txnId);
 
-            // Expect the messages that were not consumed to be released
-            int unconsumed = transferCount - consumeCount;
-            for (int i = 1; i <= unconsumed; i++) {
-                testPeer.expectDisposition(true, new ReleasedMatcher());
-            }
-
             if (!closeConsumer) {
+                // Expect the messages that were not consumed to be released
+                int unconsumed = transferCount - consumeCount;
+                for (int i = 1; i <= unconsumed; i++) {
+                    testPeer.expectDisposition(true, new ReleasedMatcher());
+                }
+
                 // Expect the consumer to be 'started' again as rollback completes
                 testPeer.expectLinkFlow(false, false, greaterThan(UnsignedInteger.ZERO));
             }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org