diff options
Diffstat (limited to 'qpid/java')
| -rw-r--r-- | qpid/java/module.xml | 13 | ||||
| -rw-r--r-- | qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java | 57 |
2 files changed, 57 insertions, 13 deletions
diff --git a/qpid/java/module.xml b/qpid/java/module.xml index 9fcc8ded4d..1cd1afc0c3 100644 --- a/qpid/java/module.xml +++ b/qpid/java/module.xml @@ -60,6 +60,8 @@ <property name="module.release.bz2" location="${module.release}/${module.namever}.tar.bz2"/> <property name="module.genpom.args" value=""/> + <property name="broker.log.prefix" value="BROKER: "/> + <property name="broker.log.interleave" value="true"/> <property name="module.qpid.jar" location="${module.release.lib}/qpid-all.jar"/> <basename property="qpid.jar.name" file="${module.qpid.jar}"/> @@ -276,6 +278,7 @@ <sysproperty key="broker.stopped" value="${broker.stopped}" /> <sysproperty key="broker.config" value="${broker.config}" /> <sysproperty key="test.output" value="${module.results}"/> + <syspropertyset> <propertyref prefix="test"/> </syspropertyset> @@ -284,7 +287,11 @@ </syspropertyset> <syspropertyset> <propertyref prefix="javax.net.ssl"/> + </syspropertyset> + <syspropertyset> + <propertyref prefix="broker"/> </syspropertyset> + <sysproperty key="max_prefetch" value ="${max_prefetch}"/> <sysproperty key="example.plugin.target" value="${project.root}/build/lib/plugins"/> <sysproperty key="QPID_EXAMPLE_HOME" value="${qpid.home}"/> @@ -526,6 +533,7 @@ </target> <target name="cover-test" depends="instrument"> + <mkdir dir="${build.coveragereport}" /> <junit fork="yes" forkmode="once" maxmemory="${test.mem}" reloading="no" haltonfailure="${haltonfailure}" haltonerror="${haltonerror}" @@ -543,9 +551,14 @@ <sysproperty key="broker.version" value="${broker.version}"/> <sysproperty key="broker.ready" value="${broker.ready}" /> <sysproperty key="test.output" value="${module.results}"/> + <syspropertyset> <propertyref prefix="test"/> </syspropertyset> + <syspropertyset> + <propertyref prefix="broker"/> + </syspropertyset> + <sysproperty key="max_prefetch" value ="${max_prefetch}"/> <sysproperty key="example.plugin.target" value="${project.root}/build/lib/plugins"/> <sysproperty key="QPID_EXAMPLE_HOME" value="${project.root}/build"/> diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java index b7ca40213a..a1fa2c1a0c 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java @@ -50,6 +50,7 @@ import javax.naming.InitialContext; import javax.naming.NamingException; import java.io.BufferedReader; import java.io.File; +import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; @@ -160,7 +161,9 @@ public class QpidTestCase extends TestCase protected static final String BROKER_READY = "broker.ready"; private static final String BROKER_STOPPED = "broker.stopped"; private static final String TEST_OUTPUT = "test.output"; - + private static final String BROKER_LOG_INTERLEAVE = "broker.log.interleave"; + private static final String BROKER_LOG_PREFIX = "broker.log.prefix"; + // values protected static final String JAVA = "java"; protected static final String CPP = "cpp"; @@ -181,9 +184,14 @@ public class QpidTestCase extends TestCase private Boolean _brokerCleanBetweenTests = Boolean.getBoolean(BROKER_CLEAN_BETWEEN_TESTS); private String _brokerVersion = System.getProperty(BROKER_VERSION, VERSION_08); private String _output = System.getProperty(TEST_OUTPUT); - + + private static String _brokerLogPrefix = System.getProperty(BROKER_LOG_PREFIX,"BROKER: "); + protected static boolean _interleaveBrokerLog = Boolean.getBoolean(BROKER_LOG_INTERLEAVE); + protected File _outputFile; - + + protected PrintStream _brokerOutputStream; + private Map<Integer, Process> _brokers = new HashMap<Integer, Process>(); private InitialContext _initialContext; @@ -209,17 +217,18 @@ public class QpidTestCase extends TestCase } public void runBare() throws Throwable - { + { _testName = getClass().getSimpleName() + "." + getName(); String qname = getClass().getName() + "." + getName(); - // Initalise this for each test run + // Initialize this for each test run _env = new HashMap<String, String>(); PrintStream oldOut = System.out; PrintStream oldErr = System.err; PrintStream out = null; PrintStream err = null; + boolean redirected = _output != null && _output.length() > 0; if (redirected) { @@ -228,6 +237,16 @@ public class QpidTestCase extends TestCase err = new PrintStream(String.format("%s/TEST-%s.err", _output, qname)); System.setOut(out); System.setErr(err); + + if (_interleaveBrokerLog) + { + _brokerOutputStream = out; + } + else + { + _brokerOutputStream = new PrintStream(new FileOutputStream(String + .format("%s/TEST-%s.broker.out", _output, qname)), true); + } } _logger.info("========== start " + _testName + " =========="); @@ -266,6 +285,10 @@ public class QpidTestCase extends TestCase System.setOut(oldOut); err.close(); out.close(); + if (!_interleaveBrokerLog) + { + _brokerOutputStream.close(); + } } } } @@ -300,20 +323,22 @@ public class QpidTestCase extends TestCase { private LineNumberReader in; + private PrintStream out; private String ready; private CountDownLatch latch; private boolean seenReady; private String stopped; private String stopLine; - public Piper(InputStream in, String ready) + public Piper(InputStream in, PrintStream out, String ready) { - this(in, ready, null); + this(in, out, ready, null); } - public Piper(InputStream in, String ready, String stopped) + public Piper(InputStream in, PrintStream out, String ready, String stopped) { this.in = new LineNumberReader(new InputStreamReader(in)); + this.out = out; this.ready = ready; this.stopped = stopped; this.seenReady = false; @@ -328,9 +353,9 @@ public class QpidTestCase extends TestCase } } - public Piper(InputStream in) + public Piper(InputStream in, PrintStream out) { - this(in, null); + this(in, out, null); } public boolean await(long timeout, TimeUnit unit) throws InterruptedException @@ -352,8 +377,13 @@ public class QpidTestCase extends TestCase { String line; while ((line = in.readLine()) != null) - { - System.out.println(line); + { + if (_interleaveBrokerLog) + { + line = _brokerLogPrefix + line; + } + out.println(line); + if (latch != null && line.contains(ready)) { seenReady = true; @@ -528,6 +558,7 @@ public class QpidTestCase extends TestCase process = pb.start(); Piper p = new Piper(process.getInputStream(), + _brokerOutputStream, System.getProperty(BROKER_READY), System.getProperty(BROKER_STOPPED)); @@ -591,7 +622,7 @@ public class QpidTestCase extends TestCase ProcessBuilder pb = new ProcessBuilder(_brokerClean.split("\\s+")); pb.redirectErrorStream(true); Process clean = pb.start(); - new Piper(clean.getInputStream()).start(); + new Piper(clean.getInputStream(),_brokerOutputStream).start(); clean.waitFor(); |
