summaryrefslogtreecommitdiff
path: root/qpid/java
diff options
context:
space:
mode:
authorRobert Gemmell <robbie@apache.org>2011-08-21 15:29:52 +0000
committerRobert Gemmell <robbie@apache.org>2011-08-21 15:29:52 +0000
commitacfc50e9a15f0a25b2f9eff1b2c83a643e9691ca (patch)
tree5c68f32579ae90f78a068636751222332148dc53 /qpid/java
parent1f5408d785d38c00051be1922b62529a4be9cae6 (diff)
downloadqpid-python-acfc50e9a15f0a25b2f9eff1b2c83a643e9691ca.tar.gz
NO-JIRA: remove test config for Logger which is no longer used, move test start reporting to QTC so it shows up in output of non-broker tests, move log level utility methods to QTC
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1159998 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java')
-rw-r--r--qpid/java/common/src/test/java/org/apache/qpid/test/utils/QpidTestCase.java73
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/AbstractACLTestCase.java2
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java47
-rw-r--r--qpid/java/test-profiles/log4j-test.xml4
4 files changed, 70 insertions, 56 deletions
diff --git a/qpid/java/common/src/test/java/org/apache/qpid/test/utils/QpidTestCase.java b/qpid/java/common/src/test/java/org/apache/qpid/test/utils/QpidTestCase.java
index 2ec5e17a16..ac3380e0c0 100644
--- a/qpid/java/common/src/test/java/org/apache/qpid/test/utils/QpidTestCase.java
+++ b/qpid/java/common/src/test/java/org/apache/qpid/test/utils/QpidTestCase.java
@@ -32,6 +32,7 @@ import java.util.Map;
import junit.framework.TestCase;
import junit.framework.TestResult;
+import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.mina.util.AvailablePortFinder;
@@ -42,8 +43,11 @@ public class QpidTestCase extends TestCase
private static final Logger _logger = Logger.getLogger(QpidTestCase.class);
+ private final Map<Logger, Level> _loggerLevelSetForTest = new HashMap<Logger, Level>();
private final Map<String, String> _propertiesSetForTest = new HashMap<String, String>();
+ private String _testName;
+
/**
* Some tests are excluded when the property test.excludes is set to true.
* An exclusion list is either a file (prop test.excludesfile) which contains one test name
@@ -172,25 +176,74 @@ public class QpidTestCase extends TestCase
*/
protected void revertTestSystemProperties()
{
- _logger.debug("reverting " + _propertiesSetForTest.size() + " test properties");
- for (String key : _propertiesSetForTest.keySet())
+ if(!_propertiesSetForTest.isEmpty())
{
- String value = _propertiesSetForTest.get(key);
- if (value != null)
- {
- System.setProperty(key, value);
- }
- else
+ _logger.debug("reverting " + _propertiesSetForTest.size() + " test properties");
+ for (String key : _propertiesSetForTest.keySet())
{
- System.clearProperty(key);
+ String value = _propertiesSetForTest.get(key);
+ if (value != null)
+ {
+ System.setProperty(key, value);
+ }
+ else
+ {
+ System.clearProperty(key);
+ }
}
+
+ _propertiesSetForTest.clear();
+ }
+ }
+
+ /**
+ * Adjust the VMs Log4j Settings just for this test run
+ *
+ * @param logger the logger to change
+ * @param level the level to set
+ */
+ protected void setLoggerLevel(Logger logger, Level level)
+ {
+ assertNotNull("Cannot set level of null logger", logger);
+ assertNotNull("Cannot set Logger("+logger.getName()+") to null level.",level);
+
+ if (!_loggerLevelSetForTest.containsKey(logger))
+ {
+ // Record the current value so we can revert it later.
+ _loggerLevelSetForTest.put(logger, logger.getLevel());
+ }
+
+ logger.setLevel(level);
+ }
+
+ /**
+ * Restore the logging levels defined by this test.
+ */
+ protected void revertLoggingLevels()
+ {
+ for (Logger logger : _loggerLevelSetForTest.keySet())
+ {
+ logger.setLevel(_loggerLevelSetForTest.get(logger));
}
- _propertiesSetForTest.clear();
+ _loggerLevelSetForTest.clear();
}
protected void tearDown() throws java.lang.Exception
{
+ _logger.info("========== tearDown " + _testName + " ==========");
revertTestSystemProperties();
+ revertLoggingLevels();
+ }
+
+ protected void setUp() throws Exception
+ {
+ _testName = getClass().getSimpleName() + "." + getName();
+ _logger.info("========== start " + _testName + " ==========");
+ }
+
+ protected String getTestName()
+ {
+ return _testName;
}
}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/AbstractACLTestCase.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/AbstractACLTestCase.java
index 7f8f71d965..8aa5b6d9de 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/AbstractACLTestCase.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/AbstractACLTestCase.java
@@ -196,7 +196,7 @@ public abstract class AbstractACLTestCase extends QpidBrokerTestCase implements
}
PrintWriter out = new PrintWriter(new FileWriter(aclFile));
- out.println(String.format("# %s", _testName));
+ out.println(String.format("# %s", getTestName()));
for (String line : rules)
{
out.println(line);
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
index 2e9e18d493..0a98fc3382 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
@@ -92,7 +92,6 @@ public class QpidBrokerTestCase extends QpidTestCase
protected long RECEIVE_TIMEOUT = 1000l;
private Map<String, String> _propertiesSetForBroker = new HashMap<String, String>();
- private Map<Logger, Level> _loggerLevelSetForTest = new HashMap<Logger, Level>();
private XMLConfiguration _testConfiguration = new XMLConfiguration();
private XMLConfiguration _testVirtualhosts = new XMLConfiguration();
@@ -163,8 +162,6 @@ public class QpidBrokerTestCase extends QpidTestCase
protected InitialContext _initialContext;
protected AMQConnectionFactory _connectionFactory;
- protected String _testName;
-
// the connections created for a given test
protected List<Connection> _connections = new ArrayList<Connection>();
public static final String QUEUE = "queue";
@@ -206,7 +203,6 @@ public class QpidBrokerTestCase extends QpidTestCase
public void runBare() throws Throwable
{
- _testName = getClass().getSimpleName() + "." + getName();
String qname = getClass().getName() + "." + getName();
// Initialize this for each test run
@@ -237,7 +233,6 @@ public class QpidBrokerTestCase extends QpidTestCase
}
}
- _logger.info("========== start " + _testName + " ==========");
try
{
super.runBare();
@@ -274,7 +269,7 @@ public class QpidBrokerTestCase extends QpidTestCase
}
}
- _logger.info("========== stop " + _testName + " ==========");
+ _logger.info("========== stop " + getTestName() + " ==========");
if (redirected)
{
@@ -293,6 +288,8 @@ public class QpidBrokerTestCase extends QpidTestCase
@Override
protected void setUp() throws Exception
{
+ super.setUp();
+
if (!_configFile.exists())
{
fail("Unable to test without config file:" + _configFile);
@@ -512,7 +509,7 @@ public class QpidBrokerTestCase extends QpidTestCase
//Add the test name to the broker run.
// DON'T change PNAME, qpid.stop needs this value.
- env.put("QPID_PNAME", "-DPNAME=QPBRKR -DTNAME=\"" + _testName + "\"");
+ env.put("QPID_PNAME", "-DPNAME=QPBRKR -DTNAME=\"" + getTestName() + "\"");
// Add the port to QPID_WORK to ensure unique working dirs for multi broker tests
env.put("QPID_WORK", getQpidWork(_brokerType, port));
@@ -920,40 +917,6 @@ public class QpidBrokerTestCase extends QpidTestCase
}
/**
- * Adjust the VMs Log4j Settings just for this test run
- *
- * @param logger the logger to change
- * @param level the level to set
- */
- protected void setLoggerLevel(Logger logger, Level level)
- {
- assertNotNull("Cannot set level of null logger", logger);
- assertNotNull("Cannot set Logger("+logger.getName()+") to null level.",level);
-
- if (!_loggerLevelSetForTest.containsKey(logger))
- {
- // Record the current value so we can revert it later.
- _loggerLevelSetForTest.put(logger, logger.getLevel());
- }
-
- logger.setLevel(level);
- }
-
- /**
- * Restore the logging levels defined by this test.
- */
- protected void revertLoggingLevels()
- {
- for (Logger logger : _loggerLevelSetForTest.keySet())
- {
- logger.setLevel(_loggerLevelSetForTest.get(logger));
- }
-
- _loggerLevelSetForTest.clear();
-
- }
-
- /**
* Check whether the broker is an 0.8
*
* @return true if the broker is an 0_8 version, false otherwise.
@@ -1129,6 +1092,8 @@ public class QpidBrokerTestCase extends QpidTestCase
protected void tearDown() throws java.lang.Exception
{
+ super.tearDown();
+
// close all the connections used by this test.
for (Connection c : _connections)
{
diff --git a/qpid/java/test-profiles/log4j-test.xml b/qpid/java/test-profiles/log4j-test.xml
index 9adfd68202..062acaaac9 100644
--- a/qpid/java/test-profiles/log4j-test.xml
+++ b/qpid/java/test-profiles/log4j-test.xml
@@ -59,10 +59,6 @@
<level value="ERROR"/>
</logger>
- <logger name="org.apache.qpid.server.virtualhost.VirtualHostImpl$1HouseKeepingTask">
- <level value="WARN"/>
- </logger>
-
<root>
<level value="${root.logging.level}"/>
<appender-ref ref="console" />