You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2014/08/19 01:44:59 UTC
git commit: Make the test more tolerant of slow machines by replacing
fixed length sleep with a Wait condition.
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 <ta...@gmail.com>
Authored: Mon Aug 18 19:44:50 2014 -0400
Committer: Timothy Bish <ta...@gmail.com>
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");