You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2022/08/16 15:23:04 UTC
[camel] branch main updated (5a5e091fa10 -> 8bcb2f5f043)
This is an automated email from the ASF dual-hosted git repository.
orpiske pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
from 5a5e091fa10 Convert non-persistent JMS tests to the test infra
new 49af0f8ddce (chores) camel-test-infra-activemq: cleanups
new 8bcb2f5f043 (chores) camel-test-infra-activemq: rename a few methods to give more clarity
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../camel/component/jms/AbstractJMSTest.java | 2 +-
.../jms/JmsProducerWithJMSHeaderTest.java | 2 +-
...e.java => AbstractActiveMQEmbeddedService.java} | 41 +++---
.../activemq/services/ActiveMQEmbeddedService.java | 154 ++-------------------
.../services/ActiveMQEmbeddedServiceBuilder.java | 14 --
.../activemq/services/ActiveMQServiceFactory.java | 16 +--
.../infra/activemq/services/ActiveMQVMService.java | 143 ++-----------------
7 files changed, 51 insertions(+), 321 deletions(-)
copy test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/{ActiveMQVMService.java => AbstractActiveMQEmbeddedService.java} (83%)
[camel] 02/02: (chores) camel-test-infra-activemq: rename a few methods to give more clarity
Posted by or...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 8bcb2f5f0436a975b6d8250b842aaa4ea12785e3
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Tue Aug 16 15:51:45 2022 +0200
(chores) camel-test-infra-activemq: rename a few methods to give more clarity
---
.../org/apache/camel/component/jms/AbstractJMSTest.java | 2 +-
.../component/jms/JmsProducerWithJMSHeaderTest.java | 2 +-
.../infra/activemq/services/ActiveMQServiceFactory.java | 16 +++++-----------
3 files changed, 7 insertions(+), 13 deletions(-)
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/AbstractJMSTest.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/AbstractJMSTest.java
index f99690b72e6..43c7f569e44 100644
--- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/AbstractJMSTest.java
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/AbstractJMSTest.java
@@ -29,7 +29,7 @@ import org.junit.jupiter.api.extension.RegisterExtension;
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public abstract class AbstractJMSTest extends CamelTestSupport {
@RegisterExtension
- public static ActiveMQService service = ActiveMQServiceFactory.createEmbeddedService();
+ public static ActiveMQService service = ActiveMQServiceFactory.createVMService();
public static String queueNameForClass(String desiredName, Class<?> requestingClass) {
return desiredName + "." + requestingClass.getSimpleName();
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsProducerWithJMSHeaderTest.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsProducerWithJMSHeaderTest.java
index bbdb75aad16..b71ebe358dd 100644
--- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsProducerWithJMSHeaderTest.java
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsProducerWithJMSHeaderTest.java
@@ -46,7 +46,7 @@ public class JmsProducerWithJMSHeaderTest extends CamelTestSupport {
// This one needs a different lifecycle, so we cannot extend AbstractJMSTest
@RegisterExtension
- private ActiveMQService service = ActiveMQServiceFactory.createEmbeddedService();
+ private ActiveMQService service = ActiveMQServiceFactory.createVMService();
@Test
public void testInOnlyJMSPrioritory() throws Exception {
diff --git a/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/ActiveMQServiceFactory.java b/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/ActiveMQServiceFactory.java
index 89c898069db..bddb725c436 100644
--- a/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/ActiveMQServiceFactory.java
+++ b/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/ActiveMQServiceFactory.java
@@ -81,11 +81,11 @@ public final class ActiveMQServiceFactory {
.build();
}
- public static synchronized ActiveMQService createEmbeddedService() {
- return createSingletonEmbeddedService();
+ public static synchronized ActiveMQService createVMService() {
+ return createSingletonVMService();
}
- public static synchronized ActiveMQService createEmbeddedServiceInstance() {
+ public static synchronized ActiveMQService createVMServiceInstance() {
if (service == null) {
if (instance == null) {
instance = new SimpleTestServiceBuilder<>("activemq");
@@ -97,15 +97,9 @@ public final class ActiveMQServiceFactory {
return instance.build();
}
- public static synchronized ActiveMQService createSingletonEmbeddedService() {
+ public static synchronized ActiveMQService createSingletonVMService() {
if (service == null) {
- if (instance == null) {
- instance = new SimpleTestServiceBuilder<>("activemq");
-
- instance.addLocalMapping(() -> new SingletonActiveMQService(new ActiveMQVMService(), "activemq"));
- }
-
- service = instance.build();
+ service = createVMServiceInstance();
}
return service;
[camel] 01/02: (chores) camel-test-infra-activemq: cleanups
Posted by or...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 49af0f8ddce5a69ff73320753946c81a6463c91f
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Tue Aug 16 14:20:58 2022 +0200
(chores) camel-test-infra-activemq: cleanups
- Remove duplicated code for the embedded activeMQ
- Remove commented code
- Cleanup the initialization of embedded broker services
---
...e.java => AbstractActiveMQEmbeddedService.java} | 41 +++---
.../activemq/services/ActiveMQEmbeddedService.java | 154 ++-------------------
.../services/ActiveMQEmbeddedServiceBuilder.java | 14 --
.../infra/activemq/services/ActiveMQVMService.java | 143 ++-----------------
4 files changed, 44 insertions(+), 308 deletions(-)
diff --git a/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/ActiveMQVMService.java b/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/AbstractActiveMQEmbeddedService.java
similarity index 83%
copy from test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/ActiveMQVMService.java
copy to test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/AbstractActiveMQEmbeddedService.java
index 037d6e5b7de..c7a9979bc59 100644
--- a/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/ActiveMQVMService.java
+++ b/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/AbstractActiveMQEmbeddedService.java
@@ -35,21 +35,21 @@ import org.slf4j.LoggerFactory;
import static org.junit.jupiter.api.Assertions.fail;
-public class ActiveMQVMService implements ActiveMQService, ConnectionFactoryAware, BeforeEachCallback, AfterEachCallback {
- private static final Logger LOG = LoggerFactory.getLogger(ActiveMQVMService.class);
+public abstract class AbstractActiveMQEmbeddedService
+ implements ActiveMQService, ConnectionFactoryAware, BeforeEachCallback, AfterEachCallback {
+ private static final Logger LOG = LoggerFactory.getLogger(AbstractActiveMQEmbeddedService.class);
private final BrokerService brokerService;
private final boolean recycle;
- public ActiveMQVMService() {
+ public AbstractActiveMQEmbeddedService() {
this(ActiveMQEmbeddedServiceBuilder.defaultBroker().brokerService());
}
- public ActiveMQVMService(BrokerService brokerService) {
- this.brokerService = brokerService;
- this.recycle = false;
+ public AbstractActiveMQEmbeddedService(BrokerService brokerService) {
+ this(brokerService, false);
}
- public ActiveMQVMService(BrokerService brokerService, boolean recycle) {
+ public AbstractActiveMQEmbeddedService(BrokerService brokerService, boolean recycle) {
this.brokerService = brokerService;
this.recycle = recycle;
}
@@ -93,11 +93,6 @@ public class ActiveMQVMService implements ActiveMQService, ConnectionFactoryAwar
}
}
- @Override
- public String serviceAddress() {
- return getVmURL();
- }
-
@Override
public String userName() {
return null;
@@ -116,6 +111,10 @@ public class ActiveMQVMService implements ActiveMQService, ConnectionFactoryAwar
return brokerService;
}
+ protected String getBrokerUri(int connector) {
+ return getBrokerUri(brokerService, connector);
+ }
+
public static String getBrokerUri(BrokerService broker, int connector) {
try {
return broker.getTransportConnectors().get(connector).getPublishableConnectString();
@@ -135,7 +134,7 @@ public class ActiveMQVMService implements ActiveMQService, ConnectionFactoryAwar
}
@Override
- public void afterEach(ExtensionContext extensionContext) throws Exception {
+ public void afterEach(ExtensionContext extensionContext) {
if (recycle) {
shutdown();
}
@@ -143,20 +142,20 @@ public class ActiveMQVMService implements ActiveMQService, ConnectionFactoryAwar
}
@Override
- public void beforeEach(ExtensionContext extensionContext) throws Exception {
+ public void beforeEach(ExtensionContext extensionContext) {
if (recycle) {
initialize();
}
}
- public String getVmURL() {
- return getVmURL(true);
- }
+ public abstract String getVmURL();
+
+ public abstract String getVmURL(boolean create);
- public String getVmURL(boolean failoverURL) {
+ protected String getVmURL(boolean failoverURL, boolean create) {
return failoverURL
- ? String.format("failover:(%s?create=true)", brokerService.getVmConnectorURI().toString())
- : this.brokerService.getVmConnectorURI().toString() + "?create=true";
+ ? String.format("failover:(%s?create=%b)", brokerService.getVmConnectorURI().toString(), create)
+ : this.brokerService.getVmConnectorURI().toString() + "?create=" + create;
}
public DestinationViewMBean getQueueMBean(String queueName) throws MalformedObjectNameException {
@@ -180,6 +179,6 @@ public class ActiveMQVMService implements ActiveMQService, ConnectionFactoryAwar
@Deprecated
public ConnectionFactory createConnectionFactory(Integer maximumRedeliveries) {
- return ConnectionFactoryHelper.createConnectionFactory(getVmURL(), maximumRedeliveries);
+ return ConnectionFactoryHelper.createConnectionFactory(getVmURL(true), maximumRedeliveries);
}
}
diff --git a/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/ActiveMQEmbeddedService.java b/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/ActiveMQEmbeddedService.java
index 70ccc2129e9..f624742a6ca 100644
--- a/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/ActiveMQEmbeddedService.java
+++ b/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/ActiveMQEmbeddedService.java
@@ -17,171 +17,39 @@
package org.apache.camel.test.infra.activemq.services;
-import java.io.IOException;
-import java.net.URISyntaxException;
-
-import javax.jms.ConnectionFactory;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.jmx.DestinationViewMBean;
-import org.apache.camel.test.infra.activemq.common.ConnectionFactoryHelper;
-import org.junit.jupiter.api.extension.AfterEachCallback;
-import org.junit.jupiter.api.extension.BeforeEachCallback;
-import org.junit.jupiter.api.extension.ExtensionContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.junit.jupiter.api.Assertions.fail;
-
-public class ActiveMQEmbeddedService implements ActiveMQService, ConnectionFactoryAware, BeforeEachCallback, AfterEachCallback {
+/**
+ * A regular embedded broker that uses the standard transport protocols (i.e.: AMQP, OpenWire, etc)
+ */
+public class ActiveMQEmbeddedService extends AbstractActiveMQEmbeddedService {
private static final Logger LOG = LoggerFactory.getLogger(ActiveMQEmbeddedService.class);
- private final BrokerService brokerService;
- private final boolean recycle;
public ActiveMQEmbeddedService() {
this(ActiveMQEmbeddedServiceBuilder.defaultBroker().brokerService());
}
public ActiveMQEmbeddedService(BrokerService brokerService) {
- this.brokerService = brokerService;
- this.recycle = false;
+ this(brokerService, false);
}
public ActiveMQEmbeddedService(BrokerService brokerService, boolean recycle) {
- this.brokerService = brokerService;
- this.recycle = recycle;
- }
-
- @Override
- public void initialize() {
- LOG.info("Trying to start the embedded ActiveMQ");
- try {
- brokerService.start();
- brokerService.waitUntilStarted();
- LOG.info("Embedded ActiveMQ running at {}", serviceAddress());
- } catch (Exception e) {
- LOG.warn("Unable to start embedded ActiveMQ broker: {}", e.getMessage(), e);
- fail(e.getMessage());
- }
- }
-
- @Override
- public void shutdown() {
- LOG.debug("Trying to stop the embedded ActiveMQ");
- try {
- brokerService.stop();
- brokerService.waitUntilStopped();
- LOG.debug("Embedded ActiveMQ stopped");
- } catch (Exception e) {
- LOG.warn("Error stopping embedded ActiveMQ broker: {}", e.getMessage(), e);
- }
+ super(brokerService, recycle);
}
- public void restart() {
- shutdown();
-
- LOG.info("Trying to start the restart ActiveMQ");
- try {
- brokerService.start(true);
- brokerService.waitUntilStarted();
- LOG.info("Embedded ActiveMQ running at {}", serviceAddress());
- } catch (Exception e) {
- LOG.warn("Unable to start embedded ActiveMQ broker: {}", e.getMessage(), e);
- fail(e.getMessage());
- }
- }
-
- @Override
- public String serviceAddress() {
- return getBrokerUri(brokerService, 0);
- }
-
- @Override
- public String userName() {
- return null;
+ public String getVmURL() {
+ return getVmURL(true, false);
}
@Override
- public String password() {
+ public String getVmURL(boolean create) {
return null;
}
- public int getConnectionCount() {
- return brokerService.getTransportConnectors().get(0).getConnections().size();
- }
-
- public BrokerService getBrokerService() {
- return brokerService;
- }
-
- public static String getBrokerUri(BrokerService broker, int connector) {
- try {
- return broker.getTransportConnectors().get(connector).getPublishableConnectString();
- } catch (Exception e) {
- LOG.warn("Unable to get ActiveMQ broker address: {}", e.getMessage(), e);
- return null;
- }
- }
-
- public int getPort() {
- try {
- return brokerService.getTransportConnectors().get(0).getServer().getSocketAddress().getPort();
- } catch (URISyntaxException | IOException e) {
- LOG.error("Error getting the port: {}", e.getMessage());
- throw new RuntimeException("Error getting the port", e);
- }
- }
-
- @Override
- public void afterEach(ExtensionContext extensionContext) throws Exception {
- if (recycle) {
- shutdown();
- }
-
- }
-
@Override
- public void beforeEach(ExtensionContext extensionContext) throws Exception {
- if (recycle) {
- initialize();
- }
- }
-
- public String getVmURL() {
- return getVmURL(true);
- }
-
- public String getVmURL(boolean failoverURL) {
- return failoverURL
- ? String.format("failover:(%s?create=false)", brokerService.getVmConnectorURI().toString())
- : this.brokerService.getVmConnectorURI().toString() + "?create=false";
- }
-
- public DestinationViewMBean getQueueMBean(String queueName) throws MalformedObjectNameException {
- return getDestinationMBean(queueName, false);
- }
-
- public DestinationViewMBean getDestinationMBean(String destinationName, boolean topic) throws MalformedObjectNameException {
- String domain = "org.apache.activemq";
- String destinationType = topic ? "Topic" : "Queue";
- ObjectName name = new ObjectName(
- String.format("%s:type=Broker,brokerName=localhost,destinationType=%s,destinationName=%s",
- domain, destinationType, destinationName));
- return (DestinationViewMBean) brokerService.getManagementContext().newProxyInstance(name,
- DestinationViewMBean.class, true);
- }
-
- @Deprecated
- public ConnectionFactory createConnectionFactory() {
- return createConnectionFactory(null);
- }
-
- @Deprecated
- public ConnectionFactory createConnectionFactory(Integer maximumRedeliveries) {
- ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(getVmURL());
- return ConnectionFactoryHelper.createConnectionFactory(connectionFactory, maximumRedeliveries);
+ public String serviceAddress() {
+ return getBrokerUri(0);
}
}
diff --git a/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/ActiveMQEmbeddedServiceBuilder.java b/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/ActiveMQEmbeddedServiceBuilder.java
index dcf6139a403..25aa2af28e0 100644
--- a/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/ActiveMQEmbeddedServiceBuilder.java
+++ b/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/ActiveMQEmbeddedServiceBuilder.java
@@ -603,20 +603,6 @@ public class ActiveMQEmbeddedServiceBuilder {
return defaultBroker(ActiveMQEmbeddedServiceBuilder.class.getSimpleName());
}
- /*
- public static ConnectionFactory createPersistentConnectionFactory(String options) {
- String url = createPersistentBrokerUrl(options);
- ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
- // optimize AMQ to be as fast as possible so unit testing is quicker
- connectionFactory.setCopyMessageOnSend(false);
- connectionFactory.setOptimizeAcknowledge(true);
- connectionFactory.setOptimizedMessageDispatch(true);
- connectionFactory.setAlwaysSessionAsync(false);
- connectionFactory.setTrustAllPackages(true);
- return connectionFactory;
- }
- */
-
public static ActiveMQEmbeddedServiceBuilder defaultBroker(String name) {
return new ActiveMQEmbeddedServiceBuilder()
.withDeleteAllMessagesOnStartup(true)
diff --git a/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/ActiveMQVMService.java b/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/ActiveMQVMService.java
index 037d6e5b7de..3924d35174f 100644
--- a/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/ActiveMQVMService.java
+++ b/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/ActiveMQVMService.java
@@ -17,85 +17,43 @@
package org.apache.camel.test.infra.activemq.services;
-import java.io.IOException;
-import java.net.URISyntaxException;
-
-import javax.jms.ConnectionFactory;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.jmx.DestinationViewMBean;
-import org.apache.camel.test.infra.activemq.common.ConnectionFactoryHelper;
-import org.junit.jupiter.api.extension.AfterEachCallback;
-import org.junit.jupiter.api.extension.BeforeEachCallback;
-import org.junit.jupiter.api.extension.ExtensionContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.junit.jupiter.api.Assertions.fail;
-
-public class ActiveMQVMService implements ActiveMQService, ConnectionFactoryAware, BeforeEachCallback, AfterEachCallback {
+/**
+ * An embedded broker that relies on the VM transport for communication.
+ *
+ * @see <a href="https://activemq.apache.org/vm-transport-reference">VM Transport Reference</a>
+ */
+public class ActiveMQVMService extends AbstractActiveMQEmbeddedService {
private static final Logger LOG = LoggerFactory.getLogger(ActiveMQVMService.class);
- private final BrokerService brokerService;
- private final boolean recycle;
public ActiveMQVMService() {
this(ActiveMQEmbeddedServiceBuilder.defaultBroker().brokerService());
}
public ActiveMQVMService(BrokerService brokerService) {
- this.brokerService = brokerService;
- this.recycle = false;
+ this(brokerService, true);
}
public ActiveMQVMService(BrokerService brokerService, boolean recycle) {
- this.brokerService = brokerService;
- this.recycle = recycle;
+ super(brokerService, recycle);
}
@Override
- public void initialize() {
- LOG.info("Trying to start the embedded ActiveMQ");
- try {
- brokerService.start();
- brokerService.waitUntilStarted();
- LOG.info("Embedded ActiveMQ running at {}", serviceAddress());
- } catch (Exception e) {
- LOG.warn("Unable to start embedded ActiveMQ broker: {}", e.getMessage(), e);
- fail(e.getMessage());
- }
+ public String getVmURL() {
+ return getVmURL(true);
}
@Override
- public void shutdown() {
- LOG.debug("Trying to stop the embedded ActiveMQ");
- try {
- brokerService.stop();
- brokerService.waitUntilStopped();
- LOG.debug("Embedded ActiveMQ stopped");
- } catch (Exception e) {
- LOG.warn("Error stopping embedded ActiveMQ broker: {}", e.getMessage(), e);
- }
- }
-
- public void restart() {
- shutdown();
-
- LOG.info("Trying to start the restart ActiveMQ");
- try {
- brokerService.start(true);
- brokerService.waitUntilStarted();
- LOG.info("Embedded ActiveMQ running at {}", serviceAddress());
- } catch (Exception e) {
- LOG.warn("Unable to start embedded ActiveMQ broker: {}", e.getMessage(), e);
- fail(e.getMessage());
- }
+ public String getVmURL(boolean create) {
+ return getVmURL(false, create);
}
@Override
public String serviceAddress() {
- return getVmURL();
+ return getVmURL(true);
}
@Override
@@ -107,79 +65,4 @@ public class ActiveMQVMService implements ActiveMQService, ConnectionFactoryAwar
public String password() {
return null;
}
-
- public int getConnectionCount() {
- return brokerService.getTransportConnectors().get(0).getConnections().size();
- }
-
- public BrokerService getBrokerService() {
- return brokerService;
- }
-
- public static String getBrokerUri(BrokerService broker, int connector) {
- try {
- return broker.getTransportConnectors().get(connector).getPublishableConnectString();
- } catch (Exception e) {
- LOG.warn("Unable to get ActiveMQ broker address: {}", e.getMessage(), e);
- return null;
- }
- }
-
- public int getPort() {
- try {
- return brokerService.getTransportConnectors().get(0).getServer().getSocketAddress().getPort();
- } catch (URISyntaxException | IOException e) {
- LOG.error("Error getting the port: {}", e.getMessage());
- throw new RuntimeException("Error getting the port", e);
- }
- }
-
- @Override
- public void afterEach(ExtensionContext extensionContext) throws Exception {
- if (recycle) {
- shutdown();
- }
-
- }
-
- @Override
- public void beforeEach(ExtensionContext extensionContext) throws Exception {
- if (recycle) {
- initialize();
- }
- }
-
- public String getVmURL() {
- return getVmURL(true);
- }
-
- public String getVmURL(boolean failoverURL) {
- return failoverURL
- ? String.format("failover:(%s?create=true)", brokerService.getVmConnectorURI().toString())
- : this.brokerService.getVmConnectorURI().toString() + "?create=true";
- }
-
- public DestinationViewMBean getQueueMBean(String queueName) throws MalformedObjectNameException {
- return getDestinationMBean(queueName, false);
- }
-
- public DestinationViewMBean getDestinationMBean(String destinationName, boolean topic) throws MalformedObjectNameException {
- String domain = "org.apache.activemq";
- String destinationType = topic ? "Topic" : "Queue";
- ObjectName name = new ObjectName(
- String.format("%s:type=Broker,brokerName=localhost,destinationType=%s,destinationName=%s",
- domain, destinationType, destinationName));
- return (DestinationViewMBean) brokerService.getManagementContext().newProxyInstance(name,
- DestinationViewMBean.class, true);
- }
-
- @Deprecated
- public ConnectionFactory createConnectionFactory() {
- return createConnectionFactory(null);
- }
-
- @Deprecated
- public ConnectionFactory createConnectionFactory(Integer maximumRedeliveries) {
- return ConnectionFactoryHelper.createConnectionFactory(getVmURL(), maximumRedeliveries);
- }
}