Repository: qpid-jms Updated Branches: refs/heads/master 9f0b49efc -> 147199924
NO-JIRA: update test to avoid sporadic failure and simplify slightly Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/1a4d2d3d Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/1a4d2d3d Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/1a4d2d3d Branch: refs/heads/master Commit: 1a4d2d3db54c323bd67c272f4fcf078bf358a32f Parents: 9f0b49e Author: Robert Gemmell <[email protected]> Authored: Tue Sep 29 14:55:13 2015 +0100 Committer: Robert Gemmell <[email protected]> Committed: Tue Sep 29 14:55:13 2015 +0100 ---------------------------------------------------------------------- .../jms/integration/ConsumerIntegrationTest.java | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/1a4d2d3d/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 254542e..6d91096 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 @@ -367,9 +367,9 @@ public class ConsumerIntegrationTest extends QpidJmsTestCase { @Test(timeout=20000) public void testSetMessageListenerAfterStartAndSend() throws Exception { - final AtomicInteger counter = new AtomicInteger(0); - final CountDownLatch done = new CountDownLatch(1); + final int messageCount = 4; + final CountDownLatch latch = new CountDownLatch(messageCount); try (TestAmqpPeer testPeer = new TestAmqpPeer();) { Connection connection = testFixture.establishConnecton(testPeer); connection.start(); @@ -380,7 +380,6 @@ public class ConsumerIntegrationTest extends QpidJmsTestCase { Queue destination = session.createQueue(getTestName()); connection.start(); - final int messageCount = 4; testPeer.expectReceiverAttach(); testPeer.expectLinkFlowRespondWithTransfer(null, null, null, null, new AmqpValueDescribedType("content"), messageCount); @@ -390,22 +389,20 @@ public class ConsumerIntegrationTest extends QpidJmsTestCase { testPeer.expectDisposition(true, new AcceptedMatcher()); } - testPeer.expectDetach(true, true, true); - consumer.setMessageListener(new MessageListener() { @Override public void onMessage(Message m) { LOG.debug("Async consumer got Message: {}", m); - counter.incrementAndGet(); - if (counter.get() == messageCount) { - done.countDown(); - } + latch.countDown(); } }); - assertTrue(done.await(1000, TimeUnit.MILLISECONDS)); - assertEquals(messageCount, counter.get()); + boolean await = latch.await(3000, TimeUnit.MILLISECONDS); + assertTrue("Messages not received within given timeout. Count remaining: " + latch.getCount(), await); + testPeer.waitForAllHandlersToComplete(2000); + + testPeer.expectDetach(true, true, true); consumer.close(); testPeer.waitForAllHandlersToComplete(2000); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
