diff options
| author | Keith Wall <kwall@apache.org> | 2012-03-30 08:54:06 +0000 |
|---|---|---|
| committer | Keith Wall <kwall@apache.org> | 2012-03-30 08:54:06 +0000 |
| commit | 6e605c53e91d5b9b1bf46985c5cf8bd94a34de4d (patch) | |
| tree | d2c4300f3309cc5fc9f825837bbb46e1da8c7d78 /qpid/java | |
| parent | ae9493a91afe1d12f11ef61e6744264447f41f9e (diff) | |
| download | qpid-python-6e605c53e91d5b9b1bf46985c5cf8bd94a34de4d.tar.gz | |
NO-JIRA: QpidBrokerTestCase - minor improvements
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1307316 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java')
5 files changed, 26 insertions, 32 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 94db7d8dde..ee9556f1f0 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 @@ -157,7 +157,7 @@ public class QpidTestCase extends TestCase * @param fromPort the port to scan for availability * @throws NoSuchElementException if there are no ports available */ - protected int getNextAvailable(int fromPort) + public int getNextAvailable(int fromPort) { if ((fromPort < MIN_PORT_NUMBER) || (fromPort > MAX_PORT_NUMBER)) { diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/jms/xa/XAResourceTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/jms/xa/XAResourceTest.java index c8ffe8571d..ac29b72620 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/jms/xa/XAResourceTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/jms/xa/XAResourceTest.java @@ -90,15 +90,6 @@ public class XAResourceTest extends QpidBrokerTestCase } @Override - public void stopBroker(int port) throws Exception - { - if (isBrokerPresent(port)) - { - super.stopBroker(port); - } - } - - @Override public void tearDown() throws Exception { try diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/ra/QpidRAConnectionTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/ra/QpidRAConnectionTest.java index 658e1fca1f..0ca90ac2ea 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/ra/QpidRAConnectionTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/ra/QpidRAConnectionTest.java @@ -86,12 +86,4 @@ public class QpidRAConnectionTest extends QpidBrokerTestCase c.close(); } } - @Override - public void stopBroker(int port) throws Exception - { - if (isBrokerPresent(port)) - { - super.stopBroker(port); - } - } } 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 32c6094adb..e2c107817a 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 @@ -63,9 +63,12 @@ import java.io.PrintStream; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.TimeUnit; /** @@ -195,6 +198,7 @@ public class QpidBrokerTestCase extends QpidTestCase return QpidBrokerTestCase._logger; } + @Override public void runBare() throws Throwable { String qname = getClass().getName() + "." + getName(); @@ -243,14 +247,7 @@ public class QpidBrokerTestCase extends QpidTestCase } finally { - try - { - stopBroker(); - } - catch (Exception e) - { - _logger.error("exception stopping broker", e); - } + stopAllBrokers(); // reset properties used in the test revertSystemProperties(); @@ -634,12 +631,21 @@ public class QpidBrokerTestCase extends QpidTestCase } } - public void stopBroker() throws Exception + public void stopBroker() { stopBroker(0); } - public void stopBroker(int port) throws Exception + public void stopAllBrokers() + { + Set<Integer> runningBrokerPorts = new HashSet<Integer>(getBrokerPortNumbers()); + for (int brokerPortNumber : runningBrokerPorts) + { + stopBroker(brokerPortNumber); + } + } + + public void stopBroker(int port) { if (isBrokerPresent(port)) { @@ -651,12 +657,12 @@ public class QpidBrokerTestCase extends QpidTestCase } } - public void killBroker() throws Exception + public void killBroker() { killBroker(0); } - public void killBroker(int port) throws Exception + public void killBroker(int port) { if (isBrokerPresent(port)) { @@ -668,7 +674,7 @@ public class QpidBrokerTestCase extends QpidTestCase } } - public boolean isBrokerPresent(int port) throws Exception + public boolean isBrokerPresent(int port) { port = getPort(port); @@ -681,6 +687,11 @@ public class QpidBrokerTestCase extends QpidTestCase return _brokers.get(port); } + public Set<Integer> getBrokerPortNumbers() + { + return new HashSet<Integer>(_brokers.keySet()); + } + /** * Attempt to set the Java Broker to use the BDBMessageStore for persistence * Falling back to the DerbyMessageStore if diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/SpawnedBrokerHolder.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/SpawnedBrokerHolder.java index 50b1ea7cea..787fc164d5 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/SpawnedBrokerHolder.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/SpawnedBrokerHolder.java @@ -114,7 +114,7 @@ public class SpawnedBrokerHolder implements BrokerHolder } catch (ReflectionUtilsException e) { - LOGGER.warn("Could not get pid for process, Broker process shutdown will be ungraceful"); + LOGGER.warn("Could not get pid for process, Broker process shutdown will be graceful"); } } return null; |
