From 739c0f368b5d9ad79ee3d8f68d55134cfc5c3f69 Mon Sep 17 00:00:00 2001 From: Martyn Taylor Date: Mon, 15 Dec 2014 13:50:45 +0000 Subject: [PATCH] Allow tests to set TM in TMLocatorImpl Some tests require a proper TM to be returned by the TMLocator implementation whilst others require a DummyTM to be returned. This patch makes allows TM returned by the locator class to be changed by the test. --- .../integration/jms/bridge/TransactionManagerLocatorImpl.java | 4 +++- .../apache/activemq/tests/integration/ra/JMSContextTest.java | 2 ++ .../activemq/tests/integration/ra/OutgoingConnectionTest.java | 1 - 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/jms/bridge/TransactionManagerLocatorImpl.java b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/jms/bridge/TransactionManagerLocatorImpl.java index 5ab404f9c6..7d6ff749e9 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/jms/bridge/TransactionManagerLocatorImpl.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/jms/bridge/TransactionManagerLocatorImpl.java @@ -28,9 +28,11 @@ import org.apache.activemq.service.extensions.transactions.TransactionManagerLoc public class TransactionManagerLocatorImpl implements TransactionManagerLocator { + public static TransactionManager tm = new TransactionManagerImple(); + @Override public TransactionManager getTransactionManager() { - return new TransactionManagerImple(); + return tm; } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/ra/JMSContextTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/ra/JMSContextTest.java index aeed55cbee..92c350cb81 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/ra/JMSContextTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/ra/JMSContextTest.java @@ -29,6 +29,7 @@ import org.apache.activemq.ra.ActiveMQRAConnectionFactoryImpl; import org.apache.activemq.ra.ActiveMQRAConnectionManager; import org.apache.activemq.ra.ActiveMQRAManagedConnectionFactory; import org.apache.activemq.ra.ActiveMQResourceAdapter; +import org.apache.activemq.tests.integration.jms.bridge.TransactionManagerLocatorImpl; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -63,6 +64,7 @@ public class JMSContextTest extends ActiveMQRATestBase resourceAdapter.setConnectorClassName(InVMConnectorFactory.class.getName()); MyBootstrapContext ctx = new MyBootstrapContext(); + TransactionManagerLocatorImpl.tm = DummyTransactionManager.tm; resourceAdapter.start(ctx); ActiveMQRAManagedConnectionFactory mcf = new ActiveMQRAManagedConnectionFactory(); mcf.setResourceAdapter(resourceAdapter); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/ra/OutgoingConnectionTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/ra/OutgoingConnectionTest.java index 4dbf1afaa3..f906885bf3 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/ra/OutgoingConnectionTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/ra/OutgoingConnectionTest.java @@ -286,7 +286,6 @@ public class OutgoingConnectionTest extends ActiveMQRATestBase { setupDLQ(10); resourceAdapter = newResourceAdapter(); - DummyTransactionManager.tm.tx = new DummyTransaction(); MyBootstrapContext ctx = new MyBootstrapContext(); resourceAdapter.start(ctx); ActiveMQRAManagedConnectionFactory mcf = new ActiveMQRAManagedConnectionFactory();