diff options
| author | Rafael H. Schloming <rhs@apache.org> | 2008-05-13 18:38:37 +0000 |
|---|---|---|
| committer | Rafael H. Schloming <rhs@apache.org> | 2008-05-13 18:38:37 +0000 |
| commit | 2579255f8844bf6b7a9dab39ec4a49c1eabbb07b (patch) | |
| tree | ba62ade97a8691a5a266f194fc00e1ed0a6b7cae /java/client/src/test | |
| parent | d5f4f49951f7a8818cfbde421ef31ec695eb1bdb (diff) | |
| download | qpid-python-2579255f8844bf6b7a9dab39ec4a49c1eabbb07b.tar.gz | |
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
Diffstat (limited to 'java/client/src/test')
| -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 { |
