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 <[email protected]> Authored: Tue Apr 5 17:39:03 2016 -0400 Committer: Timothy Bish <[email protected]> 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: [email protected] For additional commands, e-mail: [email protected]
