activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject git commit: Add some methods for stoppng and restarting broker during tests.
Date Wed, 27 Nov 2013 19:02:14 GMT
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 <tabish121@gmai.com>
Authored: Wed Nov 27 14:02:05 2013 -0500
Committer: Timothy Bish <tabish121@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();
     }
 


Mime
View raw message