You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rh...@apache.org on 2008/05/13 17:55:01 UTC
svn commit: r655927 - in /incubator/qpid/trunk/qpid/java:
client/src/test/java/org/apache/qpid/testutil/QpidTestCase.java
cpp.async.testprofile cpp.sync.testprofile cpp.testprofile
default.testprofile module.xml
Author: rhs
Date: Tue May 13 08:55:00 2008
New Revision: 655927
URL: http://svn.apache.org/viewvc?rev=655927&view=rev
Log:
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
Modified:
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/testutil/QpidTestCase.java
incubator/qpid/trunk/qpid/java/cpp.async.testprofile
incubator/qpid/trunk/qpid/java/cpp.sync.testprofile
incubator/qpid/trunk/qpid/java/cpp.testprofile
incubator/qpid/trunk/qpid/java/default.testprofile
incubator/qpid/trunk/qpid/java/module.xml
Modified: incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/testutil/QpidTestCase.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/testutil/QpidTestCase.java?rev=655927&r1=655926&r2=655927&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/testutil/QpidTestCase.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/testutil/QpidTestCase.java Tue May 13 08:55:00 2008
@@ -23,9 +23,10 @@
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 @@
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 @@
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 @@
// this seems to happen regularly even when
// exits are normal
}
+ finally
+ {
+ if (latch != null)
+ {
+ latch.countDown();
+ }
+ }
}
}
@@ -202,9 +238,11 @@
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
{
Modified: incubator/qpid/trunk/qpid/java/cpp.async.testprofile
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/cpp.async.testprofile?rev=655927&r1=655926&r2=655927&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/cpp.async.testprofile (original)
+++ incubator/qpid/trunk/qpid/java/cpp.async.testprofile Tue May 13 08:55:00 2008
@@ -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 @@
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
Modified: incubator/qpid/trunk/qpid/java/cpp.sync.testprofile
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/cpp.sync.testprofile?rev=655927&r1=655926&r2=655927&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/cpp.sync.testprofile (original)
+++ incubator/qpid/trunk/qpid/java/cpp.sync.testprofile Tue May 13 08:55:00 2008
@@ -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 @@
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
Modified: incubator/qpid/trunk/qpid/java/cpp.testprofile
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/cpp.testprofile?rev=655927&r1=655926&r2=655927&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/cpp.testprofile (original)
+++ incubator/qpid/trunk/qpid/java/cpp.testprofile Tue May 13 08:55:00 2008
@@ -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 @@
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
Modified: incubator/qpid/trunk/qpid/java/default.testprofile
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/default.testprofile?rev=655927&r1=655926&r2=655927&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/default.testprofile (original)
+++ incubator/qpid/trunk/qpid/java/default.testprofile Tue May 13 08:55:00 2008
@@ -12,7 +12,6 @@
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
Modified: incubator/qpid/trunk/qpid/java/module.xml
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/module.xml?rev=655927&r1=655926&r2=655927&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/module.xml (original)
+++ incubator/qpid/trunk/qpid/java/module.xml Tue May 13 08:55:00 2008
@@ -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}"/>