added some clean up code that cause other tests fail.
Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/fda6e339 Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/fda6e339 Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/fda6e339 Branch: refs/heads/refactor-openwire Commit: fda6e339f45dbf5d75677617d477643ee1d82f6c Parents: 1be5004 Author: Howard Gao <howard....@gmail.com> Authored: Thu Feb 4 22:53:31 2016 +0800 Committer: Clebert Suconic <clebertsuco...@apache.org> Committed: Thu Feb 25 18:10:23 2016 -0500 ---------------------------------------------------------------------- .../activemq/transport/tcp/TcpTransportFactory.java | 15 ++++++++++++++- .../apache/activemq/QueueConsumerPriorityTest.java | 3 +++ .../test/java/org/apache/activemq/TimeStampTest.java | 10 ++++++++++ .../org/apache/activemq/TransactionContextTest.java | 10 ++++++++++ 4 files changed, 37 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/fda6e339/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java ---------------------------------------------------------------------- diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java index b3ac85f..4ddc2a6 100644 --- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java +++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java @@ -57,6 +57,8 @@ public class TcpTransportFactory extends TransportFactory { Map<String, String> params = URISupport.parseParameters(location); String brokerId = params.remove("invmBrokerId"); URI location1 = URISupport.createRemainingURI(location, Collections.EMPTY_MAP); + + LOG.info("deciding whether starting an internal broker: " + brokerService + " flag: " + BrokerService.disableWrapper); if (brokerService == null && !BrokerService.disableWrapper) { ArtemisBrokerHelper.startArtemisBroker(location1); @@ -179,7 +181,18 @@ public class TcpTransportFactory extends TransportFactory { return new InactivityMonitor(transport, format); } + //remember call this if the test is using the internal broker. public static void clearService() { - brokerService = null; + if (brokerService != null) { + try { + ArtemisBrokerHelper.stopArtemisBroker(); + } + catch (Exception e) { + e.printStackTrace(); + } + finally { + brokerService = null; + } + } } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/fda6e339/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/QueueConsumerPriorityTest.java ---------------------------------------------------------------------- diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/QueueConsumerPriorityTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/QueueConsumerPriorityTest.java index 0358323..296f52b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/QueueConsumerPriorityTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/QueueConsumerPriorityTest.java @@ -26,7 +26,9 @@ import javax.jms.Session; import junit.framework.TestCase; +import org.apache.activemq.artemiswrapper.ArtemisBrokerHelper; import org.apache.activemq.command.ActiveMQQueue; +import org.apache.activemq.transport.tcp.TcpTransportFactory; public class QueueConsumerPriorityTest extends TestCase { @@ -43,6 +45,7 @@ public class QueueConsumerPriorityTest extends TestCase { @Override protected void tearDown() throws Exception { + TcpTransportFactory.clearService(); super.tearDown(); } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/fda6e339/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/TimeStampTest.java ---------------------------------------------------------------------- diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/TimeStampTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/TimeStampTest.java index 87c5fc9..c1c058f 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/TimeStampTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/TimeStampTest.java @@ -34,6 +34,16 @@ import org.apache.activemq.broker.view.ConnectionDotFilePlugin; public class TimeStampTest extends TestCase { + @Override + public void setUp() { + BrokerService.disableWrapper = true; + } + + @Override + public void tearDown() { + BrokerService.disableWrapper = false; + } + public void test() throws Exception { BrokerService broker = new BrokerService(); broker.setPersistent(false); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/fda6e339/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/TransactionContextTest.java ---------------------------------------------------------------------- diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/TransactionContextTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/TransactionContextTest.java index beab88e..4991c92 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/TransactionContextTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/TransactionContextTest.java @@ -23,9 +23,14 @@ import java.util.concurrent.atomic.AtomicInteger; import javax.jms.TransactionRolledBackException; +import org.apache.activemq.artemiswrapper.ArtemisBrokerHelper; +import org.apache.activemq.broker.BrokerService; import org.apache.activemq.transaction.Synchronization; +import org.apache.activemq.transport.tcp.TcpTransportFactory; import org.junit.After; +import org.junit.AfterClass; import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; public class TransactionContextTest { @@ -40,6 +45,11 @@ public class TransactionContextTest { underTest = new TransactionContext(connection); } + @AfterClass + public static void cleanup() throws Exception { + TcpTransportFactory.clearService(); + } + @After public void tearDown() throws Exception { if (connection != null) {