activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject activemq git commit: https://issues.apache.org/jira/browse/AMQ-5621
Date Wed, 04 Mar 2015 15:44:12 GMT
Repository: activemq
Updated Branches:
  refs/heads/master ac24a08b8 -> 7fdfdeba7


https://issues.apache.org/jira/browse/AMQ-5621

Turn off JMX, switch to JUnit 4 style test with timeout, actually
shutdown the running broker and clean up in tear down method.

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

Branch: refs/heads/master
Commit: 7fdfdeba79d849623d3e82beded4786c1e337dea
Parents: ac24a08
Author: Timothy Bish <tabish121@gmail.com>
Authored: Wed Mar 4 10:44:03 2015 -0500
Committer: Timothy Bish <tabish121@gmail.com>
Committed: Wed Mar 4 10:44:03 2015 -0500

----------------------------------------------------------------------
 .../org/apache/activemq/bugs/AMQ3779Test.java   | 72 ++++++++++++++------
 1 file changed, 50 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/7fdfdeba/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3779Test.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3779Test.java b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3779Test.java
index 5a410e8..e068a4c 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3779Test.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3779Test.java
@@ -17,29 +17,40 @@
 
 package org.apache.activemq.bugs;
 
+import static org.junit.Assert.assertTrue;
+
 import java.util.concurrent.atomic.AtomicBoolean;
+
 import javax.jms.Connection;
 import javax.jms.DeliveryMode;
 import javax.jms.MessageProducer;
 import javax.jms.Session;
+
 import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.AutoFailTestSupport;
 import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.broker.util.LoggingBrokerPlugin;
 import org.apache.activemq.util.DefaultTestAppender;
 import org.apache.log4j.Appender;
 import org.apache.log4j.Logger;
 import org.apache.log4j.spi.LoggingEvent;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 
-public class AMQ3779Test extends AutoFailTestSupport {
+public class AMQ3779Test {
 
-    private static final Logger logger = Logger.getLogger(AMQ3779Test.class);
+    private static final Logger LOG = Logger.getLogger(AMQ3779Test.class);
     private static final String qName = "QNameToFind";
 
-    public void testLogPerDest() throws Exception {
+    private BrokerService brokerService;
+    private Appender appender;
+    private final AtomicBoolean ok = new AtomicBoolean(false);
+
+    @Before
+    public void setUp() throws Exception {
+        ok.set(false);
 
-        final AtomicBoolean ok = new AtomicBoolean(false);
-        Appender appender = new DefaultTestAppender() {
+        appender = new DefaultTestAppender() {
             @Override
             public void doAppend(LoggingEvent event) {
                 if (event.getLoggerName().toString().contains(qName)) {
@@ -47,30 +58,47 @@ public class AMQ3779Test extends AutoFailTestSupport {
                 }
             }
         };
-        logger.getRootLogger().addAppender(appender);
 
-        try {
+        Logger.getRootLogger().addAppender(appender);
 
-            BrokerService broker = new BrokerService();
+        try {
+            brokerService = new BrokerService();
             LoggingBrokerPlugin loggingBrokerPlugin = new LoggingBrokerPlugin();
             loggingBrokerPlugin.setPerDestinationLogger(true);
             loggingBrokerPlugin.setLogAll(true);
-            broker.setPlugins(new LoggingBrokerPlugin[]{loggingBrokerPlugin});
-            broker.start();
-
+            brokerService.setPlugins(new LoggingBrokerPlugin[]{loggingBrokerPlugin});
 
-            Connection connection = new ActiveMQConnectionFactory(broker.getVmConnectorURI()).createConnection();
-            Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-            MessageProducer messageProducer = session.createProducer(session.createQueue(qName));
-            messageProducer.setDeliveryMode(DeliveryMode.PERSISTENT);
-            connection.start();
-
-            messageProducer.send(session.createTextMessage("Hi"));
-            connection.close();
+            brokerService.setPersistent(false);
+            brokerService.setUseJmx(false);
+            brokerService.start();
+        } finally {
+            LOG.removeAppender(appender);
+        }
+    }
 
-            assertTrue("got expected log message", ok.get());
+    @After
+    public void tearDown() throws Exception {
+        try {
+            if (brokerService != null) {
+                brokerService.stop();
+                brokerService.waitUntilStopped();
+            }
         } finally {
-            logger.removeAppender(appender);
+            LOG.removeAppender(appender);
         }
     }
+
+    @Test(timeout = 60000)
+    public void testLogPerDest() throws Exception {
+        Connection connection = new ActiveMQConnectionFactory(brokerService.getVmConnectorURI()).createConnection();
+        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        MessageProducer messageProducer = session.createProducer(session.createQueue(qName));
+        messageProducer.setDeliveryMode(DeliveryMode.PERSISTENT);
+        connection.start();
+
+        messageProducer.send(session.createTextMessage("Hi"));
+        connection.close();
+
+        assertTrue("got expected log message", ok.get());
+    }
 }


Mime
View raw message