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 2020/11/13 14:43:43 UTC
[camel] branch master updated: Add test infra from message brokers
(#4608)
This is an automated email from the ASF dual-hosted git repository.
orpiske pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new 2dd3d70 Add test infra from message brokers (#4608)
2dd3d70 is described below
commit 2dd3d70cbfbed05af5ad4100400584e16fe03c21
Author: Otavio Rodolfo Piske <or...@users.noreply.github.com>
AuthorDate: Fri Nov 13 15:34:24 2020 +0100
Add test infra from message brokers (#4608)
Includes:
- test infra based on Apache Artemis
- test infra based on Qpid
---
test-infra/camel-test-infra-artemis/pom.xml | 66 +++++++++++
.../src/main/resources/META-INF/MANIFEST.MF | 0
.../infra/artemis/services/ArtemisContainer.java | 131 +++++++++++++++++++++
.../camel/test/infra/artemis/services/Dockerfile | 33 ++++++
.../camel-test-infra-dispatch-router/pom.xml | 66 +++++++++++
.../src/main/resources/META-INF/MANIFEST.MF | 0
.../router/services/DispatchRouterContainer.java | 60 ++++++++++
.../test/infra/dispatch/router/services/Dockerfile | 19 +++
.../camel-test-infra-messaging-common/pom.xml | 56 +++++++++
.../src/main/resources/META-INF/MANIFEST.MF | 0
.../messaging/common/MessagingProperties.java | 27 +++++
.../messaging/services/MessagingContainer.java | 28 +++++
.../services/MessagingLocalContainerService.java | 71 +++++++++++
.../messaging/services/MessagingRemoteService.java | 43 +++++++
.../infra/messaging/services/MessagingService.java | 43 +++++++
.../services/MessagingServiceBuilder.java | 70 +++++++++++
test-infra/pom.xml | 4 +
17 files changed, 717 insertions(+)
diff --git a/test-infra/camel-test-infra-artemis/pom.xml b/test-infra/camel-test-infra-artemis/pom.xml
new file mode 100644
index 0000000..3cc0501
--- /dev/null
+++ b/test-infra/camel-test-infra-artemis/pom.xml
@@ -0,0 +1,66 @@
+<?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>3.7.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>camel-test-infra-artemis</artifactId>
+ <name>Camel :: Test Infra :: Artemis</name>
+ <description>Apache Artemis test infrastructure for Camel</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-infra-common</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-infra-messaging-common</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.testcontainers</groupId>
+ <artifactId>testcontainers</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
diff --git a/test-infra/camel-test-infra-artemis/src/main/resources/META-INF/MANIFEST.MF b/test-infra/camel-test-infra-artemis/src/main/resources/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..e69de29
diff --git a/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/ArtemisContainer.java b/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/ArtemisContainer.java
new file mode 100644
index 0000000..eee4009
--- /dev/null
+++ b/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/ArtemisContainer.java
@@ -0,0 +1,131 @@
+/*
+ * 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.artemis.services;
+
+import org.apache.camel.test.infra.messaging.services.MessagingContainer;
+import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.containers.wait.strategy.Wait;
+import org.testcontainers.images.builder.ImageFromDockerfile;
+
+public class ArtemisContainer extends GenericContainer<ArtemisContainer> implements MessagingContainer {
+ private static final int DEFAULT_MQTT_PORT = 1883;
+ private static final int DEFAULT_AMQP_PORT = 5672;
+ private static final int DEFAULT_ADMIN_PORT = 8161;
+ private static final int DEFAULT_ACCEPTOR_PORT = 61616;
+
+ public ArtemisContainer() {
+ super(new ImageFromDockerfile("apache-artemis:ckc", false)
+ .withFileFromClasspath("Dockerfile",
+ "org/apache/camel/test/infra/artemis/services/Dockerfile"));
+
+ withExposedPorts(DEFAULT_MQTT_PORT, DEFAULT_AMQP_PORT,
+ DEFAULT_ADMIN_PORT, DEFAULT_ACCEPTOR_PORT);
+
+ waitingFor(Wait.forListeningPort());
+ }
+
+ /**
+ * Gets the port number used for exchanging messages using the AMQP protocol
+ *
+ * @return the port number
+ */
+ public int amqpPort() {
+ return getMappedPort(DEFAULT_AMQP_PORT);
+ }
+
+ /**
+ * Gets the end point URL used exchanging messages using the AMQP protocol (ie.: tcp://host:${amqp.port})
+ *
+ * @return the end point URL as a string
+ */
+ public String amqpEndpoint() {
+ return String.format("tcp://%s:%d", getContainerIpAddress(), amqpPort());
+ }
+
+ /**
+ * Gets the port number used for exchanging messages using the MQTT protocol
+ *
+ * @return the port number
+ */
+ public int mqttPort() {
+ return getMappedPort(DEFAULT_MQTT_PORT);
+ }
+
+ /**
+ * Gets the end point URL used exchanging messages using the MQTT protocol (ie.: tcp://host:${mqtt.port})
+ *
+ * @return the end point URL as a string
+ */
+ public String mqttEndpoint() {
+ return String.format("tcp://%s:%d", getContainerIpAddress(), mqttPort());
+ }
+
+ /**
+ * Gets the port number used for accessing the web management console or the management API
+ *
+ * @return the port number
+ */
+ public int adminPort() {
+ return getMappedPort(DEFAULT_ADMIN_PORT);
+ }
+
+ /**
+ * Gets the end point URL used for accessing the web management console or the management API
+ *
+ * @return the admin URL as a string
+ */
+ public String adminURL() {
+ return String.format("http://%s:%d", getContainerIpAddress(), adminPort());
+ }
+
+ /**
+ * Gets the port number used for exchanging messages using the default acceptor port
+ *
+ * @return the port number
+ */
+ public int defaultAcceptorPort() {
+ return getMappedPort(DEFAULT_ACCEPTOR_PORT);
+ }
+
+ /**
+ * Gets the end point URL used exchanging messages through the default acceptor port
+ *
+ * @return the end point URL as a string
+ */
+ public String defaultEndpoint() {
+ return String.format("tcp://%s:%d", getContainerIpAddress(), defaultAcceptorPort());
+ }
+
+ /**
+ * Gets the port number used for exchanging messages using the Openwire protocol
+ *
+ * @return the port number
+ */
+ public int openwirePort() {
+ return defaultAcceptorPort();
+ }
+
+ /**
+ * Gets the end point URL used exchanging messages using the Openwire protocol (ie.: tcp://host:${amqp.port})
+ *
+ * @return the end point URL as a string
+ */
+ public String getOpenwireEndpoint() {
+ return String.format("tcp://%s:%d", getContainerIpAddress(), openwirePort());
+ }
+}
diff --git a/test-infra/camel-test-infra-artemis/src/test/resources/org/apache/camel/test/infra/artemis/services/Dockerfile b/test-infra/camel-test-infra-artemis/src/test/resources/org/apache/camel/test/infra/artemis/services/Dockerfile
new file mode 100644
index 0000000..1cfd66e
--- /dev/null
+++ b/test-infra/camel-test-infra-artemis/src/test/resources/org/apache/camel/test/infra/artemis/services/Dockerfile
@@ -0,0 +1,33 @@
+# 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.
+FROM centos:8 as artemis-base
+MAINTAINER Otavio Rodolfo Piske <an...@gmail.com>
+ARG ARTEMIS_VERSION
+ENV ARTEMIS_VERSION ${ARTEMIS_VERSION:-2.7.0}
+ARG ARTEMIS_JOURNAL
+ENV ARTEMIS_JOURNAL ${ARTEMIS_JOURNAL:-aio}
+ENV JMS_BROKER_ROOT /opt/camel-kafka-connector/artemis/
+EXPOSE 1883 5672 8161 61616
+RUN dnf install -y java-1.8.0-openjdk-headless libaio tar gzip && dnf clean all
+ENV JAVA_HOME /etc/alternatives/jre
+RUN mkdir -p ${JMS_BROKER_ROOT}
+WORKDIR ${JMS_BROKER_ROOT}
+RUN curl https://archive.apache.org/dist/activemq/activemq-artemis/${ARTEMIS_VERSION}/apache-artemis-${ARTEMIS_VERSION}-bin.tar.gz -o apache-artemis.tar.gz && \
+ mkdir -p apache-artemis && tar --strip-components=1 -xvf apache-artemis.tar.gz -C apache-artemis && \
+ rm -f apache-artemis.tar.gz
+
+FROM artemis-base as artemis
+RUN ${JMS_BROKER_ROOT}/apache-artemis/bin/artemis create --${ARTEMIS_JOURNAL} --relax-jolokia --allow-anonymous --http-host 0.0.0.0 --user admin --password "admin" --role amq --data /artemis-storage ${JMS_BROKER_ROOT}/apache-artemis-instance
+CMD [ "sh", "-c", "./apache-artemis-instance/bin/artemis run" ]
\ No newline at end of file
diff --git a/test-infra/camel-test-infra-dispatch-router/pom.xml b/test-infra/camel-test-infra-dispatch-router/pom.xml
new file mode 100644
index 0000000..d1e7b2d
--- /dev/null
+++ b/test-infra/camel-test-infra-dispatch-router/pom.xml
@@ -0,0 +1,66 @@
+<?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>3.7.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>camel-test-infra-dispatch-router</artifactId>
+ <name>Camel :: Test Infra :: Dispatch Router</name>
+ <description>Dispatch Router test infrastructure for Camel</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-infra-common</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-infra-messaging-common</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.testcontainers</groupId>
+ <artifactId>testcontainers</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
diff --git a/test-infra/camel-test-infra-dispatch-router/src/main/resources/META-INF/MANIFEST.MF b/test-infra/camel-test-infra-dispatch-router/src/main/resources/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..e69de29
diff --git a/test-infra/camel-test-infra-dispatch-router/src/test/java/org/apache/camel/test/infra/dispatch/router/services/DispatchRouterContainer.java b/test-infra/camel-test-infra-dispatch-router/src/test/java/org/apache/camel/test/infra/dispatch/router/services/DispatchRouterContainer.java
new file mode 100644
index 0000000..c1e96b8
--- /dev/null
+++ b/test-infra/camel-test-infra-dispatch-router/src/test/java/org/apache/camel/test/infra/dispatch/router/services/DispatchRouterContainer.java
@@ -0,0 +1,60 @@
+/*
+ * 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.dispatch.router.services;
+
+import org.apache.camel.test.infra.messaging.services.MessagingContainer;
+import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.containers.wait.strategy.Wait;
+import org.testcontainers.images.builder.ImageFromDockerfile;
+
+public class DispatchRouterContainer extends GenericContainer<DispatchRouterContainer> implements MessagingContainer {
+ private static final int DEFAULT_AMQP_PORT = 5672;
+
+ public DispatchRouterContainer() {
+ super(new ImageFromDockerfile("qpid-dispatch:camel", false)
+ .withFileFromClasspath("Dockerfile",
+ "org/apache/camel/test/infra/dispatch/router/services/Dockerfile"));
+
+ withExposedPorts(DEFAULT_AMQP_PORT);
+
+ waitingFor(Wait.forListeningPort());
+ }
+
+ /**
+ * Gets the port number used for exchanging messages using the AMQP protocol
+ *
+ * @return the port number
+ */
+ public int getAMQPPort() {
+ return getMappedPort(DEFAULT_AMQP_PORT);
+ }
+
+ /**
+ * Gets the end point URL used exchanging messages using the AMQP protocol (ie.: tcp://host:${amqp.port})
+ *
+ * @return the end point URL as a string
+ */
+ public String getAMQPEndpoint() {
+ return String.format("amqp://%s:%d", getContainerIpAddress(), getAMQPPort());
+ }
+
+ @Override
+ public String defaultEndpoint() {
+ return getAMQPEndpoint();
+ }
+}
diff --git a/test-infra/camel-test-infra-dispatch-router/src/test/resources/org/apache/camel/test/infra/dispatch/router/services/Dockerfile b/test-infra/camel-test-infra-dispatch-router/src/test/resources/org/apache/camel/test/infra/dispatch/router/services/Dockerfile
new file mode 100644
index 0000000..5f55073
--- /dev/null
+++ b/test-infra/camel-test-infra-dispatch-router/src/test/resources/org/apache/camel/test/infra/dispatch/router/services/Dockerfile
@@ -0,0 +1,19 @@
+# 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.
+FROM fedora:31
+MAINTAINER Otavio Rodolfo Piske <an...@gmail.com>
+EXPOSE 5672
+RUN dnf install -y qpid-dispatch-router
+CMD [ "sh", "-c", "/usr/sbin/qdrouterd" ]
\ No newline at end of file
diff --git a/test-infra/camel-test-infra-messaging-common/pom.xml b/test-infra/camel-test-infra-messaging-common/pom.xml
new file mode 100644
index 0000000..9d45297
--- /dev/null
+++ b/test-infra/camel-test-infra-messaging-common/pom.xml
@@ -0,0 +1,56 @@
+<?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>3.7.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <name>Camel :: Test Infra :: Messaging Common</name>
+ <artifactId>camel-test-infra-messaging-common</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-infra-common</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.testcontainers</groupId>
+ <artifactId>testcontainers</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
diff --git a/test-infra/camel-test-infra-messaging-common/src/main/resources/META-INF/MANIFEST.MF b/test-infra/camel-test-infra-messaging-common/src/main/resources/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..e69de29
diff --git a/test-infra/camel-test-infra-messaging-common/src/test/java/org/apache/camel/test/infra/messaging/common/MessagingProperties.java b/test-infra/camel-test-infra-messaging-common/src/test/java/org/apache/camel/test/infra/messaging/common/MessagingProperties.java
new file mode 100644
index 0000000..0cbd034
--- /dev/null
+++ b/test-infra/camel-test-infra-messaging-common/src/test/java/org/apache/camel/test/infra/messaging/common/MessagingProperties.java
@@ -0,0 +1,27 @@
+/*
+ * 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.messaging.common;
+
+public final class MessagingProperties {
+ public static final String MESSAGING_BROKER_ADDRESS = "messaging.broker.address";
+
+ private MessagingProperties() {
+
+ }
+
+}
diff --git a/test-infra/camel-test-infra-messaging-common/src/test/java/org/apache/camel/test/infra/messaging/services/MessagingContainer.java b/test-infra/camel-test-infra-messaging-common/src/test/java/org/apache/camel/test/infra/messaging/services/MessagingContainer.java
new file mode 100644
index 0000000..2b58466
--- /dev/null
+++ b/test-infra/camel-test-infra-messaging-common/src/test/java/org/apache/camel/test/infra/messaging/services/MessagingContainer.java
@@ -0,0 +1,28 @@
+/*
+ * 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.messaging.services;
+
+public interface MessagingContainer {
+
+ /**
+ * Gets the end point URL used exchanging messages through the default acceptor port
+ *
+ * @return the end point URL as a string
+ */
+ String defaultEndpoint();
+}
diff --git a/test-infra/camel-test-infra-messaging-common/src/test/java/org/apache/camel/test/infra/messaging/services/MessagingLocalContainerService.java b/test-infra/camel-test-infra-messaging-common/src/test/java/org/apache/camel/test/infra/messaging/services/MessagingLocalContainerService.java
new file mode 100644
index 0000000..c26b134
--- /dev/null
+++ b/test-infra/camel-test-infra-messaging-common/src/test/java/org/apache/camel/test/infra/messaging/services/MessagingLocalContainerService.java
@@ -0,0 +1,71 @@
+/*
+ * 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.messaging.services;
+
+import java.util.function.Function;
+
+import org.apache.camel.test.infra.common.services.ContainerService;
+import org.apache.camel.test.infra.messaging.common.MessagingProperties;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testcontainers.containers.GenericContainer;
+
+/**
+ * A specialized container that can be used to create message broker instances.
+ */
+public class MessagingLocalContainerService<T extends GenericContainer<T>> implements MessagingService, ContainerService<T> {
+ private static final Logger LOG = LoggerFactory.getLogger(MessagingLocalContainerService.class);
+
+ private final T container;
+ private final Function<T, String> endpointFunction;
+
+ public MessagingLocalContainerService(T container, Function<T, String> endpointFunction) {
+ this.container = container;
+ this.endpointFunction = endpointFunction;
+ }
+
+ @Override
+ public T getContainer() {
+ return container;
+ }
+
+ @Override
+ public String defaultEndpoint() {
+ return endpointFunction.apply(container);
+ }
+
+ @Override
+ public void registerProperties() {
+ System.setProperty(MessagingProperties.MESSAGING_BROKER_ADDRESS, defaultEndpoint());
+ }
+
+ @Override
+ public void initialize() {
+ LOG.info("Trying to start the message broker container");
+ container.start();
+
+ registerProperties();
+ LOG.info("Message broker running at address {}", defaultEndpoint());
+ }
+
+ @Override
+ public void shutdown() {
+ LOG.info("Stopping message broker container");
+ container.stop();
+ }
+}
diff --git a/test-infra/camel-test-infra-messaging-common/src/test/java/org/apache/camel/test/infra/messaging/services/MessagingRemoteService.java b/test-infra/camel-test-infra-messaging-common/src/test/java/org/apache/camel/test/infra/messaging/services/MessagingRemoteService.java
new file mode 100644
index 0000000..a487c53
--- /dev/null
+++ b/test-infra/camel-test-infra-messaging-common/src/test/java/org/apache/camel/test/infra/messaging/services/MessagingRemoteService.java
@@ -0,0 +1,43 @@
+/*
+ * 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.messaging.services;
+
+import org.apache.camel.test.infra.messaging.common.MessagingProperties;
+
+public class MessagingRemoteService implements MessagingService {
+
+ @Override
+ public void registerProperties() {
+ // NO-OP
+ }
+
+ @Override
+ public void initialize() {
+ registerProperties();
+ }
+
+ @Override
+ public void shutdown() {
+ // NO-OP
+ }
+
+ @Override
+ public String defaultEndpoint() {
+ return System.getProperty(MessagingProperties.MESSAGING_BROKER_ADDRESS);
+ }
+}
diff --git a/test-infra/camel-test-infra-messaging-common/src/test/java/org/apache/camel/test/infra/messaging/services/MessagingService.java b/test-infra/camel-test-infra-messaging-common/src/test/java/org/apache/camel/test/infra/messaging/services/MessagingService.java
new file mode 100644
index 0000000..521935c
--- /dev/null
+++ b/test-infra/camel-test-infra-messaging-common/src/test/java/org/apache/camel/test/infra/messaging/services/MessagingService.java
@@ -0,0 +1,43 @@
+/*
+ * 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.messaging.services;
+
+import org.apache.camel.test.infra.common.services.TestService;
+import org.junit.jupiter.api.extension.AfterAllCallback;
+import org.junit.jupiter.api.extension.BeforeAllCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
+
+public interface MessagingService extends TestService, BeforeAllCallback, AfterAllCallback {
+
+ /**
+ * Gets the default endpoint for the messaging service (ie.: amqp://host:port, or tcp://host:port, etc)
+ *
+ * @return the endpoint URL as a string in the specific format used by the service
+ */
+ String defaultEndpoint();
+
+ @Override
+ default void beforeAll(ExtensionContext extensionContext) throws Exception {
+ initialize();
+ }
+
+ @Override
+ default void afterAll(ExtensionContext extensionContext) throws Exception {
+ shutdown();
+ }
+}
diff --git a/test-infra/camel-test-infra-messaging-common/src/test/java/org/apache/camel/test/infra/messaging/services/MessagingServiceBuilder.java b/test-infra/camel-test-infra-messaging-common/src/test/java/org/apache/camel/test/infra/messaging/services/MessagingServiceBuilder.java
new file mode 100644
index 0000000..65de110
--- /dev/null
+++ b/test-infra/camel-test-infra-messaging-common/src/test/java/org/apache/camel/test/infra/messaging/services/MessagingServiceBuilder.java
@@ -0,0 +1,70 @@
+/*
+ * 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.messaging.services;
+
+import java.util.function.Function;
+import java.util.function.Supplier;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testcontainers.containers.GenericContainer;
+
+public class MessagingServiceBuilder<T extends GenericContainer<T>> {
+ private static final Logger LOG = LoggerFactory.getLogger(MessagingServiceBuilder.class);
+
+ private Supplier<T> containerSupplier;
+ private Function<T, String> endpointFunction;
+
+ protected MessagingServiceBuilder() {
+ }
+
+ public static <T extends GenericContainer<T>> MessagingServiceBuilder<T> newBuilder(Supplier<T> containerSupplier) {
+ MessagingServiceBuilder messagingServiceBuilder = new MessagingServiceBuilder<>();
+
+ messagingServiceBuilder.withContainer(containerSupplier);
+
+ return messagingServiceBuilder;
+ }
+
+ protected MessagingServiceBuilder<T> withContainer(Supplier<T> containerSupplier) {
+ this.containerSupplier = containerSupplier;
+
+ return this;
+ }
+
+ public MessagingServiceBuilder<T> withEndpointProvider(Function<T, String> endpointFunction) {
+ this.endpointFunction = endpointFunction;
+
+ return this;
+ }
+
+ public MessagingService build() {
+ String instanceType = System.getProperty("messaging.instance.type");
+
+ if (instanceType == null || instanceType.isEmpty()) {
+ LOG.info("Creating a new messaging local container service");
+ return new MessagingLocalContainerService(containerSupplier.get(), this.endpointFunction);
+ }
+
+ if (instanceType.equals("remote")) {
+ return new MessagingRemoteService();
+ }
+
+ throw new UnsupportedOperationException("Invalid messaging instance type");
+ }
+}
diff --git a/test-infra/pom.xml b/test-infra/pom.xml
index c5871f1..5123e11 100644
--- a/test-infra/pom.xml
+++ b/test-infra/pom.xml
@@ -48,5 +48,9 @@
<module>camel-test-infra-azure-common</module>
<module>camel-test-infra-azure-storage-blob</module>
<module>camel-test-infra-azure-storage-queue</module>
+ <module>camel-test-infra-messaging-common</module>
+ <module>camel-test-infra-artemis</module>
+ <module>camel-test-infra-dispatch-router</module>
+
</modules>
</project>
\ No newline at end of file