From 2579255f8844bf6b7a9dab39ec4a49c1eabbb07b Mon Sep 17 00:00:00 2001 From: "Rafael H. Schloming" Date: Tue, 13 May 2008 18:38:37 +0000 Subject: QPID-1053: add a timeout in case the broker is never ready git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@655964 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/qpid/testutil/QpidTestCase.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'java/client/src/test') diff --git a/java/client/src/test/java/org/apache/qpid/testutil/QpidTestCase.java b/java/client/src/test/java/org/apache/qpid/testutil/QpidTestCase.java index 145b4da268..2efec309b2 100644 --- a/java/client/src/test/java/org/apache/qpid/testutil/QpidTestCase.java +++ b/java/client/src/test/java/org/apache/qpid/testutil/QpidTestCase.java @@ -27,6 +27,7 @@ import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; import org.apache.qpid.client.transport.TransportConnection; import org.apache.qpid.client.AMQConnection; @@ -187,11 +188,15 @@ public class QpidTestCase extends TestCase this(in, null); } - public void await() throws InterruptedException + public boolean await(long timeout, TimeUnit unit) throws InterruptedException { - if (latch != null) + if (latch == null) { - latch.await(); + return true; + } + else + { + return latch.await(timeout, unit); } } @@ -242,7 +247,13 @@ public class QpidTestCase extends TestCase System.getProperty(BROKER_READY)); p.start(); - p.await(); + + if (!p.await(30, TimeUnit.SECONDS)) + { + _logger.info("broker failed to become ready"); + cleanBroker(); + throw new RuntimeException("broker failed to become ready"); + } try { -- cgit v1.2.1