From 47c024237135d9db387bb5db7f234e324871dfa4 Mon Sep 17 00:00:00 2001 From: Martin Ritchie Date: Sun, 16 Aug 2009 23:15:41 +0000 Subject: Give QpidTestCase the ability to set environment variables for the external brokers git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@804811 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/qpid/test/utils/QpidTestCase.java | 29 +++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) 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 e7218d6975..db096710dc 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 @@ -157,7 +157,7 @@ public class QpidTestCase extends TestCase private static final String VERSION_08 = "0-8"; private static final String VERSION_010 = "0-10"; - private static final String QPID_HOME = "QPID_HOME"; + protected static final String QPID_HOME = "QPID_HOME"; protected static int DEFAULT_VM_PORT = 1; protected static int DEFAULT_PORT = Integer.getInteger("test.port", 5672); @@ -182,6 +182,8 @@ public class QpidTestCase extends TestCase protected List _connections = new ArrayList(); public static final String QUEUE = "queue"; public static final String TOPIC = "topic"; + /** Map to hold test defined environment properties */ + private Map _env; public QpidTestCase(String name) @@ -199,6 +201,9 @@ public class QpidTestCase extends TestCase _testName = getClass().getSimpleName() + "." + getName(); String qname = getClass().getName() + "." + getName(); + // Initalise this for each test run + _env = new HashMap(); + PrintStream oldOut = System.out; PrintStream oldErr = System.err; PrintStream out = null; @@ -435,6 +440,16 @@ public class QpidTestCase extends TestCase //Add the test name to the broker run. env.put("QPID_PNAME", "-DPNAME=\"" + _testName + "\""); env.put("QPID_WORK", System.getProperty("QPID_WORK")); + + // Add all the environment settings the test requested + if (!_env.isEmpty()) + { + for(Map.Entry entry : _env.entrySet()) + { + env.put(entry.getKey() ,entry.getValue()); + } + } + process = pb.start(); Piper p = new Piper(process.getInputStream(), @@ -676,6 +691,18 @@ public class QpidTestCase extends TestCase } } + /** + * Add an environtmen variable for the external broker environment + * + * @param property the property to set + * @param value the value to set it to + */ + protected void setBrokerEnvironment(String property, String value) + { + _env.put(property,value); + } + + /** * Check whether the broker is an 0.8 * -- cgit v1.2.1