activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andytay...@apache.org
Subject [1/3] activemq-artemis git commit: ARTEMIS-302 more changes around XA reliability (resilience on failures)
Date Wed, 16 Dec 2015 15:23:28 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/master a2c8e6bc3 -> 1f3d189dc


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/af1f79bf/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/ra/MDBMultipleHandlersServerDisconnectTest.java
----------------------------------------------------------------------
diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/ra/MDBMultipleHandlersServerDisconnectTest.java
b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/ra/MDBMultipleHandlersServerDisconnectTest.java
index 41f47b5..063a254 100644
--- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/ra/MDBMultipleHandlersServerDisconnectTest.java
+++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/ra/MDBMultipleHandlersServerDisconnectTest.java
@@ -70,6 +70,10 @@ public class MDBMultipleHandlersServerDisconnectTest extends ActiveMQRATestBase
 
    ServerLocator nettyLocator;
 
+   // This thread will keep bugging the handlers.
+   // if they behave well with XA, the test pass!
+   final AtomicBoolean running = new AtomicBoolean(true);
+
    private volatile boolean playTXTimeouts = true;
    private volatile boolean playServerClosingSession = true;
    private volatile boolean playServerClosingConsumer = true;
@@ -85,6 +89,7 @@ public class MDBMultipleHandlersServerDisconnectTest extends ActiveMQRATestBase
       super.setUp();
       createQueue(true, "outQueue");
       DummyTMLocator.startTM();
+      running.set(true);
    }
 
    @Override
@@ -113,6 +118,11 @@ public class MDBMultipleHandlersServerDisconnectTest extends ActiveMQRATestBase
       server.getAddressSettingsRepository().addMatch("#", settings);
       ActiveMQResourceAdapter qResourceAdapter = newResourceAdapter();
       resourceAdapter = qResourceAdapter;
+      resourceAdapter.setConfirmationWindowSize(-1);
+      resourceAdapter.setCallTimeout(1000L);
+      resourceAdapter.setConsumerWindowSize(1024 * 1024);
+      resourceAdapter.setReconnectAttempts(-1);
+      resourceAdapter.setRetryInterval(100L);
 
       //      qResourceAdapter.setTransactionManagerLocatorClass(DummyTMLocator.class.getName());
       //      qResourceAdapter.setTransactionManagerLocatorMethod("getTM");
@@ -125,17 +135,18 @@ public class MDBMultipleHandlersServerDisconnectTest extends ActiveMQRATestBase
       final int NUMBER_OF_SESSIONS = 10;
 
       ActiveMQActivationSpec spec = new ActiveMQActivationSpec();
-      spec.setMaxSession(NUMBER_OF_SESSIONS);
+
       spec.setTransactionTimeout(1);
-      spec.setReconnectAttempts(-1);
-      spec.setConfirmationWindowSize(-1);
-      spec.setReconnectInterval(1000);
-      spec.setCallTimeout(1000L);
+      spec.setMaxSession(NUMBER_OF_SESSIONS);
+      spec.setSetupAttempts(-1);
+      spec.setSetupInterval(100);
       spec.setResourceAdapter(qResourceAdapter);
       spec.setUseJNDI(false);
       spec.setDestinationType("javax.jms.Queue");
       spec.setDestination(MDBQUEUE);
-      spec.setConsumerWindowSize(1024 * 1024);
+
+      // Some the routines would be screwed up if using the default one
+      Assert.assertFalse(spec.isHasBeenUpdated());
 
       TestEndpointFactory endpointFactory = new TestEndpointFactory(true);
       qResourceAdapter.endpointActivation(endpointFactory, spec);
@@ -146,7 +157,6 @@ public class MDBMultipleHandlersServerDisconnectTest extends ActiveMQRATestBase
       final int NUMBER_OF_MESSAGES = 1000;
 
       Thread producer = new Thread() {
-         @Override
          public void run() {
             try {
                ServerLocator locator = createInVMLocator(0);
@@ -155,11 +165,18 @@ public class MDBMultipleHandlersServerDisconnectTest extends ActiveMQRATestBase
 
                ClientProducer clientProducer = session.createProducer(MDBQUEUEPREFIXED);
 
+               StringBuffer buffer = new StringBuffer();
+
+               for (int b = 0; b < 500; b++) {
+                  buffer.append("ab");
+               }
+
                for (int i = 0; i < NUMBER_OF_MESSAGES; i++) {
 
                   ClientMessage message = session.createMessage(true);
 
-                  message.getBodyBuffer().writeString("teststring " + i);
+                  message.getBodyBuffer().writeString(buffer.toString() + i);
+
                   message.putIntProperty("i", i);
 
                   clientProducer.send(message);
@@ -181,12 +198,7 @@ public class MDBMultipleHandlersServerDisconnectTest extends ActiveMQRATestBase
 
       final AtomicBoolean metaDataFailed = new AtomicBoolean(false);
 
-      // This thread will keep bugging the handlers.
-      // if they behave well with XA, the test pass!
-      final AtomicBoolean running = new AtomicBoolean(true);
-
       Thread buggerThread = new Thread() {
-         @Override
          public void run() {
             while (running.get()) {
                try {
@@ -197,7 +209,7 @@ public class MDBMultipleHandlersServerDisconnectTest extends ActiveMQRATestBase
                   return;
                }
 
-               List<ServerSession> serverSessions = lookupServerSessions("resource-adapter");
+               List<ServerSession> serverSessions = lookupServerSessions("resource-adapter",
NUMBER_OF_SESSIONS);
 
                System.err.println("Contains " + serverSessions.size() + " RA sessions");
 
@@ -256,6 +268,13 @@ public class MDBMultipleHandlersServerDisconnectTest extends ActiveMQRATestBase
             break;
          }
 
+         if (i == NUMBER_OF_MESSAGES * 0.50) {
+            // This is to make sure the MDBs will survive a reboot
+            // and no duplications or message loss will happen because of this
+            System.err.println("Rebooting the MDBs at least once!");
+            activation.startReconnectThread("I");
+         }
+
          if (i == NUMBER_OF_MESSAGES * 0.90) {
             System.out.println("Disabled failures at " + i);
             playTXTimeouts = false;
@@ -266,17 +285,7 @@ public class MDBMultipleHandlersServerDisconnectTest extends ActiveMQRATestBase
 
          System.out.println("Received " + i + " messages");
 
-         Assert.assertNotNull(message);
-         message.acknowledge();
-
-         Integer value = message.getIntProperty("i");
-         AtomicInteger mapCount = new AtomicInteger(1);
-
-         mapCount = mapCounter.putIfAbsent(value, mapCount);
-
-         if (mapCount != null) {
-            mapCount.incrementAndGet();
-         }
+         doReceiveMessage(message);
 
          if (i % 200 == 0) {
             System.out.println("received " + i);
@@ -285,6 +294,20 @@ public class MDBMultipleHandlersServerDisconnectTest extends ActiveMQRATestBase
       }
 
       session.commit();
+
+      while (true) {
+         ClientMessage message = consumer.receiveImmediate();
+         if (message == null) {
+            break;
+         }
+
+         System.out.println("Received extra message " + message);
+
+         doReceiveMessage(message);
+      }
+
+      session.commit();
+
       Assert.assertNull(consumer.receiveImmediate());
 
       StringWriter writer = new StringWriter();
@@ -328,14 +351,42 @@ public class MDBMultipleHandlersServerDisconnectTest extends ActiveMQRATestBase
 
    }
 
-   private List<ServerSession> lookupServerSessions(String parameter) {
-      List<ServerSession> serverSessions = new LinkedList<>();
+   private void doReceiveMessage(ClientMessage message) throws Exception {
+      Assert.assertNotNull(message);
+      message.acknowledge();
+      Integer value = message.getIntProperty("i");
+      AtomicInteger mapCount = new AtomicInteger(1);
 
-      for (ServerSession session : server.getSessions()) {
-         if (session.getMetaData(parameter) != null) {
-            serverSessions.add(session);
-         }
+      mapCount = mapCounter.putIfAbsent(value, mapCount);
+
+      if (mapCount != null) {
+         mapCount.incrementAndGet();
       }
+   }
+
+   private List<ServerSession> lookupServerSessions(String parameter, int numberOfSessions)
{
+      long timeout = System.currentTimeMillis() + 50000;
+      List<ServerSession> serverSessions = new LinkedList<ServerSession>();
+      do {
+         if (!serverSessions.isEmpty()) {
+            System.err.println("Retry on serverSessions!!! currently with " + serverSessions.size());
+            serverSessions.clear();
+            try {
+               Thread.sleep(100);
+            }
+            catch (Exception e) {
+               break;
+            }
+         }
+         serverSessions.clear();
+         for (ServerSession session : server.getSessions()) {
+            if (session.getMetaData(parameter) != null) {
+               serverSessions.add(session);
+            }
+         }
+      } while (running.get() && serverSessions.size() != numberOfSessions &&
timeout > System.currentTimeMillis());
+
+      System.err.println("Returning " + serverSessions.size() + " sessions");
       return serverSessions;
    }
 
@@ -347,7 +398,6 @@ public class MDBMultipleHandlersServerDisconnectTest extends ActiveMQRATestBase
          isDeliveryTransacted = deliveryTransacted;
       }
 
-      @Override
       public MessageEndpoint createEndpoint(XAResource xaResource) throws UnavailableException
{
          TestEndpoint retEnd = new TestEndpoint();
          if (xaResource != null) {
@@ -356,7 +406,6 @@ public class MDBMultipleHandlersServerDisconnectTest extends ActiveMQRATestBase
          return retEnd;
       }
 
-      @Override
       public boolean isDeliveryTransacted(Method method) throws NoSuchMethodException {
          return isDeliveryTransacted;
       }
@@ -397,7 +446,6 @@ public class MDBMultipleHandlersServerDisconnectTest extends ActiveMQRATestBase
 
       }
 
-      @Override
       public void onMessage(Message message) {
          Integer value = 0;
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/af1f79bf/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeReconnectTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeReconnectTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeReconnectTest.java
index e937b26..03a1b6d 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeReconnectTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeReconnectTest.java
@@ -680,6 +680,10 @@ public class BridgeReconnectTest extends BridgeTestBase {
          }
       }
 
+      for (int i = 0; i < 100 && queue.getDeliveringCount() != 0; i++) {
+         Thread.sleep(10);
+      }
+
       System.out.println("Check.. DeliveringCount: " + queue.getDeliveringCount());
       assertEquals("Delivering count of a source queue should be zero on connection failure",
0, queue.getDeliveringCount());
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/af1f79bf/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/AsynchronousFailoverTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/AsynchronousFailoverTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/AsynchronousFailoverTest.java
index f7a6d25..d21bd84 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/AsynchronousFailoverTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/AsynchronousFailoverTest.java
@@ -18,6 +18,7 @@ package org.apache.activemq.artemis.tests.integration.cluster.failover;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.activemq.artemis.api.core.ActiveMQDuplicateIdException;
 import org.apache.activemq.artemis.api.core.ActiveMQException;
@@ -185,7 +186,12 @@ public class AsynchronousFailoverTest extends FailoverTestBase {
 
                AsynchronousFailoverTest.log.info("Fail complete");
 
-               t.join();
+               t.join(TimeUnit.SECONDS.toMillis(20));
+               if (t.isAlive()) {
+                  System.out.println(threadDump("Thread still running from the test"));
+                  t.interrupt();
+                  fail("Test didn't complete successful, thread still running");
+               }
 
                runnable.checkForExceptions();
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/af1f79bf/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ResourceAdapterTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ResourceAdapterTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ResourceAdapterTest.java
index 272214b..aea899c 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ResourceAdapterTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ResourceAdapterTest.java
@@ -16,13 +16,21 @@
  */
 package org.apache.activemq.artemis.tests.integration.ra;
 
+import javax.jms.Connection;
+import javax.resource.ResourceException;
+import javax.resource.spi.endpoint.MessageEndpoint;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.CountDownLatch;
+
 import org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration;
 import org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory;
 import org.apache.activemq.artemis.api.core.client.ClientSession;
 import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
 import org.apache.activemq.artemis.api.core.client.ServerLocator;
 import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
-import org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryInternal;
 import org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl;
 import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
 import org.apache.activemq.artemis.jms.client.ActiveMQDestination;
@@ -35,16 +43,6 @@ import org.apache.activemq.artemis.tests.unit.ra.MessageEndpointFactory;
 import org.apache.activemq.artemis.utils.DefaultSensitiveStringCodec;
 import org.junit.Test;
 
-import javax.jms.Connection;
-import javax.resource.ResourceException;
-import javax.resource.spi.endpoint.MessageEndpoint;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.CountDownLatch;
-
 public class ResourceAdapterTest extends ActiveMQRATestBase {
 
    @Test
@@ -86,29 +84,17 @@ public class ResourceAdapterTest extends ActiveMQRATestBase {
 
       ServerLocatorImpl serverLocator = (ServerLocatorImpl) ra.getDefaultActiveMQConnectionFactory().getServerLocator();
 
-      Field f = Class.forName(ServerLocatorImpl.class.getName()).getDeclaredField("factories");
-
       Set<XARecoveryConfig> resources = ra.getRecoveryManager().getResources();
 
-      f.setAccessible(true);
-
-      Set<ClientSessionFactoryInternal> factories = (Set<ClientSessionFactoryInternal>)
f.get(serverLocator);
-
       for (int i = 0; i < 10; i++) {
          System.out.println(i);
-         assertEquals(factories.size(), 0);
          activation.start();
-         assertEquals(factories.size(), 15);
          assertEquals(1, resources.size());
          activation.stop();
-         assertEquals(factories.size(), 0);
       }
 
-      System.out.println("before RA stop => " + factories.size());
       ra.stop();
       assertEquals(0, resources.size());
-      System.out.println("after RA stop => " + factories.size());
-      assertEquals(factories.size(), 0);
       locator.close();
 
    }
@@ -402,7 +388,7 @@ public class ResourceAdapterTest extends ActiveMQRATestBase {
       spec.setUseJNDI(false);
       spec.setDestinationType("javax.jms.Queue");
       spec.setDestination(MDBQUEUE);
-      ActiveMQConnectionFactory fac = qResourceAdapter.createActiveMQConnectionFactory(spec);
+      ActiveMQConnectionFactory fac = qResourceAdapter.getConnectionFactory(spec);
       DiscoveryGroupConfiguration dc = fac.getServerLocator().getDiscoveryGroupConfiguration();
       UDPBroadcastEndpointFactory udpDg = (UDPBroadcastEndpointFactory) dc.getBroadcastEndpointFactory();
       assertEquals(udpDg.getGroupAddress(), "231.6.6.6");
@@ -430,7 +416,7 @@ public class ResourceAdapterTest extends ActiveMQRATestBase {
       spec.setDiscoveryPort(1234);
       spec.setDiscoveryInitialWaitTimeout(1L);
       spec.setDiscoveryRefreshTimeout(1L);
-      ActiveMQConnectionFactory fac = qResourceAdapter.createActiveMQConnectionFactory(spec);
+      ActiveMQConnectionFactory fac = qResourceAdapter.getConnectionFactory(spec);
       DiscoveryGroupConfiguration dc = fac.getServerLocator().getDiscoveryGroupConfiguration();
       UDPBroadcastEndpointFactory udpDg = (UDPBroadcastEndpointFactory) dc.getBroadcastEndpointFactory();
       assertEquals(udpDg.getGroupAddress(), "231.6.6.6");
@@ -455,7 +441,7 @@ public class ResourceAdapterTest extends ActiveMQRATestBase {
       spec.setDestinationType("javax.jms.Queue");
       spec.setDestination(MDBQUEUE);
 
-      ActiveMQConnectionFactory fac = qResourceAdapter.createActiveMQConnectionFactory(spec);
+      ActiveMQConnectionFactory fac = qResourceAdapter.getConnectionFactory(spec);
 
       assertTrue(fac.isHA());
 
@@ -477,7 +463,7 @@ public class ResourceAdapterTest extends ActiveMQRATestBase {
       spec.setDestinationType("javax.jms.Queue");
       spec.setDestination(MDBQUEUE);
 
-      ActiveMQConnectionFactory fac = qResourceAdapter.createActiveMQConnectionFactory(spec);
+      ActiveMQConnectionFactory fac = qResourceAdapter.getConnectionFactory(spec);
 
       assertFalse(fac.isHA());
 
@@ -499,7 +485,7 @@ public class ResourceAdapterTest extends ActiveMQRATestBase {
       spec.setDestinationType("javax.jms.Queue");
       spec.setDestination(MDBQUEUE);
       spec.setHA(true);
-      ActiveMQConnectionFactory fac = qResourceAdapter.createActiveMQConnectionFactory(spec);
+      ActiveMQConnectionFactory fac = qResourceAdapter.getConnectionFactory(spec);
 
       assertTrue(fac.isHA());
 
@@ -522,7 +508,7 @@ public class ResourceAdapterTest extends ActiveMQRATestBase {
       spec.setDestinationType("javax.jms.Queue");
       spec.setDestination(MDBQUEUE);
 
-      ActiveMQConnectionFactory fac = qResourceAdapter.createActiveMQConnectionFactory(spec);
+      ActiveMQConnectionFactory fac = qResourceAdapter.getConnectionFactory(spec);
 
       assertEquals(100, fac.getReconnectAttempts());
 
@@ -544,7 +530,7 @@ public class ResourceAdapterTest extends ActiveMQRATestBase {
       spec.setDestinationType("javax.jms.Queue");
       spec.setDestination(MDBQUEUE);
 
-      ActiveMQConnectionFactory fac = qResourceAdapter.createActiveMQConnectionFactory(spec);
+      ActiveMQConnectionFactory fac = qResourceAdapter.getConnectionFactory(spec);
 
       assertEquals(-1, fac.getReconnectAttempts());
 
@@ -566,7 +552,7 @@ public class ResourceAdapterTest extends ActiveMQRATestBase {
       spec.setDestinationType("javax.jms.Queue");
       spec.setDestination(MDBQUEUE);
       spec.setReconnectAttempts(100);
-      ActiveMQConnectionFactory fac = qResourceAdapter.createActiveMQConnectionFactory(spec);
+      ActiveMQConnectionFactory fac = qResourceAdapter.getConnectionFactory(spec);
 
       assertEquals(100, fac.getReconnectAttempts());
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/af1f79bf/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/xa/BasicXaRecoveryTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/xa/BasicXaRecoveryTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/xa/BasicXaRecoveryTest.java
index 6cb6d0b..61069ac 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/xa/BasicXaRecoveryTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/xa/BasicXaRecoveryTest.java
@@ -381,6 +381,9 @@ public class BasicXaRecoveryTest extends ActiveMQTestBase {
       else {
          clientSession.rollback(xid);
       }
+
+      xids = clientSession.recover(XAResource.TMSTARTRSCAN);
+      Assert.assertEquals(xids.length, 0);
    }
 
    @Test

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/af1f79bf/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/ra/ResourceAdapterTest.java
----------------------------------------------------------------------
diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/ra/ResourceAdapterTest.java
b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/ra/ResourceAdapterTest.java
index 8261249..3932f75 100644
--- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/ra/ResourceAdapterTest.java
+++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/ra/ResourceAdapterTest.java
@@ -24,22 +24,22 @@ import java.util.Map;
 import org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration;
 import org.apache.activemq.artemis.api.core.TransportConfiguration;
 import org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory;
+import org.apache.activemq.artemis.api.core.client.ActiveMQClient;
 import org.apache.activemq.artemis.api.core.client.ClientSession;
 import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
-import org.apache.activemq.artemis.api.core.client.ActiveMQClient;
 import org.apache.activemq.artemis.api.core.client.ServerLocator;
 import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
-import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
 import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory;
 import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory;
 import org.apache.activemq.artemis.core.server.ActiveMQServer;
 import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
 import org.apache.activemq.artemis.jms.client.ActiveMQDestination;
-import org.apache.activemq.artemis.ra.ConnectionFactoryProperties;
 import org.apache.activemq.artemis.ra.ActiveMQRAManagedConnectionFactory;
 import org.apache.activemq.artemis.ra.ActiveMQResourceAdapter;
+import org.apache.activemq.artemis.ra.ConnectionFactoryProperties;
 import org.apache.activemq.artemis.ra.inflow.ActiveMQActivation;
 import org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec;
+import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -99,7 +99,7 @@ public class ResourceAdapterTest extends ActiveMQTestBase {
    public void testCreateConnectionFactoryNoOverrides() throws Exception {
       ActiveMQResourceAdapter ra = new ActiveMQResourceAdapter();
       ra.setConnectorClassName(InVMConnectorFactory.class.getName());
-      ActiveMQConnectionFactory factory = ra.createActiveMQConnectionFactory(new ConnectionFactoryProperties());
+      ActiveMQConnectionFactory factory = ra.getConnectionFactory(new ConnectionFactoryProperties());
       Assert.assertEquals(factory.getCallTimeout(), ActiveMQClient.DEFAULT_CALL_TIMEOUT);
       Assert.assertEquals(factory.getClientFailureCheckPeriod(), ActiveMQClient.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD);
       Assert.assertEquals(factory.getClientID(), null);
@@ -211,7 +211,7 @@ public class ResourceAdapterTest extends ActiveMQTestBase {
       connectionFactoryProperties.setThreadPoolMaxSize(17);
       connectionFactoryProperties.setTransactionBatchSize(18);
       connectionFactoryProperties.setUseGlobalPools(!ActiveMQClient.DEFAULT_USE_GLOBAL_POOLS);
-      ActiveMQConnectionFactory factory = ra.createActiveMQConnectionFactory(connectionFactoryProperties);
+      ActiveMQConnectionFactory factory = ra.getConnectionFactory(connectionFactoryProperties);
       Assert.assertEquals(factory.getCallTimeout(), 1);
       Assert.assertEquals(factory.getClientFailureCheckPeriod(), 2);
       Assert.assertEquals(factory.getClientID(), "myid");
@@ -245,7 +245,7 @@ public class ResourceAdapterTest extends ActiveMQTestBase {
       ArrayList<String> value = new ArrayList<>();
       value.add(NettyConnectorFactory.class.getName());
       connectionFactoryProperties.setParsedConnectorClassNames(value);
-      ActiveMQConnectionFactory factory = ra.createActiveMQConnectionFactory(connectionFactoryProperties);
+      ActiveMQConnectionFactory factory = ra.getConnectionFactory(connectionFactoryProperties);
       ActiveMQConnectionFactory defaultFactory = ra.getDefaultActiveMQConnectionFactory();
       Assert.assertNotSame(factory, defaultFactory);
    }
@@ -258,7 +258,7 @@ public class ResourceAdapterTest extends ActiveMQTestBase {
       connectionFactoryProperties.setDiscoveryAddress("myhost");
       connectionFactoryProperties.setDiscoveryPort(5678);
       connectionFactoryProperties.setDiscoveryLocalBindAddress("newAddress");
-      ActiveMQConnectionFactory factory = ra.createActiveMQConnectionFactory(connectionFactoryProperties);
+      ActiveMQConnectionFactory factory = ra.getConnectionFactory(connectionFactoryProperties);
       ActiveMQConnectionFactory defaultFactory = ra.getDefaultActiveMQConnectionFactory();
       Assert.assertNotSame(factory, defaultFactory);
       DiscoveryGroupConfiguration dc = factory.getServerLocator().getDiscoveryGroupConfiguration();
@@ -272,7 +272,7 @@ public class ResourceAdapterTest extends ActiveMQTestBase {
    public void testCreateConnectionFactoryMultipleConnectors() {
       ActiveMQResourceAdapter ra = new ActiveMQResourceAdapter();
       ra.setConnectorClassName(NETTY_CONNECTOR_FACTORY + "," + INVM_CONNECTOR_FACTORY + ","
+ NETTY_CONNECTOR_FACTORY);
-      ActiveMQConnectionFactory factory = ra.createActiveMQConnectionFactory(new ConnectionFactoryProperties());
+      ActiveMQConnectionFactory factory = ra.getConnectionFactory(new ConnectionFactoryProperties());
       TransportConfiguration[] configurations = factory.getServerLocator().getStaticTransportConfigurations();
       assertNotNull(configurations);
       assertEquals(3, configurations.length);
@@ -289,7 +289,7 @@ public class ResourceAdapterTest extends ActiveMQTestBase {
       ActiveMQResourceAdapter ra = new ActiveMQResourceAdapter();
       ra.setConnectorClassName(NETTY_CONNECTOR_FACTORY + "," + INVM_CONNECTOR_FACTORY + ","
+ NETTY_CONNECTOR_FACTORY);
       ra.setConnectionParameters("host=host1;port=61616, serverid=0, host=host2;port=61617");
-      ActiveMQConnectionFactory factory = ra.createActiveMQConnectionFactory(new ConnectionFactoryProperties());
+      ActiveMQConnectionFactory factory = ra.getConnectionFactory(new ConnectionFactoryProperties());
       TransportConfiguration[] configurations = factory.getServerLocator().getStaticTransportConfigurations();
       assertNotNull(configurations);
       assertEquals(3, configurations.length);
@@ -316,7 +316,7 @@ public class ResourceAdapterTest extends ActiveMQTestBase {
       value.add(NETTY_CONNECTOR_FACTORY);
       value.add(INVM_CONNECTOR_FACTORY);
       overrideProperties.setParsedConnectorClassNames(value);
-      ActiveMQConnectionFactory factory = ra.createActiveMQConnectionFactory(overrideProperties);
+      ActiveMQConnectionFactory factory = ra.getConnectionFactory(overrideProperties);
       TransportConfiguration[] configurations = factory.getServerLocator().getStaticTransportConfigurations();
       assertNotNull(configurations);
       assertEquals(3, configurations.length);
@@ -351,7 +351,7 @@ public class ResourceAdapterTest extends ActiveMQTestBase {
       map3.put("serverid", "1");
       connectionParameters.add(map3);
       overrideProperties.setParsedConnectionParameters(connectionParameters);
-      ActiveMQConnectionFactory factory = ra.createActiveMQConnectionFactory(overrideProperties);
+      ActiveMQConnectionFactory factory = ra.getConnectionFactory(overrideProperties);
       TransportConfiguration[] configurations = factory.getServerLocator().getStaticTransportConfigurations();
       assertNotNull(configurations);
       assertEquals(3, configurations.length);
@@ -372,7 +372,7 @@ public class ResourceAdapterTest extends ActiveMQTestBase {
       ActiveMQResourceAdapter ra = new ActiveMQResourceAdapter();
       ConnectionFactoryProperties connectionFactoryProperties = new ConnectionFactoryProperties();
       try {
-         ra.createActiveMQConnectionFactory(connectionFactoryProperties);
+         ra.getConnectionFactory(connectionFactoryProperties);
          Assert.fail("should throw exception");
       }
       catch (IllegalArgumentException e) {


Mime
View raw message