summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael H. Schloming <rhs@apache.org>2008-05-13 15:55:00 +0000
committerRafael H. Schloming <rhs@apache.org>2008-05-13 15:55:00 +0000
commit134fb24da17b023fba1a55d5d60e1ac0580f145e (patch)
tree2c83a3a812751d4ac005fe04a65f202b05ba1bb0
parente00d795537664f2aabe03bb0e764dadc73f00df3 (diff)
downloadqpid-python-134fb24da17b023fba1a55d5d60e1ac0580f145e.tar.gz
QPID-1053: updated QpidTestCase to check against broker output to ensure the broker is actually listening before the test attempts to connect; the text checked for is controlled by the broker.ready system property, appropriate values have been added to the cpp profiles
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@655927 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--java/client/src/test/java/org/apache/qpid/testutil/QpidTestCase.java56
-rw-r--r--java/cpp.async.testprofile4
-rw-r--r--java/cpp.sync.testprofile4
-rw-r--r--java/cpp.testprofile4
-rw-r--r--java/default.testprofile3
-rw-r--r--java/module.xml1
6 files changed, 55 insertions, 17 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 2f4a0e6b04..145b4da268 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
@@ -23,9 +23,10 @@ import junit.framework.TestResult;
import javax.jms.Connection;
import javax.naming.InitialContext;
import java.io.*;
-import java.util.List;
import java.util.ArrayList;
+import java.util.List;
import java.util.StringTokenizer;
+import java.util.concurrent.CountDownLatch;
import org.apache.qpid.client.transport.TransportConnection;
import org.apache.qpid.client.AMQConnection;
@@ -105,6 +106,7 @@ public class QpidTestCase extends TestCase
private static final String BROKER = "broker";
private static final String BROKER_CLEAN = "broker.clean";
private static final String BROKER_VERSION = "broker.version";
+ private static final String BROKER_READY = "broker.ready";
// values
private static final String VM = "vm";
@@ -162,22 +164,49 @@ public class QpidTestCase extends TestCase
private static final class Piper extends Thread
{
- private InputStream in;
+ private LineNumberReader in;
+ private String ready;
+ private CountDownLatch latch;
+
+ public Piper(InputStream in, String ready)
+ {
+ this.in = new LineNumberReader(new InputStreamReader(in));
+ this.ready = ready;
+ if (this.ready != null && !this.ready.equals(""))
+ {
+ this.latch = new CountDownLatch(1);
+ }
+ else
+ {
+ this.latch = null;
+ }
+ }
public Piper(InputStream in)
{
- this.in = in;
+ this(in, null);
+ }
+
+ public void await() throws InterruptedException
+ {
+ if (latch != null)
+ {
+ latch.await();
+ }
}
public void run()
{
try
{
- byte[] buf = new byte[4*1024];
- int n;
- while ((n = in.read(buf)) != -1)
+ String line;
+ while ((line = in.readLine()) != null)
{
- System.out.write(buf, 0, n);
+ System.out.println(line);
+ if (latch != null && line.contains(ready))
+ {
+ latch.countDown();
+ }
}
}
catch (IOException e)
@@ -185,6 +214,13 @@ public class QpidTestCase extends TestCase
// this seems to happen regularly even when
// exits are normal
}
+ finally
+ {
+ if (latch != null)
+ {
+ latch.countDown();
+ }
+ }
}
}
@@ -202,9 +238,11 @@ public class QpidTestCase extends TestCase
pb.redirectErrorStream(true);
_brokerProcess = pb.start();
- new Piper(_brokerProcess.getInputStream()).start();
+ Piper p = new Piper(_brokerProcess.getInputStream(),
+ System.getProperty(BROKER_READY));
- Thread.sleep(1000);
+ p.start();
+ p.await();
try
{
diff --git a/java/cpp.async.testprofile b/java/cpp.async.testprofile
index e7ab8f879e..cbdd6f7940 100644
--- a/java/cpp.async.testprofile
+++ b/java/cpp.async.testprofile
@@ -1,6 +1,7 @@
broker.version=0-10
broker=${project.root}/../cpp/src/qpidd --data-dir ${build.data} -t --load-module ${project.root}/../../cppStore/cpp/lib/.libs/libbdbstore.so --store-async yes --auth no
broker.clean=${project.root}/clean-dir ${build.data}
+broker.ready=Listening on TCP port
java.naming.provider.url=${project.root}/test-provider.properties
max_prefetch=1000
test.excludes=true
@@ -12,7 +13,6 @@ log4j.configuration=file://${project.root}/log4j-test.xml
test.fork=no
test.mem=512M
test=*Test
-test1=*Tests
haltonfailure=no
haltonerror=no
-exclude.modules=systests \ No newline at end of file
+exclude.modules=systests
diff --git a/java/cpp.sync.testprofile b/java/cpp.sync.testprofile
index f99a81954d..ef8b298b87 100644
--- a/java/cpp.sync.testprofile
+++ b/java/cpp.sync.testprofile
@@ -1,6 +1,7 @@
broker.version=0-10
broker=${project.root}/../cpp/src/qpidd --data-dir ${build.data} -t --load-module ${project.root}/../../cppStore/cpp/lib/.libs/libbdbstore.so --store-async no --auth no
broker.clean=${project.root}/clean-dir ${build.data}
+broker.ready=Listening on TCP port
java.naming.provider.url=${project.root}/test-provider.properties
test.excludes=true
max_prefetch=1000
@@ -12,7 +13,6 @@ log4j.configuration=file://${project.root}/log4j-test.xml
test.fork=no
test.mem=512M
test=*Test
-test1=*Tests
haltonfailure=no
haltonerror=no
-exclude.modules=systests \ No newline at end of file
+exclude.modules=systests
diff --git a/java/cpp.testprofile b/java/cpp.testprofile
index 8af64d59e3..7b90d26e5c 100644
--- a/java/cpp.testprofile
+++ b/java/cpp.testprofile
@@ -1,6 +1,7 @@
broker.version=0-10
broker=${project.root}/../cpp/src/qpidd --data-dir ${build.data} -t --auth no
broker.clean=${project.root}/clean-dir ${build.data}
+broker.ready=Listening on TCP port
java.naming.provider.url=${project.root}/test-provider.properties
max_prefetch=1000
test.excludes=true
@@ -12,7 +13,6 @@ log4j.configuration=file://${project.root}/log4j-test.xml
test.fork=no
test.mem=512M
test=*Test
-test1=*Tests
haltonfailure=no
haltonerror=no
-exclude.modules=systests \ No newline at end of file
+exclude.modules=systests
diff --git a/java/default.testprofile b/java/default.testprofile
index 4d3f961660..4f749b84a7 100644
--- a/java/default.testprofile
+++ b/java/default.testprofile
@@ -12,7 +12,6 @@ log4j.configuration=file:///${project.root}/log4j-test.xml
test.fork=no
test.mem=512M
test=*Test
-test1=*Tests
haltonfailure=no
haltonerror=no
-exclude.modules=none \ No newline at end of file
+exclude.modules=none
diff --git a/java/module.xml b/java/module.xml
index 2b5a798d58..44d2a8ee6c 100644
--- a/java/module.xml
+++ b/java/module.xml
@@ -207,6 +207,7 @@
<sysproperty key="broker" value="${broker}"/>
<sysproperty key="broker.clean" value="${broker.clean}"/>
<sysproperty key="broker.version" value="${broker.version}"/>
+ <sysproperty key="broker.ready" value="${broker.ready}" />
<sysproperty key="test.excludes" value="${test.excludes}"/>
<sysproperty key="test.excludesfile" value="${test.excludesfile}"/>
<sysproperty key="max_prefetch" value ="${max_prefetch}"/>