Return-Path: X-Original-To: apmail-activemq-commits-archive@www.apache.org Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 645C111827 for ; Mon, 18 Aug 2014 23:44:59 +0000 (UTC) Received: (qmail 19447 invoked by uid 500); 18 Aug 2014 23:44:59 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 19401 invoked by uid 500); 18 Aug 2014 23:44:59 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 19380 invoked by uid 99); 18 Aug 2014 23:44:59 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 Aug 2014 23:44:59 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 11E3A9C6A00; Mon, 18 Aug 2014 23:44:59 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: tabish@apache.org To: commits@activemq.apache.org Message-Id: <92cb5ad39d774345b8c7920fa0331efd@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: Make the test more tolerant of slow machines by replacing fixed length sleep with a Wait condition. Date: Mon, 18 Aug 2014 23:44:59 +0000 (UTC) Repository: activemq Updated Branches: refs/heads/trunk aae7aeaf3 -> 858ab4020 Make the test more tolerant of slow machines by replacing fixed length sleep with a Wait condition. Project: http://git-wip-us.apache.org/repos/asf/activemq/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/858ab402 Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/858ab402 Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/858ab402 Branch: refs/heads/trunk Commit: 858ab40203e51054bcb5814a29d8e36b1ad7937b Parents: aae7aea Author: Timothy Bish Authored: Mon Aug 18 19:44:50 2014 -0400 Committer: Timothy Bish Committed: Mon Aug 18 19:44:50 2014 -0400 ---------------------------------------------------------------------- .../org/apache/activemq/bugs/AMQ4368Test.java | 27 +++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq/blob/858ab402/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4368Test.java ---------------------------------------------------------------------- diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4368Test.java b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4368Test.java index 4978a9f..13e1cfb 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4368Test.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4368Test.java @@ -37,6 +37,7 @@ import org.apache.activemq.broker.region.policy.PolicyEntry; import org.apache.activemq.broker.region.policy.PolicyMap; import org.apache.activemq.command.ActiveMQQueue; import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter; +import org.apache.activemq.util.Wait; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -202,15 +203,17 @@ public class AMQ4368Test { } @Test - public void testENTMQ220() throws InterruptedException, JMSException { + public void testENTMQ220() throws Exception { LOG.info("Start test."); CountDownLatch producer1Started = new CountDownLatch(1); CountDownLatch producer2Started = new CountDownLatch(1); CountDownLatch listener1Started = new CountDownLatch(1); - ProducingClient producer1 = new ProducingClient("1", producer1Started); - ProducingClient producer2 = new ProducingClient("2", producer2Started); - ConsumingClient listener1 = new ConsumingClient("subscriber-1", listener1Started); + final ProducingClient producer1 = new ProducingClient("1", producer1Started); + final ProducingClient producer2 = new ProducingClient("2", producer2Started); + final ConsumingClient listener1 = new ConsumingClient("subscriber-1", listener1Started); + final AtomicLong lastSize = new AtomicLong(); + try { producer1.start(); @@ -221,13 +224,19 @@ public class AMQ4368Test { producer2Started.await(15, TimeUnit.SECONDS); listener1Started.await(15, TimeUnit.SECONDS); - long lastSize = listener1.size.get(); + lastSize.set(listener1.size.get()); for (int i = 0; i < 10; i++) { - Thread.sleep(2000); + Wait.waitFor(new Wait.Condition() { + + @Override + public boolean isSatisified() throws Exception { + return listener1.size.get() > lastSize.get(); + } + }); long size = listener1.size.get(); - LOG.info("Listener 1: consumed: " + (size - lastSize)); - assertTrue("No messages received on iteration: " + i, size > lastSize); - lastSize = size; + LOG.info("Listener 1: consumed: " + (size - lastSize.get())); + assertTrue("No messages received on iteration: " + i, size > lastSize.get()); + lastSize.set(size); } } finally { LOG.info("Stopping clients");