diff options
-rw-r--r-- | java/client/src/test/java/org/apache/qpid/testutil/QpidTestCase.java | 19 |
1 files changed, 15 insertions, 4 deletions
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 { |