summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael H. Schloming <rhs@apache.org>2008-05-13 18:38:37 +0000
committerRafael H. Schloming <rhs@apache.org>2008-05-13 18:38:37 +0000
commit0d104f77655da5670f86c79092b3259f1205a1a7 (patch)
tree60a7842d5361bbe5788386fc0fdb456889fa4b99
parentf4295ab286030329fd1cd70a1f1c02a4834c4040 (diff)
downloadqpid-python-0d104f77655da5670f86c79092b3259f1205a1a7.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@655964 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/java/client/src/test/java/org/apache/qpid/testutil/QpidTestCase.java19
1 files changed, 15 insertions, 4 deletions
diff --git a/qpid/java/client/src/test/java/org/apache/qpid/testutil/QpidTestCase.java b/qpid/java/client/src/test/java/org/apache/qpid/testutil/QpidTestCase.java
index 145b4da268..2efec309b2 100644
--- a/qpid/java/client/src/test/java/org/apache/qpid/testutil/QpidTestCase.java
+++ b/qpid/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
{