You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2013/11/27 20:02:14 UTC

git commit: Add some methods for stoppng and restarting broker during tests.

Updated Branches:
  refs/heads/trunk eead6e511 -> e3fed4b57


Add some methods for stoppng and restarting broker during tests.

Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/e3fed4b5
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/e3fed4b5
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/e3fed4b5

Branch: refs/heads/trunk
Commit: e3fed4b57a295c73fcc98f2abbdd98d3a67baaba
Parents: eead6e5
Author: Timothy Bish <ta...@gmai.com>
Authored: Wed Nov 27 14:02:05 2013 -0500
Committer: Timothy Bish <ta...@gmai.com>
Committed: Wed Nov 27 14:02:05 2013 -0500

----------------------------------------------------------------------
 .../transport/amqp/AmqpTestSupport.java         | 30 +++++++++++++++++---
 1 file changed, 26 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/e3fed4b5/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/AmqpTestSupport.java
----------------------------------------------------------------------
diff --git a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/AmqpTestSupport.java b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/AmqpTestSupport.java
index 5c5bcff..91eb6b2 100644
--- a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/AmqpTestSupport.java
+++ b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/AmqpTestSupport.java
@@ -70,12 +70,14 @@ public class AmqpTestSupport {
         autoFailTestSupport.startAutoFailThread();
         exceptions.clear();
         startBroker();
+        this.numberOfMessages = 2000;
     }
 
-    public void startBroker() throws Exception {
+    private void createBroker(boolean deleteAllMessages) throws Exception {
         brokerService = new BrokerService();
         brokerService.setPersistent(false);
         brokerService.setAdvisorySupport(false);
+        brokerService.setDeleteAllMessagesOnStartup(deleteAllMessages);
 
         SSLContext ctx = SSLContext.getInstance("TLS");
         ctx.init(new KeyManager[0], new TrustManager[]{new DefaultTrustManager()}, new SecureRandom());
@@ -93,8 +95,6 @@ public class AmqpTestSupport {
         brokerService.setSslContext(sslContext);
 
         addAMQPConnector();
-        brokerService.start();
-        this.numberOfMessages = 2000;
     }
 
     protected void addAMQPConnector() throws Exception {
@@ -112,12 +112,34 @@ public class AmqpTestSupport {
         LOG.debug("Using amqp+nio+ssl port " + nioPlusSslPort);
     }
 
-    @After
+    public void startBroker() throws Exception {
+        if (brokerService != null) {
+            throw new IllegalStateException("Broker is already created.");
+        }
+
+        createBroker(true);
+        brokerService.start();
+        brokerService.waitUntilStarted();
+    }
+
+    public void restartBroker() throws Exception {
+        stopBroker();
+        createBroker(false);
+        brokerService.start();
+        brokerService.waitUntilStarted();
+    }
+
     public void stopBroker() throws Exception {
         if (brokerService != null) {
             brokerService.stop();
+            brokerService.waitUntilStopped();
             brokerService = null;
         }
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        stopBroker();
         autoFailTestSupport.stopAutoFailThread();
     }