summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authorRafael H. Schloming <rhs@apache.org>2008-02-21 20:51:11 +0000
committerRafael H. Schloming <rhs@apache.org>2008-02-21 20:51:11 +0000
commit07474f46b3315717e96a654513735ff6f5b1d664 (patch)
tree70dedada799d6f3ecbfaf4810dbbcca28da692f4 /java
parent3767d7e49e80c268c60ee247b3526b986eb7fc17 (diff)
downloadqpid-python-07474f46b3315717e96a654513735ff6f5b1d664.tar.gz
modified test harness to clean up data dir when broker crashes
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@629986 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java')
-rwxr-xr-xjava/clean-dir3
-rw-r--r--java/client/src/test/java/org/apache/qpid/testutil/QpidTestCase.java84
-rw-r--r--java/module.xml18
3 files changed, 76 insertions, 29 deletions
diff --git a/java/clean-dir b/java/clean-dir
new file mode 100755
index 0000000000..52800c5151
--- /dev/null
+++ b/java/clean-dir
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+rm -rf $@; mkdir $@
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 084137b38e..60b1b70d67 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
@@ -43,6 +43,7 @@ public class QpidTestCase extends TestCase
// system properties
private static final String BROKER = "broker";
+ private static final String BROKER_CLEAN = "broker.clean";
private static final String BROKER_VERSION = "broker.version";
// values
@@ -52,6 +53,7 @@ public class QpidTestCase extends TestCase
private static final String VERSION_010 = "0-10";
private String _broker = System.getProperty(BROKER, VM);
+ private String _brokerClean = System.getProperty(BROKER_CLEAN, null);
private String _brokerVersion = System.getProperty(BROKER_VERSION, VERSION_08);
private Process _brokerProcess;
@@ -82,6 +84,35 @@ public class QpidTestCase extends TestCase
}
}
+ private static final class Piper extends Thread
+ {
+
+ private InputStream in;
+
+ public Piper(InputStream in)
+ {
+ this.in = in;
+ }
+
+ public void run()
+ {
+ try
+ {
+ byte[] buf = new byte[4*1024];
+ int n;
+ while ((n = in.read(buf)) != -1)
+ {
+ System.out.write(buf, 0, n);
+ }
+ }
+ catch (IOException e)
+ {
+ // this seems to happen regularly even when
+ // exits are normal
+ }
+ }
+ }
+
public void startBroker() throws Exception
{
if (_broker.equals(VM))
@@ -96,34 +127,15 @@ public class QpidTestCase extends TestCase
pb.redirectErrorStream(true);
_brokerProcess = pb.start();
- new Thread()
- {
- private InputStream in = _brokerProcess.getInputStream();
-
- public void run()
- {
- try
- {
- byte[] buf = new byte[4*1024];
- int n;
- while ((n = in.read(buf)) != -1)
- {
- System.out.write(buf, 0, n);
- }
- }
- catch (IOException e)
- {
- // this seems to happen regularly even when
- // exits are normal
- }
- }
- }.start();
+ new Piper(_brokerProcess.getInputStream()).start();
Thread.sleep(1000);
try
{
int exit = _brokerProcess.exitValue();
+ _logger.info("broker aborted: " + exit);
+ cleanBroker();
throw new RuntimeException("broker aborted: " + exit);
}
catch (IllegalThreadStateException e)
@@ -133,6 +145,34 @@ public class QpidTestCase extends TestCase
}
}
+ public void cleanBroker()
+ {
+ if (_brokerClean != null)
+ {
+ _logger.info("clean: " + _brokerClean);
+
+ try
+ {
+ ProcessBuilder pb = new ProcessBuilder(_brokerClean.split("\\s+"));
+ pb.redirectErrorStream(true);
+ Process clean = pb.start();
+ new Piper(clean.getInputStream()).start();
+
+ clean.waitFor();
+
+ _logger.info("clean exited: " + clean.exitValue());
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException(e);
+ }
+ catch (InterruptedException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
public void stopBroker() throws Exception
{
_logger.info("stopping broker: " + _broker);
diff --git a/java/module.xml b/java/module.xml
index c129c2ea7a..1da06ab92b 100644
--- a/java/module.xml
+++ b/java/module.xml
@@ -169,14 +169,18 @@
<condition property="brokerdefault" value="${project.root}/../cpp/src/qpidd --data-dir ${build.data} -t" else="vm">
<isset property="cpp"/>
- </condition>
+ </condition>
- <condition property="broker" value="${brokerdefault} --load-module ${store}" else="${brokerdefault}">
+ <condition property="broker" value="${brokerdefault} --load-module ${store} --store-async yes" else="${brokerdefault}">
<and>
- <isset property="store"/>
- <isset property="cpp"/>
- </and>
- </condition>
+ <isset property="store"/>
+ <isset property="cpp"/>
+ </and>
+ </condition>
+
+ <condition property="broker.clean" value="${project.root}/clean-dir ${build.data}">
+ <isset property="cpp"/>
+ </condition>
<condition property="broker.version" value="0-10" else="0-8">
<isset property="cpp"/>
@@ -184,7 +188,6 @@
<target name="test" depends="compile-tests" if="module.test.src.exists"
description="execute unit tests">
- <echo message="=------->>>>>>>>>>>>> ${broker}"/>
<junit fork="yes" haltonfailure="no" printsummary="on" timeout="600000">
<sysproperty key="amqj.logging.level" value="${amqj.logging.level}"/>
@@ -193,6 +196,7 @@
<sysproperty key="java.naming.factory.initial" value="${java.naming.factory.initial}"/>
<sysproperty key="java.naming.provider.url" value="${java.naming.provider.url}"/>
<sysproperty key="broker" value="${broker}"/>
+ <sysproperty key="broker.clean" value="${broker.clean}"/>
<sysproperty key="broker.version" value="${broker.version}"/>
<formatter type="plain"/>