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/09/01 21:19:21 UTC

qpid-jms git commit: QPIDJMS-51 QueueBrowser created now with settled sender mode. Tests updated to reflect this.

Repository: qpid-jms
Updated Branches:
  refs/heads/master 07bfb159e -> f15f812ea


QPIDJMS-51 QueueBrowser created now with settled sender mode.  Tests
updated to reflect this. 

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

Branch: refs/heads/master
Commit: f15f812ea18269dae5e165b603b0a7b8c9e8b5e7
Parents: 07bfb15
Author: Timothy Bish <ta...@gmail.com>
Authored: Tue Sep 1 15:19:13 2015 -0400
Committer: Timothy Bish <ta...@gmail.com>
Committed: Tue Sep 1 15:19:13 2015 -0400

----------------------------------------------------------------------
 .../qpid/jms/provider/amqp/AmqpConsumer.java    |  2 +-
 .../QueueBrowserIntegrationTest.java            | 49 ++++++------
 .../failover/FailoverIntegrationTest.java       |  4 +-
 .../qpid/jms/test/testpeer/TestAmqpPeer.java    | 78 +++++++++++++++-----
 4 files changed, 86 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/f15f812e/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConsumer.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConsumer.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConsumer.java
index 22a2932..2ffb94b 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConsumer.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConsumer.java
@@ -568,7 +568,7 @@ public class AmqpConsumer extends AmqpAbstractResource<JmsConsumerInfo, Receiver
     }
 
     public boolean isPresettle() {
-        return presettle;
+        return presettle || resource.isBrowser();
     }
 
     public void setPresettle(boolean presettle) {

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/f15f812e/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/QueueBrowserIntegrationTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/QueueBrowserIntegrationTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/QueueBrowserIntegrationTest.java
index a8589af..e179db2 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/QueueBrowserIntegrationTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/QueueBrowserIntegrationTest.java
@@ -39,12 +39,12 @@ import org.apache.qpid.jms.test.testpeer.describedtypes.Declare;
 import org.apache.qpid.jms.test.testpeer.describedtypes.Declared;
 import org.apache.qpid.jms.test.testpeer.describedtypes.sections.AmqpValueDescribedType;
 import org.apache.qpid.jms.test.testpeer.matchers.CoordinatorMatcher;
-import org.apache.qpid.jms.test.testpeer.matchers.ModifiedMatcher;
 import org.apache.qpid.jms.test.testpeer.matchers.sections.TransferPayloadCompositeMatcher;
 import org.apache.qpid.jms.test.testpeer.matchers.types.EncodedAmqpValueMatcher;
 import org.apache.qpid.proton.amqp.Binary;
 import org.apache.qpid.proton.amqp.DescribedType;
 import org.apache.qpid.proton.amqp.UnsignedInteger;
+import org.hamcrest.Matchers;
 import org.junit.Test;
 
 public class QueueBrowserIntegrationTest extends QpidJmsTestCase {
@@ -87,7 +87,7 @@ public class QueueBrowserIntegrationTest extends QpidJmsTestCase {
             Queue queue = session.createQueue("myQueue");
 
             // Expected the browser to create a consumer and send credit.
-            testPeer.expectReceiverAttach();
+            testPeer.expectQueueBrowserAttach();
             testPeer.expectLinkFlow();
             testPeer.expectDetach(true, true, true);
 
@@ -115,7 +115,7 @@ public class QueueBrowserIntegrationTest extends QpidJmsTestCase {
             Queue queue = session.createQueue("myQueue");
 
             // Expected the browser to create a consumer and send credit.
-            testPeer.expectReceiverAttach();
+            testPeer.expectQueueBrowserAttach();
             testPeer.expectLinkFlow();
             testPeer.expectLinkFlow(true, true, equalTo(UnsignedInteger.valueOf(1)));
             testPeer.expectDetach(true, true, true);
@@ -148,12 +148,10 @@ public class QueueBrowserIntegrationTest extends QpidJmsTestCase {
             Queue queue = session.createQueue("myQueue");
 
             // Expected the browser to create a consumer and send credit.
-            testPeer.expectReceiverAttach();
-
-            testPeer.expectLinkFlow();
-            testPeer.sendTransferToLastOpenedLinkOnLastOpenedSession(null, null, null, null, amqpValueNullContent, 1);
+            testPeer.expectQueueBrowserAttach();
+            testPeer.expectLinkFlowRespondWithTransfer(null, null, null, null, amqpValueNullContent,
+                1, false, false, Matchers.equalTo(UnsignedInteger.ONE), 1, true, false);
             testPeer.expectLinkFlow();
-            testPeer.expectDispositionThatIsAcceptedAndSettled();
             testPeer.expectDetach(true, true, true);
 
             QueueBrowser browser = session.createBrowser(queue);
@@ -187,9 +185,9 @@ public class QueueBrowserIntegrationTest extends QpidJmsTestCase {
             // Expected the browser to create a consumer and send credit, once hasMoreElements
             // is called a message that is received should be accepted when the session is in
             // Auto acknowledge mode.
-            testPeer.expectReceiverAttach();
-            testPeer.expectLinkFlowRespondWithTransfer(null, null, null, null, amqpValueNullContent);
-            testPeer.expectDispositionThatIsAcceptedAndSettled();
+            testPeer.expectQueueBrowserAttach();
+            testPeer.expectLinkFlowRespondWithTransfer(null, null, null, null, amqpValueNullContent,
+                1, false, false, Matchers.greaterThan(UnsignedInteger.ZERO), 1, true, false);
             testPeer.expectDetach(true, true, true);
 
             QueueBrowser browser = session.createBrowser(queue);
@@ -218,8 +216,9 @@ public class QueueBrowserIntegrationTest extends QpidJmsTestCase {
 
             DescribedType amqpValueNullContent = new AmqpValueDescribedType(null);
 
-            testPeer.expectReceiverAttach();
-            testPeer.expectLinkFlowRespondWithTransfer(null, null, null, null, amqpValueNullContent);
+            testPeer.expectQueueBrowserAttach();
+            testPeer.expectLinkFlowRespondWithTransfer(null, null, null, null, amqpValueNullContent,
+                1, false, false, Matchers.greaterThan(UnsignedInteger.ZERO), 1, true, false);
 
             // First expect an unsettled 'declare' transfer to the txn coordinator, and
             // reply with a declared disposition state containing the txnId.
@@ -229,9 +228,8 @@ public class QueueBrowserIntegrationTest extends QpidJmsTestCase {
             testPeer.expectTransfer(declareMatcher, nullValue(), false, new Declared().setTxnId(txnId), true);
 
             // Expected the browser to create a consumer and send credit, once hasMoreElements
-            // is called a message that is received should be accepted when the session is in
-            // a transacted session, the browser should not participate.
-            testPeer.expectDispositionThatIsAcceptedAndSettled();
+            // is called a message that is received should be delivered when the session is in
+            // a transacted session, the browser should not participate and close when asked.
             testPeer.expectDetach(true, true, true);
 
             QueueBrowser browser = session.createBrowser(queue);
@@ -262,11 +260,10 @@ public class QueueBrowserIntegrationTest extends QpidJmsTestCase {
             // Expected the browser to create a consumer and send credit, once hasMoreElements
             // is called a message that is received should be accepted when the session is in
             // Auto acknowledge mode.
-            testPeer.expectReceiverAttach();
-            testPeer.expectLinkFlowRespondWithTransfer(null, null, null, null, amqpValueNullContent);
+            testPeer.expectQueueBrowserAttach();
+            testPeer.expectLinkFlowRespondWithTransfer(null, null, null, null, amqpValueNullContent,
+                1, false, false, Matchers.greaterThan(UnsignedInteger.ZERO), 1, true, false);
             testPeer.expectDetach(true, true, true);
-            //TODO: even though it is a copy, perhaps we should use released (or pre-settled transfers) for browsers?
-            testPeer.expectDisposition(true, new ModifiedMatcher());
 
             QueueBrowser browser = session.createBrowser(queue);
             Enumeration<?> queueView = browser.getEnumeration();
@@ -299,7 +296,7 @@ public class QueueBrowserIntegrationTest extends QpidJmsTestCase {
             Queue queue = session.createQueue("myQueue");
 
             // Expected the browser to create a consumer and send credit.
-            testPeer.expectReceiverAttach();
+            testPeer.expectQueueBrowserAttach();
             testPeer.expectDetach(true, true, true);
 
             QueueBrowser browser = session.createBrowser(queue);
@@ -327,7 +324,7 @@ public class QueueBrowserIntegrationTest extends QpidJmsTestCase {
             Queue queue = session.createQueue("myQueue");
 
             // Expected the browser to create a consumer and send credit.
-            testPeer.expectReceiverAttach();
+            testPeer.expectQueueBrowserAttach();
             testPeer.expectLinkFlow(false, false, equalTo(UnsignedInteger.valueOf(1)));
             testPeer.expectLinkFlow(true, true, equalTo(UnsignedInteger.valueOf(1)));
             testPeer.expectDetach(true, true, true);
@@ -360,16 +357,14 @@ public class QueueBrowserIntegrationTest extends QpidJmsTestCase {
             Queue queue = session.createQueue("myQueue");
 
             // Expected the browser to create a consumer and send credit.
-            testPeer.expectReceiverAttach();
+            testPeer.expectQueueBrowserAttach();
             testPeer.expectLinkFlow(false, false, equalTo(UnsignedInteger.valueOf(1)));
 
             // After timeout the browser should drain and here we want to ensure that if a
             // message arrives that we handle it correctly.
             testPeer.expectLinkFlowRespondWithTransfer(
-                null, null, null, null, amqpValueNullContent, 1, true, false, equalTo(UnsignedInteger.valueOf(1)), 1, false);
-
-            // Message gets ack'd right away
-            testPeer.expectDispositionThatIsAcceptedAndSettled();
+                null, null, null, null, amqpValueNullContent, 1, true,
+                false, equalTo(UnsignedInteger.valueOf(1)), 1, true, false);
 
             // Next attempt should not get a message and trigger a false on hasMoreElemets.
             testPeer.expectLinkFlow(false, false, equalTo(UnsignedInteger.valueOf(1)));

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/f15f812e/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/failover/FailoverIntegrationTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/failover/FailoverIntegrationTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/failover/FailoverIntegrationTest.java
index 3ff9ce2..57daed2 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/failover/FailoverIntegrationTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/failover/FailoverIntegrationTest.java
@@ -488,7 +488,7 @@ public class FailoverIntegrationTest extends QpidJmsTestCase {
 
             // Create session+producer, send a persistent message on auto-ack session for synchronous send
             originalPeer.expectBegin();
-            originalPeer.expectReceiverAttach();
+            originalPeer.expectQueueBrowserAttach();
             originalPeer.expectLinkFlow();
             originalPeer.expectLinkFlowThenDrop();
 
@@ -498,7 +498,7 @@ public class FailoverIntegrationTest extends QpidJmsTestCase {
             finalPeer.expectSaslAnonymousConnect();
             finalPeer.expectBegin();
             finalPeer.expectBegin();
-            finalPeer.expectReceiverAttach();
+            finalPeer.expectQueueBrowserAttach();
             finalPeer.expectLinkFlow();
             finalPeer.expectLinkFlow(true, true, equalTo(UnsignedInteger.valueOf(1)));
             finalPeer.expectDetach(true, true, true);

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/f15f812e/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java
index e86591c..71b208a 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java
@@ -937,30 +937,50 @@ public class TestAmqpPeer implements AutoCloseable
         addHandler(attachMatcher);
     }
 
+    public void expectQueueBrowserAttach()
+    {
+        expectReceiverAttach(notNullValue(), notNullValue(), true);
+    }
+
+    public void expectReceiverAttach()
+    {
+        expectReceiverAttach(notNullValue(), notNullValue());
+    }
+
     public void expectReceiverAttach(final Matcher<?> linkNameMatcher, final Matcher<?> sourceMatcher)
     {
-        expectReceiverAttach(linkNameMatcher, sourceMatcher, false, false, null, null);
+        expectReceiverAttach(linkNameMatcher, sourceMatcher, false, false, false, null, null);
+    }
+
+    public void expectReceiverAttach(final Matcher<?> linkNameMatcher, final Matcher<?> sourceMatcher, final boolean settled)
+    {
+        expectReceiverAttach(linkNameMatcher, sourceMatcher, settled, false, false, null, null);
     }
 
     public void expectReceiverAttach(final Matcher<?> linkNameMatcher, final Matcher<?> sourceMatcher, final boolean refuseLink, boolean deferAttachResponseWrite)
     {
-        expectReceiverAttach(linkNameMatcher, sourceMatcher, refuseLink, deferAttachResponseWrite, null, null);
+        expectReceiverAttach(linkNameMatcher, sourceMatcher, false, refuseLink, deferAttachResponseWrite, null, null);
     }
 
-    public void expectReceiverAttach(final Matcher<?> linkNameMatcher, final Matcher<?> sourceMatcher, final boolean refuseLink, boolean deferAttachResponseWrite, Symbol errorType, String errorMessage)
+    public void expectReceiverAttach(final Matcher<?> linkNameMatcher, final Matcher<?> sourceMatcher, final boolean settled, final boolean refuseLink, boolean deferAttachResponseWrite)
+    {
+        expectReceiverAttach(linkNameMatcher, sourceMatcher, settled, refuseLink, deferAttachResponseWrite, null, null);
+    }
+
+    public void expectReceiverAttach(final Matcher<?> linkNameMatcher, final Matcher<?> sourceMatcher, final boolean settled, final boolean refuseLink, boolean deferAttachResponseWrite, Symbol errorType, String errorMessage)
     {
         final AttachMatcher attachMatcher = new AttachMatcher()
                 .withName(linkNameMatcher)
                 .withHandle(notNullValue())
                 .withRole(equalTo(Role.RECEIVER))
-                .withSndSettleMode(equalTo(SenderSettleMode.UNSETTLED))
+                .withSndSettleMode(equalTo(settled ? SenderSettleMode.SETTLED : SenderSettleMode.UNSETTLED))
                 .withRcvSettleMode(equalTo(ReceiverSettleMode.FIRST))
                 .withSource(sourceMatcher)
                 .withTarget(notNullValue());
 
         final AttachFrame attachResponse = new AttachFrame()
                             .setRole(Role.SENDER)
-                            .setSndSettleMode(SenderSettleMode.UNSETTLED)
+                            .setSndSettleMode(settled ? SenderSettleMode.SETTLED : SenderSettleMode.UNSETTLED)
                             .setRcvSettleMode(ReceiverSettleMode.FIRST)
                             .setInitialDeliveryCount(UnsignedInteger.ZERO);
 
@@ -1030,11 +1050,6 @@ public class TestAmqpPeer implements AutoCloseable
         addHandler(attachMatcher);
     }
 
-    public void expectReceiverAttach()
-    {
-        expectReceiverAttach(notNullValue(), notNullValue());
-    }
-
     public void expectDurableSubscriberAttach(String topicName, String subscriptionName)
     {
         SourceMatcher sourceMatcher = new SourceMatcher();
@@ -1103,14 +1118,14 @@ public class TestAmqpPeer implements AutoCloseable
 
     public void expectLinkFlow(boolean drain, boolean sendDrainFlowResponse, Matcher<UnsignedInteger> creditMatcher)
     {
-        expectLinkFlowRespondWithTransfer(null, null, null, null, null, 0, drain, sendDrainFlowResponse, creditMatcher, null, false);
+        expectLinkFlowRespondWithTransfer(null, null, null, null, null, 0, drain, sendDrainFlowResponse, creditMatcher, null, false, false);
     }
 
     public void expectLinkFlowRespondWithTransfer(final HeaderDescribedType headerDescribedType,
-                                                 final MessageAnnotationsDescribedType messageAnnotationsDescribedType,
-                                                 final PropertiesDescribedType propertiesDescribedType,
-                                                 final ApplicationPropertiesDescribedType appPropertiesDescribedType,
-                                                 final DescribedType content)
+                                                  final MessageAnnotationsDescribedType messageAnnotationsDescribedType,
+                                                  final PropertiesDescribedType propertiesDescribedType,
+                                                  final ApplicationPropertiesDescribedType appPropertiesDescribedType,
+                                                  final DescribedType content)
     {
         expectLinkFlowRespondWithTransfer(headerDescribedType, messageAnnotationsDescribedType, propertiesDescribedType,
                                           appPropertiesDescribedType, content, 1);
@@ -1125,7 +1140,24 @@ public class TestAmqpPeer implements AutoCloseable
     {
         expectLinkFlowRespondWithTransfer(headerDescribedType, messageAnnotationsDescribedType, propertiesDescribedType,
                                           appPropertiesDescribedType, content, count, false, false,
-                                          Matchers.greaterThanOrEqualTo(UnsignedInteger.valueOf(count)), 1, false);
+                                          Matchers.greaterThanOrEqualTo(UnsignedInteger.valueOf(count)), 1, false, false);
+    }
+
+    public void expectLinkFlowRespondWithTransfer(final HeaderDescribedType headerDescribedType,
+                                                  final MessageAnnotationsDescribedType messageAnnotationsDescribedType,
+                                                  final PropertiesDescribedType propertiesDescribedType,
+                                                  ApplicationPropertiesDescribedType appPropertiesDescribedType,
+                                                  final DescribedType content,
+                                                  final int count,
+                                                  final boolean drain,
+                                                  final boolean sendDrainFlowResponse,
+                                                  Matcher<UnsignedInteger> creditMatcher,
+                                                  final Integer nextIncomingId,
+                                                  boolean addMessageNumberProperty)
+    {
+        expectLinkFlowRespondWithTransfer(headerDescribedType, messageAnnotationsDescribedType, propertiesDescribedType,
+                                          appPropertiesDescribedType, content, count, drain, sendDrainFlowResponse,
+                                          creditMatcher, nextIncomingId, false, addMessageNumberProperty);
     }
 
     public void expectLinkFlowRespondWithTransfer(final HeaderDescribedType headerDescribedType,
@@ -1138,6 +1170,7 @@ public class TestAmqpPeer implements AutoCloseable
             final boolean sendDrainFlowResponse,
             Matcher<UnsignedInteger> creditMatcher,
             final Integer nextIncomingId,
+            final boolean sendSettled,
             boolean addMessageNumberProperty)
     {
         if (nextIncomingId == null && count > 0)
@@ -1192,7 +1225,7 @@ public class TestAmqpPeer implements AutoCloseable
             .setDeliveryId(UnsignedInteger.valueOf(nextId))
             .setDeliveryTag(dtag)
             .setMessageFormat(UnsignedInteger.ZERO)
-            .setSettled(false);
+            .setSettled(sendSettled);
 
             Binary payload = prepareTransferPayload(headerDescribedType, messageAnnotationsDescribedType,
                     propertiesDescribedType, appPropertiesDescribedType, content);
@@ -1561,6 +1594,17 @@ public class TestAmqpPeer implements AutoCloseable
                                                                 final ApplicationPropertiesDescribedType appPropertiesDescribedType,
                                                                 final DescribedType content,
                                                                 final int nextIncomingDeliveryId) {
+
+        sendTransferToLastOpenedLinkOnLastOpenedSession(headerDescribedType, messageAnnotationsDescribedType, propertiesDescribedType, appPropertiesDescribedType, content, nextIncomingDeliveryId, false);
+    }
+
+    public void sendTransferToLastOpenedLinkOnLastOpenedSession(final HeaderDescribedType headerDescribedType,
+                                                                final MessageAnnotationsDescribedType messageAnnotationsDescribedType,
+                                                                final PropertiesDescribedType propertiesDescribedType,
+                                                                final ApplicationPropertiesDescribedType appPropertiesDescribedType,
+                                                                final DescribedType content,
+                                                                final int nextIncomingDeliveryId,
+                                                                final boolean settled) {
         synchronized (_handlersLock) {
             CompositeAmqpPeerRunnable comp = insertCompsiteActionForLastHandler();
 


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