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 2016/04/05 23:44:05 UTC

qpid-jms git commit: NO-JIRA Add a test for receiveNoWait when connection not started.

Repository: qpid-jms
Updated Branches:
  refs/heads/master 98ba84240 -> c9535a2ac


NO-JIRA Add a test for receiveNoWait when connection not started. 

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

Branch: refs/heads/master
Commit: c9535a2acb0e627677c8c0609630d7cb88e298a2
Parents: 98ba842
Author: Timothy Bish <ta...@gmail.com>
Authored: Tue Apr 5 17:39:03 2016 -0400
Committer: Timothy Bish <ta...@gmail.com>
Committed: Tue Apr 5 17:39:03 2016 -0400

----------------------------------------------------------------------
 .../integration/ConsumerIntegrationTest.java    | 37 ++++++++++++++++++++
 1 file changed, 37 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/c9535a2a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/ConsumerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/ConsumerIntegrationTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/ConsumerIntegrationTest.java
index 4096efb..5dc4e37 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/ConsumerIntegrationTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/ConsumerIntegrationTest.java
@@ -507,6 +507,43 @@ public class ConsumerIntegrationTest extends QpidJmsTestCase {
         }
     }
 
+    @Test(timeout=20000)
+    public void testNoReceivedNoWaitMessagesWhenConnectionNotStarted() throws Exception {
+        try (TestAmqpPeer testPeer = new TestAmqpPeer();) {
+            final CountDownLatch incoming = new CountDownLatch(1);
+            Connection connection = testFixture.establishConnecton(testPeer);
+
+            // Allow wait for incoming message before we call receive.
+            ((JmsConnection) connection).addConnectionListener(new JmsDefaultConnectionListener() {
+
+                @Override
+                public void onInboundMessage(JmsInboundMessageDispatch envelope) {
+                    incoming.countDown();
+                }
+            });
+
+            testPeer.expectBegin();
+
+            Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+            Queue destination = session.createQueue(getTestName());
+
+            testPeer.expectReceiverAttach();
+            testPeer.expectLinkFlowRespondWithTransfer(null, null, null, null, new AmqpValueDescribedType("content"), 3);
+
+            MessageConsumer consumer = session.createConsumer(destination);
+
+            // Wait for a message to arrive then try and receive it, which should not happen
+            // since the connection is not started.
+            assertTrue(incoming.await(10, TimeUnit.SECONDS));
+            assertNull(consumer.receiveNoWait());
+
+            testPeer.expectClose();
+            connection.close();
+
+            testPeer.waitForAllHandlersToComplete(2000);
+        }
+    }
+
     @Test(timeout=60000)
     public void testSyncReceiveFailsWhenListenerSet() 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