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
The following commit(s) were added to refs/heads/main by this push: new 9b45707dc8b CAMEL-18928: removed test-infra-activemq 9b45707dc8b is described below commit 9b45707dc8b5cbf0360cc7fd378ed5826fe63f24 Author: Otavio Rodolfo Piske <angusyo...@gmail.com> AuthorDate: Tue Jan 17 08:57:58 2023 +0100 CAMEL-18928: removed test-infra-activemq --- test-infra/camel-test-infra-activemq/pom.xml | 115 ---- .../src/main/resources/META-INF/MANIFEST.MF | 0 .../infra/activemq/common/ActiveMQProperties.java | 30 - .../activemq/common/ConnectionFactoryHelper.java | 86 --- .../services/AbstractActiveMQEmbeddedService.java | 160 ----- .../activemq/services/ActiveMQEmbeddedService.java | 51 -- .../services/ActiveMQEmbeddedServiceBuilder.java | 679 --------------------- .../services/ActiveMQPersistentVMService.java | 76 --- .../activemq/services/ActiveMQRemoteService.java | 52 -- .../infra/activemq/services/ActiveMQService.java | 68 --- .../activemq/services/ActiveMQServiceFactory.java | 180 ------ .../infra/activemq/services/ActiveMQVMService.java | 76 --- .../activemq/services/LegacyEmbeddedBroker.java | 58 -- test-infra/pom.xml | 1 - 14 files changed, 1632 deletions(-) diff --git a/test-infra/camel-test-infra-activemq/pom.xml b/test-infra/camel-test-infra-activemq/pom.xml deleted file mode 100644 index 71ecda45b19..00000000000 --- a/test-infra/camel-test-infra-activemq/pom.xml +++ /dev/null @@ -1,115 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <parent> - <artifactId>camel-test-infra-parent</artifactId> - <groupId>org.apache.camel</groupId> - <relativePath>../camel-test-infra-parent/pom.xml</relativePath> - <version>4.0.0-SNAPSHOT</version> - </parent> - - <modelVersion>4.0.0</modelVersion> - - <artifactId>camel-test-infra-activemq</artifactId> - <name>Camel :: Test Infra :: ActiveMQ</name> - - <dependencies> - <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-util</artifactId> - <version>${project.version}</version> - </dependency> - - <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-test-infra-common</artifactId> - <version>${project.version}</version> - <type>test-jar</type> - </dependency> - - <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-test-infra-messaging-common</artifactId> - <version>${project.version}</version> - <type>test-jar</type> - </dependency> - - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>activemq-broker</artifactId> - <version>${activemq-version}</version> - <type>test-jar</type> - </dependency> - - <dependency> - <groupId>commons-io</groupId> - <artifactId>commons-io</artifactId> - </dependency> - - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>activemq-broker</artifactId> - <version>${activemq-version}</version> - </dependency> - - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>activemq-jaas</artifactId> - <version>${activemq-version}</version> - </dependency> - - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>activemq-ra</artifactId> - <version>${activemq-version}</version> - </dependency> - - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>activemq-amqp</artifactId> - <version>${activemq-version}</version> - </dependency> - - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>activemq-mqtt</artifactId> - <version>${activemq-version}</version> - </dependency> - - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>activemq-stomp</artifactId> - <version>${activemq-version}</version> - </dependency> - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - </plugin> - </plugins> - </build> - - -</project> diff --git a/test-infra/camel-test-infra-activemq/src/main/resources/META-INF/MANIFEST.MF b/test-infra/camel-test-infra-activemq/src/main/resources/META-INF/MANIFEST.MF deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/common/ActiveMQProperties.java b/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/common/ActiveMQProperties.java deleted file mode 100644 index 0139fd72a26..00000000000 --- a/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/common/ActiveMQProperties.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.camel.test.infra.activemq.common; - -public final class ActiveMQProperties { - public static final String SERVICE_ADDRESS = "activemq.service.address"; - - public static final String AMQ_EXTERNAL = "amq.external"; - public static final String AMQ_USERNAME = "amq.username"; - public static final String AMQ_PASSWORD = "amq.password"; - - private ActiveMQProperties() { - - } -} diff --git a/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/common/ConnectionFactoryHelper.java b/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/common/ConnectionFactoryHelper.java deleted file mode 100644 index 7e9342917f5..00000000000 --- a/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/common/ConnectionFactoryHelper.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.camel.test.infra.activemq.common; - -import jakarta.jms.ConnectionFactory; - -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.camel.test.infra.activemq.services.AbstractActiveMQEmbeddedService; -import org.apache.camel.test.infra.activemq.services.ActiveMQService; -import org.apache.camel.test.infra.activemq.services.ActiveMQServiceFactory; -import org.apache.camel.test.infra.messaging.services.ConnectionFactoryAware; - -public final class ConnectionFactoryHelper { - private ConnectionFactoryHelper() { - } - - public static ConnectionFactory createConnectionFactory(ActiveMQService service) { - return createConnectionFactory(service, null); - } - - public static ConnectionFactory createConnectionFactory(ActiveMQService service, Integer maximumRedeliveries) { - if (service instanceof ConnectionFactoryAware) { - return createConnectionFactory(((AbstractActiveMQEmbeddedService) service).getVmURL(), maximumRedeliveries); - } - - if (service instanceof ActiveMQServiceFactory.SingletonActiveMQService) { - return createConnectionFactory(((ActiveMQServiceFactory.SingletonActiveMQService) service).getService(), - maximumRedeliveries); - } - - throw new UnsupportedOperationException("The test service does not implement ConnectionFactoryAware"); - } - - public static ConnectionFactory createConnectionFactory(String url, Integer maximumRedeliveries) { - return createConnectionFactory(new ActiveMQConnectionFactory(url), maximumRedeliveries); - } - - public static ConnectionFactory createConnectionFactory( - ActiveMQConnectionFactory connectionFactory, Integer maximumRedeliveries) { - // optimize AMQ to be as fast as possible so unit testing is quicker - connectionFactory.setCopyMessageOnSend(false); - connectionFactory.setOptimizeAcknowledge(true); - connectionFactory.setOptimizedMessageDispatch(true); - - // When using asyncSend, producers will not be guaranteed to send in the order we - // have in the tests (which may be confusing for queues) so we need this set to false. - // Another way of guaranteeing order is to use persistent messages or transactions. - connectionFactory.setUseAsyncSend(false); - connectionFactory.setAlwaysSessionAsync(false); - if (maximumRedeliveries != null) { - connectionFactory.getRedeliveryPolicy().setMaximumRedeliveries(maximumRedeliveries); - } - connectionFactory.setTrustAllPackages(true); - connectionFactory.setWatchTopicAdvisories(false); - return connectionFactory; - } - - public static ConnectionFactory createPersistentConnectionFactory(String url) { - return createPersistentConnectionFactory(new ActiveMQConnectionFactory(url)); - - } - - public static ConnectionFactory createPersistentConnectionFactory(ActiveMQConnectionFactory connectionFactory) { - connectionFactory.setCopyMessageOnSend(false); - connectionFactory.setOptimizeAcknowledge(true); - connectionFactory.setOptimizedMessageDispatch(true); - connectionFactory.setAlwaysSessionAsync(false); - connectionFactory.setTrustAllPackages(true); - return connectionFactory; - } -} diff --git a/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/AbstractActiveMQEmbeddedService.java b/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/AbstractActiveMQEmbeddedService.java deleted file mode 100644 index 3d123216b8c..00000000000 --- a/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/AbstractActiveMQEmbeddedService.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.camel.test.infra.activemq.services; - -import java.io.IOException; -import java.net.URISyntaxException; - -import jakarta.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.apache.camel.test.infra.messaging.services.ConnectionFactoryAware; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import static org.junit.jupiter.api.Assertions.fail; - -public abstract class AbstractActiveMQEmbeddedService implements ActiveMQService, ConnectionFactoryAware { - private static final Logger LOG = LoggerFactory.getLogger(AbstractActiveMQEmbeddedService.class); - private final BrokerService brokerService; - - public AbstractActiveMQEmbeddedService() { - this(ActiveMQEmbeddedServiceBuilder.defaultBroker().brokerService()); - } - - public AbstractActiveMQEmbeddedService(BrokerService brokerService) { - this.brokerService = brokerService; - } - - @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); - } - } - - 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 userName() { - return null; - } - - @Override - public String password() { - return null; - } - - public int getConnectionCount() { - return brokerService.getTransportConnectors().get(0).getConnections().size(); - } - - public BrokerService getBrokerService() { - 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(); - } 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); - } - } - - public abstract String getVmURL(); - - public abstract String getVmURL(boolean create); - - protected String getVmURL(boolean failoverURL, boolean create) { - return failoverURL - ? String.format("failover:(%s?create=%b)", brokerService.getVmConnectorURI().toString(), create) - : this.brokerService.getVmConnectorURI().toString() + "?create=" + create; - } - - 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(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 deleted file mode 100644 index 3703ad88bea..00000000000 --- a/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/ActiveMQEmbeddedService.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.camel.test.infra.activemq.services; - -import org.apache.activemq.broker.BrokerService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * 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); - - public ActiveMQEmbeddedService() { - this(ActiveMQEmbeddedServiceBuilder.defaultBroker().brokerService()); - } - - public ActiveMQEmbeddedService(BrokerService brokerService) { - super(brokerService); - } - - public String getVmURL() { - return getVmURL(true, false); - } - - @Override - public String getVmURL(boolean create) { - return null; - } - - @Override - 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 deleted file mode 100644 index 695f92bf581..00000000000 --- a/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/ActiveMQEmbeddedServiceBuilder.java +++ /dev/null @@ -1,679 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.camel.test.infra.activemq.services; - -import java.io.File; -import java.io.IOException; -import java.net.URI; -import java.nio.file.Path; -import java.util.List; -import java.util.concurrent.ThreadLocalRandom; -import java.util.concurrent.atomic.LongAdder; -import java.util.function.Consumer; - -import javax.management.ObjectName; - -import org.apache.activemq.Service; -import org.apache.activemq.broker.Broker; -import org.apache.activemq.broker.BrokerContext; -import org.apache.activemq.broker.BrokerPlugin; -import org.apache.activemq.broker.BrokerService; -import org.apache.activemq.broker.SslContext; -import org.apache.activemq.broker.TransportConnector; -import org.apache.activemq.broker.jmx.BrokerView; -import org.apache.activemq.broker.jmx.ManagementContext; -import org.apache.activemq.broker.region.DestinationFactory; -import org.apache.activemq.broker.region.DestinationInterceptor; -import org.apache.activemq.broker.region.policy.PolicyMap; -import org.apache.activemq.broker.scheduler.JobSchedulerStore; -import org.apache.activemq.command.ActiveMQDestination; -import org.apache.activemq.network.jms.JmsConnector; -import org.apache.activemq.security.MessageAuthorizationPolicy; -import org.apache.activemq.store.PListStore; -import org.apache.activemq.store.PersistenceAdapter; -import org.apache.activemq.store.PersistenceAdapterFactory; -import org.apache.activemq.thread.TaskRunnerFactory; -import org.apache.activemq.usage.SystemUsage; -import org.apache.activemq.util.IOExceptionHandler; -import org.apache.commons.io.FileUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import static org.junit.jupiter.api.Assertions.fail; - -/** - * This is a builder class for the embedded ActiveMQ BrokerService. Since it is tightly integrated into the tests of - * some components, we need to have flexibility setting it up. Therefore, in most cases for tests that rely on purely - * embedded ActiveMQ, they can use this to wrap the broker service into the test-infra compatible service that can be - * managed by Junit 5. - */ -public final class ActiveMQEmbeddedServiceBuilder { - private static final Logger LOG = LoggerFactory.getLogger(ActiveMQEmbeddedServiceBuilder.class); - - private static final LongAdder BROKER_COUNT = new LongAdder(); - private final BrokerService brokerService; - - private ActiveMQEmbeddedServiceBuilder() { - brokerService = new BrokerService(); - } - - public ActiveMQEmbeddedServiceBuilder withAdminView(BrokerView adminView) { - brokerService.setAdminView(adminView); - - return this; - } - - public ActiveMQEmbeddedServiceBuilder withBrokerName(Class<?> testClass) { - return withBrokerName(testClass.getSimpleName()); - } - - public ActiveMQEmbeddedServiceBuilder withBrokerName(String brokerName) { - brokerService.setBrokerName(brokerName); - - return this; - } - - public ActiveMQEmbeddedServiceBuilder withBrokerName(Class<?> testClass, String name) { - return withBrokerName(testClass.getSimpleName(), name); - } - - public ActiveMQEmbeddedServiceBuilder withBrokerName(String brokerName, String name) { - brokerService.setBrokerName(brokerName + (name != null ? "-" + name : "")); - - return this; - } - - public ActiveMQEmbeddedServiceBuilder withDataDirectory(Path dataDirectory) { - return withDataDirectory(dataDirectory.toAbsolutePath().toString()); - } - - public ActiveMQEmbeddedServiceBuilder withDataDirectory(String dataDirectory) { - brokerService.setDataDirectory(dataDirectory); - - return this; - } - - public ActiveMQEmbeddedServiceBuilder withDataDirectoryFile(File dataDirectoryFile) { - brokerService.setDataDirectoryFile(dataDirectoryFile); - - return this; - } - - public ActiveMQEmbeddedServiceBuilder withTmpDataDirectory(File tmpDataDirectory) { - brokerService.setTmpDataDirectory(tmpDataDirectory); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withPersistenceFactory(PersistenceAdapterFactory persistenceFactory) { - brokerService.setPersistenceFactory(persistenceFactory); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withDestinationFactory(DestinationFactory destinationFactory) { - brokerService.setDestinationFactory(destinationFactory); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withPersistent(boolean persistent) { - brokerService.setPersistent(persistent); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withPopulateJMSXUserID(boolean populateJMSXUserID) { - brokerService.setPopulateJMSXUserID(populateJMSXUserID); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withSystemUsage(SystemUsage memoryManager) { - brokerService.setSystemUsage(memoryManager); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withConsumerSystemUsage(SystemUsage consumerSystemUsage) { - brokerService.setConsumerSystemUsage(consumerSystemUsage); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withProducerSystemUsage(SystemUsage producerUsageManager) { - brokerService.setProducerSystemUsage(producerUsageManager); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withPersistenceAdapter(PersistenceAdapter persistenceAdapter) { - - try { - brokerService.setPersistenceAdapter(persistenceAdapter); - } catch (IOException e) { - throw new RuntimeException(e); - } - - return this; - } - - public ActiveMQEmbeddedServiceBuilder withTaskRunnerFactory(TaskRunnerFactory taskRunnerFactory) { - brokerService.setTaskRunnerFactory(taskRunnerFactory); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withPersistenceTaskRunnerFactory(TaskRunnerFactory persistenceTaskRunnerFactory) { - brokerService.setPersistenceTaskRunnerFactory(persistenceTaskRunnerFactory); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withEnableStatistics(boolean enableStatistics) { - brokerService.setEnableStatistics(enableStatistics); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withUseJmx(boolean useJmx) { - brokerService.setUseJmx(useJmx); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withBrokerObjectName(ObjectName brokerObjectName) { - brokerService.setBrokerObjectName(brokerObjectName); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withManagementContext(ManagementContext managementContext) { - brokerService.setManagementContext(managementContext); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withNetworkConnectorURIs(String[] networkConnectorURIs) { - brokerService.setNetworkConnectorURIs(networkConnectorURIs); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withTransportConnectorURIs(String[] transportConnectorURIs) { - brokerService.setTransportConnectorURIs(transportConnectorURIs); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withJmsBridgeConnectors(JmsConnector[] jmsConnectors) { - brokerService.setJmsBridgeConnectors(jmsConnectors); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withServices(Service[] services) { - brokerService.setServices(services); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withUseLoggingForShutdownErrors(boolean useLoggingForShutdownErrors) { - brokerService.setUseLoggingForShutdownErrors(useLoggingForShutdownErrors); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withUseShutdownHook(boolean useShutdownHook) { - brokerService.setUseShutdownHook(useShutdownHook); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withAdvisorySupport(boolean advisorySupport) { - brokerService.setAdvisorySupport(advisorySupport); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withAnonymousProducerAdvisorySupport(boolean anonymousProducerAdvisorySupport) { - brokerService.setAnonymousProducerAdvisorySupport(anonymousProducerAdvisorySupport); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withTransportConnectors(List<TransportConnector> transportConnectors) - throws Exception { - brokerService.setTransportConnectors(transportConnectors); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withNetworkConnectors(List<?> networkConnectors) throws Exception { - brokerService.setNetworkConnectors(networkConnectors); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withProxyConnectors(List<?> proxyConnectors) throws Exception { - brokerService.setProxyConnectors(proxyConnectors); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withDestinationPolicy(PolicyMap policyMap) { - brokerService.setDestinationPolicy(policyMap); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withPlugins(BrokerPlugin[] plugins) { - brokerService.setPlugins(plugins); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withMessageAuthorizationPolicy( - MessageAuthorizationPolicy messageAuthorizationPolicy) { - brokerService.setMessageAuthorizationPolicy(messageAuthorizationPolicy); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withDeleteAllMessagesOnStartup(boolean deletePersistentMessagesOnStartup) { - brokerService.setDeleteAllMessagesOnStartup(deletePersistentMessagesOnStartup); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withVmConnectorURI(URI vmConnectorURI) { - brokerService.setVmConnectorURI(vmConnectorURI); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withShutdownOnMasterFailure(boolean shutdownOnMasterFailure) { - brokerService.setShutdownOnMasterFailure(shutdownOnMasterFailure); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withKeepDurableSubsActive(boolean keepDurableSubsActive) { - brokerService.setKeepDurableSubsActive(keepDurableSubsActive); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withEnableMessageExpirationOnActiveDurableSubs( - boolean enableMessageExpirationOnActiveDurableSubs) { - brokerService.setEnableMessageExpirationOnActiveDurableSubs(enableMessageExpirationOnActiveDurableSubs); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withUseVirtualTopics(boolean useVirtualTopics) { - brokerService.setUseVirtualTopics(useVirtualTopics); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withUseMirroredQueues(boolean useMirroredQueues) { - brokerService.setUseMirroredQueues(useMirroredQueues); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withDestinationInterceptors(DestinationInterceptor[] destinationInterceptors) { - brokerService.setDestinationInterceptors(destinationInterceptors); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withDestinations(ActiveMQDestination[] destinations) { - brokerService.setDestinations(destinations); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withTempDataStore(PListStore tempDataStore) { - brokerService.setTempDataStore(tempDataStore); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withPersistenceThreadPriority(int persistenceThreadPriority) { - brokerService.setPersistenceThreadPriority(persistenceThreadPriority); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withUseLocalHostBrokerName(boolean useLocalHostBrokerName) { - brokerService.setUseLocalHostBrokerName(useLocalHostBrokerName); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withProducerSystemUsagePortion(int producerSystemUsagePortion) { - brokerService.setProducerSystemUsagePortion(producerSystemUsagePortion); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withConsumerSystemUsagePortion(int consumerSystemUsagePortion) { - brokerService.setConsumerSystemUsagePortion(consumerSystemUsagePortion); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withSplitSystemUsageForProducersConsumers( - boolean splitSystemUsageForProducersConsumers) { - brokerService.setSplitSystemUsageForProducersConsumers(splitSystemUsageForProducersConsumers); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withMonitorConnectionSplits(boolean monitorConnectionSplits) { - brokerService.setMonitorConnectionSplits(monitorConnectionSplits); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withTaskRunnerPriority(int taskRunnerPriority) { - brokerService.setTaskRunnerPriority(taskRunnerPriority); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withDedicatedTaskRunner(boolean dedicatedTaskRunner) { - brokerService.setDedicatedTaskRunner(dedicatedTaskRunner); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withCacheTempDestinations(boolean cacheTempDestinations) { - brokerService.setCacheTempDestinations(cacheTempDestinations); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withTimeBeforePurgeTempDestinations(int timeBeforePurgeTempDestinations) { - brokerService.setTimeBeforePurgeTempDestinations(timeBeforePurgeTempDestinations); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withUseTempMirroredQueues(boolean useTempMirroredQueues) { - brokerService.setUseTempMirroredQueues(useTempMirroredQueues); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withJobSchedulerStore(JobSchedulerStore jobSchedulerStore) { - brokerService.setJobSchedulerStore(jobSchedulerStore); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withShutdownHooks(List<Runnable> hooks) throws Exception { - brokerService.setShutdownHooks(hooks); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withRegionBroker(Broker regionBroker) { - brokerService.setRegionBroker(regionBroker); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withSystemExitOnShutdown(boolean systemExitOnShutdown) { - brokerService.setSystemExitOnShutdown(systemExitOnShutdown); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withSystemExitOnShutdownExitCode(int systemExitOnShutdownExitCode) { - brokerService.setSystemExitOnShutdownExitCode(systemExitOnShutdownExitCode); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withSslContext(SslContext sslContext) { - brokerService.setSslContext(sslContext); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withShutdownOnSlaveFailure(boolean shutdownOnSlaveFailure) { - brokerService.setShutdownOnSlaveFailure(shutdownOnSlaveFailure); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withWaitForSlave(boolean waitForSlave) { - brokerService.setWaitForSlave(waitForSlave); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withWaitForSlaveTimeout(long waitForSlaveTimeout) { - brokerService.setWaitForSlaveTimeout(waitForSlaveTimeout); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withPassiveSlave(boolean passiveSlave) { - brokerService.setPassiveSlave(passiveSlave); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withIoExceptionHandler(IOExceptionHandler ioExceptionHandler) { - brokerService.setIoExceptionHandler(ioExceptionHandler); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withSchedulerSupport(boolean schedulerSupport) { - brokerService.setSchedulerSupport(schedulerSupport); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withSchedulerDirectoryFile(File schedulerDirectory) { - brokerService.setSchedulerDirectoryFile(schedulerDirectory); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withSchedulerDirectory(String schedulerDirectory) { - brokerService.setSchedulerDirectory(schedulerDirectory); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withSchedulePeriodForDestinationPurge(int schedulePeriodForDestinationPurge) { - brokerService.setSchedulePeriodForDestinationPurge(schedulePeriodForDestinationPurge); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withSchedulePeriodForDiskUsageCheck(int schedulePeriodForDiskUsageCheck) { - brokerService.setSchedulePeriodForDiskUsageCheck(schedulePeriodForDiskUsageCheck); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withDiskUsageCheckRegrowThreshold(int diskUsageCheckRegrowThreshold) { - brokerService.setDiskUsageCheckRegrowThreshold(diskUsageCheckRegrowThreshold); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withMaxPurgedDestinationsPerSweep(int maxPurgedDestinationsPerSweep) { - brokerService.setMaxPurgedDestinationsPerSweep(maxPurgedDestinationsPerSweep); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withBrokerContext(BrokerContext brokerContext) { - brokerService.setBrokerContext(brokerContext); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withBrokerId(String brokerId) { - brokerService.setBrokerId(brokerId); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withUseAuthenticatedPrincipalForJMSXUserID( - boolean useAuthenticatedPrincipalForJMSXUserID) { - brokerService.setUseAuthenticatedPrincipalForJMSXUserID(useAuthenticatedPrincipalForJMSXUserID); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withPopulateUserNameInMBeans(boolean value) { - brokerService.setPopulateUserNameInMBeans(value); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withMbeanInvocationTimeout(long mbeanInvocationTimeout) { - brokerService.setMbeanInvocationTimeout(mbeanInvocationTimeout); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withNetworkConnectorStartAsync(boolean networkConnectorStartAsync) { - brokerService.setNetworkConnectorStartAsync(networkConnectorStartAsync); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withAllowTempAutoCreationOnSend(boolean allowTempAutoCreationOnSend) { - brokerService.setAllowTempAutoCreationOnSend(allowTempAutoCreationOnSend); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withOfflineDurableSubscriberTimeout(long offlineDurableSubscriberTimeout) { - brokerService.setOfflineDurableSubscriberTimeout(offlineDurableSubscriberTimeout); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withOfflineDurableSubscriberTaskSchedule( - long offlineDurableSubscriberTaskSchedule) { - brokerService.setOfflineDurableSubscriberTaskSchedule(offlineDurableSubscriberTaskSchedule); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withStartAsync(boolean startAsync) { - brokerService.setStartAsync(startAsync); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withRestartAllowed(boolean restartAllowed) { - brokerService.setRestartAllowed(restartAllowed); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withStoreOpenWireVersion(int storeOpenWireVersion) { - brokerService.setStoreOpenWireVersion(storeOpenWireVersion); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withRejectDurableConsumers(boolean rejectDurableConsumers) { - brokerService.setRejectDurableConsumers(rejectDurableConsumers); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withUseVirtualDestSubs(boolean useVirtualDestSubs) { - brokerService.setUseVirtualDestSubs(useVirtualDestSubs); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withUseVirtualDestSubsOnCreation(boolean useVirtualDestSubsOnCreation) { - brokerService.setUseVirtualDestSubsOnCreation(useVirtualDestSubsOnCreation); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withAdjustUsageLimits(boolean adjustUsageLimits) { - brokerService.setAdjustUsageLimits(adjustUsageLimits); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withRollbackOnlyOnAsyncException(boolean rollbackOnlyOnAsyncException) { - brokerService.setRollbackOnlyOnAsyncException(rollbackOnlyOnAsyncException); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withMaxSchedulerRepeatAllowed(int maxSchedulerRepeatAllowed) { - brokerService.setMaxSchedulerRepeatAllowed(maxSchedulerRepeatAllowed); - return this; - } - - public ActiveMQEmbeddedServiceBuilder withCustomSetup(Consumer<BrokerService> consumer) { - consumer.accept(brokerService); - - return this; - } - - public ActiveMQEmbeddedServiceBuilder withTcpTransport() { - return withTcpTransport(0); - } - - public ActiveMQEmbeddedServiceBuilder withTcpTransport(int port) { - return withTransport("tcp://0.0.0.0:", port); - } - - public ActiveMQEmbeddedServiceBuilder withAmqpTransport(int port) { - return withTransport("amqp://0.0.0.0:", port); - } - - public ActiveMQEmbeddedServiceBuilder withMqttTransport(int port) { - return withTransport("mqtt://0.0.0.0:", port); - } - - public ActiveMQEmbeddedServiceBuilder withStompTransport(int port, String options) { - return withTransport("stomp://localhost:", port, options); - } - - public ActiveMQEmbeddedServiceBuilder withTransport(String bindAddress, int port) { - return withTransport(bindAddress, port, null); - } - - public ActiveMQEmbeddedServiceBuilder withTransport(String bindAddress, int port, String options) { - try { - brokerService.addConnector(bindAddress + port + (options == null ? "" : options)); - } catch (Exception e) { - fail("Unable to add new transport: " + e.getMessage()); - } - - return this; - } - - BrokerService brokerService() { - return brokerService; - } - - public ActiveMQEmbeddedService build() { - return new ActiveMQEmbeddedService(brokerService); - } - - @Deprecated - public ActiveMQEmbeddedService buildWithRecycle() { - return build(); - } - - public static ActiveMQEmbeddedServiceBuilder bare() { - return new ActiveMQEmbeddedServiceBuilder(); - } - - private static String generateDataDirectoryPathForInstance(String name) { - final String dataDirectoryPath = ActiveMQEmbeddedServiceBuilder.class.getResource("/").getFile() + name; - - final File dataDirectory = new File(dataDirectoryPath); - if (dataDirectory.exists()) { - try { - FileUtils.deleteDirectory(dataDirectory); - } catch (IOException e) { - LOG.warn( - "Could not delete the data directory at {}: {} (the error will be ignored, but the tests are likely to fail)", - dataDirectoryPath, e.getMessage()); - } - } - - return dataDirectoryPath; - } - - private static String generateSemiUniqueBrokerName() { - final String semiUniqueName - = ActiveMQEmbeddedServiceBuilder.class.getSimpleName() + "-" + BROKER_COUNT.longValue() + "." - + ThreadLocalRandom.current().nextInt(1000); - - BROKER_COUNT.increment(); - return semiUniqueName; - } - - public static ActiveMQEmbeddedServiceBuilder defaultBroker() { - final String semiUniqueName = generateSemiUniqueBrokerName(); - - return defaultBroker(semiUniqueName); - } - - public static ActiveMQEmbeddedServiceBuilder defaultBroker(String name) { - final String dataDirectoryPath = generateDataDirectoryPathForInstance(name); - - return new ActiveMQEmbeddedServiceBuilder() - .withDeleteAllMessagesOnStartup(true) - .withBrokerName(name) - .withAdvisorySupport(false) - .withUseJmx(false) - .withDataDirectory(dataDirectoryPath); - } - - public static ActiveMQEmbeddedServiceBuilder persistentBroker() { - String semiUniqueName = "persistent" + generateSemiUniqueBrokerName(); - - BROKER_COUNT.increment(); - - return persistentBroker(semiUniqueName); - } - - public static ActiveMQEmbeddedServiceBuilder persistentBroker(String name) { - final String dataDirectoryPath = generateDataDirectoryPathForInstance(name); - - return new ActiveMQEmbeddedServiceBuilder() - .withDeleteAllMessagesOnStartup(true) - .withBrokerName(name) - .withAdvisorySupport(false) - .withUseJmx(false) - .withPersistent(true) - .withDataDirectory(dataDirectoryPath); - } - -} diff --git a/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/ActiveMQPersistentVMService.java b/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/ActiveMQPersistentVMService.java deleted file mode 100644 index 499b06cc471..00000000000 --- a/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/ActiveMQPersistentVMService.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.camel.test.infra.activemq.services; - -import org.apache.activemq.broker.BrokerService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * 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 ActiveMQPersistentVMService extends AbstractActiveMQEmbeddedService { - private static final Logger LOG = LoggerFactory.getLogger(ActiveMQPersistentVMService.class); - - public ActiveMQPersistentVMService() { - this(ActiveMQEmbeddedServiceBuilder.persistentBroker().brokerService()); - } - - public ActiveMQPersistentVMService(BrokerService brokerService) { - super(brokerService); - - super.initialize(); - } - - @Override - public String getVmURL() { - return getVmURL(true); - } - - @Override - public String getVmURL(boolean create) { - return getVmURL(false, create); - } - - @Override - public String serviceAddress() { - return getVmURL(true); - } - - @Override - public String userName() { - return null; - } - - @Override - public String password() { - return null; - } - - @Override - public void initialize() { - // NO-OP: it already initializes when the class is created. - } - - @Override - public void shutdown() { - // NO-OP - } -} diff --git a/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/ActiveMQRemoteService.java b/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/ActiveMQRemoteService.java deleted file mode 100644 index 67d4a910451..00000000000 --- a/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/ActiveMQRemoteService.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.test.infra.activemq.services; - -import org.apache.camel.test.infra.activemq.common.ActiveMQProperties; - -public class ActiveMQRemoteService implements ActiveMQService { - - @Override - public void initialize() { - registerProperties(); - } - - @Override - public void shutdown() { - // NO-OP - } - - @Override - public void restart() { - // NO-OP - } - - @Override - public String serviceAddress() { - return System.getProperty(ActiveMQProperties.SERVICE_ADDRESS); - } - - @Override - public String userName() { - return System.getProperty(ActiveMQProperties.AMQ_USERNAME); - } - - @Override - public String password() { - return System.getProperty(ActiveMQProperties.AMQ_PASSWORD); - } -} diff --git a/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/ActiveMQService.java b/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/ActiveMQService.java deleted file mode 100644 index bd70b219f2a..00000000000 --- a/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/ActiveMQService.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.test.infra.activemq.services; - -import org.apache.camel.test.infra.activemq.common.ActiveMQProperties; -import org.apache.camel.test.infra.common.services.TestService; -import org.junit.jupiter.api.extension.AfterAllCallback; -import org.junit.jupiter.api.extension.AfterEachCallback; -import org.junit.jupiter.api.extension.BeforeAllCallback; -import org.junit.jupiter.api.extension.BeforeEachCallback; -import org.junit.jupiter.api.extension.ExtensionContext; - -/** - * Test infra service for ActiveMQ - */ -public interface ActiveMQService - extends BeforeAllCallback, AfterAllCallback, BeforeEachCallback, AfterEachCallback, TestService { - - String serviceAddress(); - - String userName(); - - String password(); - - default void registerProperties() { - // For compatibility with the previous format used by camel-sjms tests - System.setProperty(ActiveMQProperties.SERVICE_ADDRESS, serviceAddress()); - System.setProperty(ActiveMQProperties.AMQ_EXTERNAL, serviceAddress()); - System.setProperty(ActiveMQProperties.AMQ_USERNAME, userName()); - System.setProperty(ActiveMQProperties.AMQ_PASSWORD, userName()); - } - - @Override - default void beforeAll(ExtensionContext extensionContext) throws Exception { - initialize(); - } - - @Override - default void afterAll(ExtensionContext extensionContext) throws Exception { - shutdown(); - } - - @Override - default void afterEach(ExtensionContext extensionContext) throws Exception { - shutdown(); - } - - @Override - default void beforeEach(ExtensionContext extensionContext) throws Exception { - initialize(); - } - - void restart(); -} 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 deleted file mode 100644 index 6a528fc3e9c..00000000000 --- a/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/ActiveMQServiceFactory.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.test.infra.activemq.services; - -import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder; -import org.apache.camel.test.infra.common.services.SingletonService; -import org.junit.jupiter.api.extension.ExtensionContext; - -public final class ActiveMQServiceFactory { - - public static class SingletonActiveMQService extends SingletonService<ActiveMQService> implements ActiveMQService { - public SingletonActiveMQService(ActiveMQService service, String name) { - super(service, name); - } - - @Override - public String serviceAddress() { - return getService().serviceAddress(); - } - - @Override - public String userName() { - return getService().userName(); - } - - @Override - public String password() { - return getService().password(); - } - - @Override - public void beforeAll(ExtensionContext extensionContext) { - addToStore(extensionContext); - } - - @Override - public void afterAll(ExtensionContext extensionContext) { - // NO-OP - } - - @Override - public void afterEach(ExtensionContext extensionContext) { - // NO-OP - } - - @Override - public void beforeEach(ExtensionContext extensionContext) { - addToStore(extensionContext); - } - - @Override - public void restart() { - getService().restart(); - } - - @Override - public ActiveMQService getService() { - return super.getService(); - } - } - - private static SimpleTestServiceBuilder<ActiveMQService> nonPersistentInstanceBuilder; - private static ActiveMQService nonPersistentService; - - private static SimpleTestServiceBuilder<ActiveMQService> persistentInstanceBuilder; - private static ActiveMQService persistentService; - - private ActiveMQServiceFactory() { - - } - - public static SimpleTestServiceBuilder<ActiveMQService> builder() { - return new SimpleTestServiceBuilder<>("activemq"); - } - - public static ActiveMQService createService() { - return builder() - .addLocalMapping(ActiveMQEmbeddedService::new) - .addRemoteMapping(ActiveMQRemoteService::new) - .build(); - } - - /** - * Creates a new instance of an embedded ActiveMQ - * - * @return a new instance of an embedded ActiveMQ - */ - public static synchronized ActiveMQService createVMService() { - return createSingletonVMService(); - } - - /** - * Creates a new instance of an embedded ActiveMQ. It may use a single instance if possible/supported. - * - * @return a new instance of an embedded ActiveMQ - */ - public static synchronized ActiveMQService createVMServiceInstance() { - SimpleTestServiceBuilder<ActiveMQService> instance = new SimpleTestServiceBuilder<>("activemq"); - instance.addLocalMapping(ActiveMQVMService::new); - - return instance.build(); - } - - /** - * Creates or reuses a new singleton instance of an embedded ActiveMQ - * - * @return an instance of an embedded ActiveMQ - */ - public static synchronized ActiveMQService createSingletonVMService() { - if (nonPersistentService == null) { - if (nonPersistentInstanceBuilder == null) { - nonPersistentInstanceBuilder = new SimpleTestServiceBuilder<>("activemq"); - - nonPersistentInstanceBuilder - .addLocalMapping(() -> new SingletonActiveMQService(new ActiveMQVMService(), "activemq")); - } - - nonPersistentService = nonPersistentInstanceBuilder.build(); - } - - return nonPersistentService; - } - - /** - * Creates a new instance of a persistent embedded ActiveMQ. It may use a single instance if possible/supported. - * - * @return a new instance of a persistent embedded ActiveMQ - */ - public static synchronized ActiveMQService createPersistentVMService() { - return createSingletonPersistentVMService(); - } - - /** - * Creates a new instance of a persistent embedded ActiveMQ - * - * @return a new instance of a persistent embedded ActiveMQ - */ - public static synchronized ActiveMQService createPersistentVMServiceInstance() { - SimpleTestServiceBuilder<ActiveMQService> instance = new SimpleTestServiceBuilder<>("activemq"); - - instance.addLocalMapping(ActiveMQPersistentVMService::new); - - return instance.build(); - } - - /** - * Creates or reuses a new singleton instance of a persistent embedded ActiveMQ - * - * @return an instance of a persistent embedded ActiveMQ - */ - public static synchronized ActiveMQService createSingletonPersistentVMService() { - if (persistentService == null) { - if (persistentInstanceBuilder == null) { - persistentInstanceBuilder = new SimpleTestServiceBuilder<>("activemq"); - - persistentInstanceBuilder - .addLocalMapping( - () -> new SingletonActiveMQService(new ActiveMQPersistentVMService(), "activemq-persistent")); - } - - persistentService = persistentInstanceBuilder.build(); - } - - return persistentService; - } -} 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 deleted file mode 100644 index 7728caccdd9..00000000000 --- a/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/ActiveMQVMService.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.camel.test.infra.activemq.services; - -import org.apache.activemq.broker.BrokerService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * 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); - - public ActiveMQVMService() { - this(ActiveMQEmbeddedServiceBuilder.defaultBroker().brokerService()); - } - - public ActiveMQVMService(BrokerService brokerService) { - super(brokerService); - - super.initialize(); - } - - @Override - public String getVmURL() { - return getVmURL(true); - } - - @Override - public String getVmURL(boolean create) { - return getVmURL(false, create); - } - - @Override - public String serviceAddress() { - return getVmURL(true); - } - - @Override - public String userName() { - return null; - } - - @Override - public String password() { - return null; - } - - @Override - public void initialize() { - // NO-OP: it already initializes when the class is created. - } - - @Override - public void shutdown() { - // NO-OP - } -} diff --git a/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/LegacyEmbeddedBroker.java b/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/LegacyEmbeddedBroker.java deleted file mode 100644 index 96468b5f6f9..00000000000 --- a/test-infra/camel-test-infra-activemq/src/test/java/org/apache/camel/test/infra/activemq/services/LegacyEmbeddedBroker.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.camel.test.infra.activemq.services; - -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.atomic.AtomicInteger; - -import org.apache.camel.util.URISupport; - -public final class LegacyEmbeddedBroker { - private static AtomicInteger counter = new AtomicInteger(); - - private LegacyEmbeddedBroker() { - - } - - @Deprecated - public static String createBrokerUrl() { - return createBrokerUrl(null); - } - - @Deprecated - public static String createBrokerUrl(String options) { - // using a unique broker name improves testing when running the entire test suite in the same JVM - int id = counter.incrementAndGet(); - Map<String, Object> map = new HashMap<>(); - map.put("broker.useJmx", false); - map.put("broker.persistent", false); - return createUri("vm://test-broker-" + id, map, options); - } - - @Deprecated - private static String createUri(String uri, Map<String, Object> map, String options) { - try { - map.putAll(URISupport.parseQuery(options)); - return URISupport.appendParametersToURI(uri, map); - } catch (Exception e) { - throw new IllegalArgumentException(e); - } - } - -} diff --git a/test-infra/pom.xml b/test-infra/pom.xml index 8b92ce06215..84331f99481 100644 --- a/test-infra/pom.xml +++ b/test-infra/pom.xml @@ -69,7 +69,6 @@ <module>camel-test-infra-ftp</module> <module>camel-test-infra-fhir</module> <module>camel-test-infra-mosquitto</module> - <!--module>camel-test-infra-activemq</module--> <module>camel-test-infra-chatscript</module> <module>camel-test-infra-openldap</module> <module>camel-test-infra-ignite</module>