You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ri...@apache.org on 2009/09/30 17:59:27 UTC
svn commit: r820323 - in
/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid:
server/BrokerStartupTest.java server/logging/BrokerLoggingTest.java
test/utils/QpidTestCase.java
Author: ritchiem
Date: Wed Sep 30 15:59:27 2009
New Revision: 820323
URL: http://svn.apache.org/viewvc?rev=820323&view=rev
Log:
QPID-2121 : Update to QTC to allow the setting of System Properties for just the Test run or the External Broker or both.
renamed _setProperties as it was confusing. Now two maps are used _propertiesSetForTestOnly and _propertiesSetForBroker calls to setSystemProperty puts the value in to both maps so test VM and the external VM will have a system property defined to have that value. If a test is configured to run against an external broker then two new methods help control how each vm is setup. setTestClientSystemProperty is used to set a value in the TestVM that is not copied to any external VM. setBrokerOnlySystemProperty can now be used to set a System property value in the external broker VM only.
As before all values are reverted at the end of the test run.
Modified:
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/BrokerStartupTest.java
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BrokerLoggingTest.java
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java
Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/BrokerStartupTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/BrokerStartupTest.java?rev=820323&r1=820322&r2=820323&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/BrokerStartupTest.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/BrokerStartupTest.java Wed Sep 30 15:59:27 2009
@@ -90,10 +90,10 @@
// Set the broker to use info level logging, which is the qpid-server
// default. Rather than debug which is the test default.
- setSystemProperty("amqj.server.logging.level","info");
+ setBrokerOnlySystemProperty("amqj.server.logging.level", "info");
// Set the logging defaults to info for this test.
- setSystemProperty("amqj.logging.level","info");
- setSystemProperty("root.logging.level","info");
+ setBrokerOnlySystemProperty("amqj.logging.level", "info");
+ setBrokerOnlySystemProperty("root.logging.level", "info");
startBroker();
Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BrokerLoggingTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BrokerLoggingTest.java?rev=820323&r1=820322&r2=820323&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BrokerLoggingTest.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BrokerLoggingTest.java Wed Sep 30 15:59:27 2009
@@ -160,7 +160,7 @@
// Set the broker.ready string to check for the _log4j default that
// is still present on standard out.
- System.setProperty(BROKER_READY, "Qpid Broker Ready");
+ setTestClientSystemProperty(BROKER_READY, "Qpid Broker Ready");
startBroker();
Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java?rev=820323&r1=820322&r2=820323&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java Wed Sep 30 15:59:27 2009
@@ -74,7 +74,9 @@
protected long RECEIVE_TIMEOUT = 1000l;
- private Map<String, String> _setProperties = new HashMap<String, String>();
+ private Map<String, String> _propertiesSetForTestOnly = new HashMap<String, String>();
+ private Map<String, String> _propertiesSetForBroker = new HashMap<String, String>();
+
private XMLConfiguration _testConfiguration = new XMLConfiguration();
/**
@@ -487,21 +489,23 @@
// Add default test logging levels that are used by the log4j-test
+ // Use the convenience methods to push the current logging setting
+ // in to the external broker's QPID_OPTS string.
if (System.getProperty("amqj.protocol.logging.level") != null)
{
- setSystemProperty("amqj.protocol.logging.level", System.getProperty("amqj.protocol.logging.level"));
+ setSystemProperty("amqj.protocol.logging.level");
}
if (System.getProperty("root.logging.level") != null)
{
- setSystemProperty("root.logging.level", System.getProperty("root.logging.level"));
+ setSystemProperty("root.logging.level");
}
String QPID_OPTS = " ";
// Add all the specified system properties to QPID_OPTS
- if (!_setProperties.isEmpty())
+ if (!_propertiesSetForBroker.isEmpty())
{
- for (String key : _setProperties.keySet())
+ for (String key : _propertiesSetForBroker.keySet())
{
QPID_OPTS += "-D" + key + "=" + System.getProperty(key) + " ";
}
@@ -526,7 +530,7 @@
if (!p.await(30, TimeUnit.SECONDS))
{
- _logger.info("broker failed to become ready:" + p.getStopLine());
+ _logger.info("broker failed to become ready (" + p.ready + "):" + p.getStopLine());
//Ensure broker has stopped
process.destroy();
cleanBroker();
@@ -704,28 +708,87 @@
}
/**
+ * Set a System property that is to be applied only to the external test
+ * broker.
+ *
+ * This is a convenience method to enable the setting of a -Dproperty=value
+ * entry in QPID_OPTS
+ *
+ * This is only useful for the External Java Broker tests.
+ *
+ * @param property the property name
+ * @param value the value to set the property to
+ */
+ protected void setBrokerOnlySystemProperty(String property, String value)
+ {
+ if (!_propertiesSetForBroker.containsKey(property))
+ {
+ _propertiesSetForBroker.put(property, value);
+ }
+
+ }
+
+ /**
+ * Set a System (-D) property for this test run.
+ *
+ * This convenience method copies the current VMs System Property
+ * for the external VM Broker.
+ *
+ * @param property the System property to set
+ */
+ protected void setSystemProperty(String property)
+ {
+ setSystemProperty(property, System.getProperty(property));
+ }
+
+ /**
* Set a System property for the duration of this test.
*
* When the test run is complete the value will be reverted.
*
+ * The values set using this method will also be propogated to the external
+ * Java Broker via a -D value defined in QPID_OPTS.
+ *
+ * If the value should not be set on the broker then use
+ * setTestClientSystemProperty().
+ *
* @param property the property to set
* @param value the new value to use
*/
protected void setSystemProperty(String property, String value)
{
- if (!_setProperties.containsKey(property))
+ // Record the value for the external broker
+ _propertiesSetForBroker.put(property, value);
+
+ //Set the value for the test client vm aswell.
+ setTestClientSystemProperty(property, value);
+ }
+
+ /**
+ * Set a System (-D) property for the external Broker of this test.
+ *
+ * @param property The property to set
+ * @param value the value to set it to.
+ */
+ protected void setTestClientSystemProperty(String property, String value)
+ {
+ if (!_propertiesSetForTestOnly.containsKey(property))
{
- _setProperties.put(property, System.getProperty(property));
- }
+ // Record the current value so we can revert it later.
+ _propertiesSetForTestOnly.put(property, System.getProperty(property));
+ }
System.setProperty(property, value);
}
+ /**
+ * Restore the System property values that were set before this test run.
+ */
protected void revertSystemProperties()
{
- for (String key : _setProperties.keySet())
+ for (String key : _propertiesSetForTestOnly.keySet())
{
- String value = _setProperties.get(key);
+ String value = _propertiesSetForTestOnly.get(key);
if (value != null)
{
System.setProperty(key, value);
@@ -735,6 +798,12 @@
System.clearProperty(key);
}
}
+
+ _propertiesSetForTestOnly.clear();
+
+ // We don't change the current VMs settings for Broker only properties
+ // so we can just clear this map
+ _propertiesSetForBroker.clear();
}
/**
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org