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/05 14:53:30 UTC
[camel] branch master updated: Added a reusable RabbitMQ test infra
code (#4570)
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 c508b0e Added a reusable RabbitMQ test infra code (#4570)
c508b0e is described below
commit c508b0e652aa9b9ea4a4dc87d003e22788a361a4
Author: Otavio Rodolfo Piske <or...@users.noreply.github.com>
AuthorDate: Thu Nov 5 15:53:06 2020 +0100
Added a reusable RabbitMQ test infra code (#4570)
Additionally:
- convert the RabbitMQ test code to use the reusable infra
- convert the embedded Qpid test code in the camel-rabbitmq component to
the reusable infra
- updated documentation
---
components/camel-rabbitmq/pom.xml | 17 +++-
components/camel-rabbitmq/readme.txt | 18 ++--
.../integration/AbstractRabbitMQIntTest.java | 76 ++++-------------
.../rabbitmq/integration/DockerTestUtils.java | 49 -----------
.../rabbitmq/integration/RabbitMQBasicIntTest.java | 18 ++--
.../integration/RabbitMQConsumerIntTest.java | 27 +++---
.../RabbitMQConsumerIntTestReplyTo.java | 12 +--
.../integration/RabbitMQDeadLetterArgsIntTest.java | 21 +++--
.../RabbitMQDeadLetterRoutingKeyIntTest.java | 33 ++++----
.../rabbitmq/integration/RabbitMQInOutIntTest.java | 33 ++++----
.../rabbitmq/integration/RabbitMQLoadIntTest.java | 14 ++--
.../integration/RabbitMQProducerIntTest.java | 49 ++++++-----
.../integration/RabbitMQReConnectionIntTest.java | 11 +--
.../RabbitMQRequeueHandledExceptionIntTest.java | 13 +--
.../integration/RabbitMQRequeueIntTest.java | 15 ++--
.../RabbitMQRequeueUnhandledExceptionIntTest.java | 12 +--
.../integration/RabbitMQSupendResumeIntTest.java | 11 +--
.../RabbitMQTemporaryQueueAutoRecoveryIntTest.java | 19 +++--
.../spring/AbstractRabbitMQSpringIntTest.java | 25 ++----
.../rabbitmq/qpid/RabbitMQConsumerQpidTest.java | 15 ----
.../qpid/RabbitMQConsumerQpidTestReplyTo.java | 16 ----
.../rabbitmq/qpid/RabbitMQInOutQpidTest.java | 15 ----
.../rabbitmq/qpid/RabbitMQLoadQpidTest.java | 15 ----
.../rabbitmq/qpid/RabbitMQProducerQpidTest.java | 16 ----
.../qpid/RabbitMQReConnectionQpidTest.java | 15 ----
.../rabbitmq/qpid/RabbitMQRequeueQpidTest.java | 16 ----
.../RabbitMQRequeueUnhandledExceptionQpidTest.java | 15 ----
.../qpid/RabbitMQSupendResumeQpidTest.java | 15 ----
.../infra/services/QpidEmbeddedService.java} | 95 ++++++++++------------
.../infra/services/RabbitMQServiceFactory.java} | 33 ++++----
.../resources/RabbitMQSpringIntTest-context.xml | 12 +--
parent/pom.xml | 5 ++
test-infra/camel-test-infra-rabbitmq/pom.xml | 62 ++++++++++++++
.../src/main/resources/META-INF/MANIFEST.MF | 0
.../infra/rabbitmq/common/RabbitMQProperties.java | 25 ++----
.../rabbitmq/services/ConnectionProperties.java | 24 ++----
.../services/RabbitMQLocalContainerService.java | 90 ++++++++++++++++++++
.../rabbitmq/services/RabbitMQRemoteService.java | 67 +++++++++++++++
.../infra/rabbitmq/services/RabbitMQService.java | 69 ++++++++++++++++
.../rabbitmq/services/RabbitMQServiceFactory.java | 45 ++++++++++
test-infra/pom.xml | 1 +
41 files changed, 623 insertions(+), 516 deletions(-)
diff --git a/components/camel-rabbitmq/pom.xml b/components/camel-rabbitmq/pom.xml
index 5b6bb7e..19b91d6 100644
--- a/components/camel-rabbitmq/pom.xml
+++ b/components/camel-rabbitmq/pom.xml
@@ -50,12 +50,24 @@
<artifactId>camel-support</artifactId>
</dependency>
- <!-- testing -->
+ <!-- test infra -->
+ <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-testcontainers-junit5</artifactId>
+ <artifactId>camel-test-infra-rabbitmq</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
<scope>test</scope>
</dependency>
+
+ <!-- testing -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test-spring-junit5</artifactId>
@@ -188,6 +200,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>${skipTests}</skipTests>
+ <argLine>-Drabbitmq.instance.type=qpid</argLine>
<excludes>
<exclude>**/*IntTest</exclude>
</excludes>
diff --git a/components/camel-rabbitmq/readme.txt b/components/camel-rabbitmq/readme.txt
index a470537..8bc17c8 100644
--- a/components/camel-rabbitmq/readme.txt
+++ b/components/camel-rabbitmq/readme.txt
@@ -3,18 +3,10 @@ Integration testing
The camel-rabbitmq component has both unit tests and integration tests.
-The integration tests requires a running RabbitMQ broker.
-All integration tests run docker container with RabbitMQ automatically.
+The integration tests requires docker, so that a RabbitMQ instance can be brought up by TestContainers. The execution
+of such tests is done automatically by checking either the docker socket or the DOCKER_HOST variable.
-The integration tests with Qpid could be run via Maven (disabled by default):
- mvn test -P qpid-itest
+It is also possible to run the tests using an embedded Qpid broker, for interoperability test. To run such tests,
+execute maven with the -Pqpid-itest profile:
-The broker can be run via Docker:
-
- docker run -it -p 5672:5672 -p 15672:15672 -e RABBITMQ_DEFAULT_USER=cameltest -e RABBITMQ_DEFAULT_PASS=cameltest --hostname my-rabbit --name some-rabbit rabbitmq:3-management
-
-Or to install RabbitMQ as standalone and then configure it:
-
- rabbitmq-server
- rabbitmqctl add_user cameltest cameltest
- rabbitmqctl set_permissions -p / cameltest ".*" ".*" ".*"
\ No newline at end of file
+```mvn -Pqpid-itest verify```
diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/AbstractRabbitMQIntTest.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/AbstractRabbitMQIntTest.java
index 6852278..ced2c06a 100644
--- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/AbstractRabbitMQIntTest.java
+++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/AbstractRabbitMQIntTest.java
@@ -17,44 +17,28 @@
package org.apache.camel.component.rabbitmq.integration;
import java.io.IOException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
-import org.apache.camel.test.testcontainers.junit5.ContainerAwareTestSupport;
-import org.apache.qpid.server.SystemLauncher;
-import org.apache.qpid.server.model.ConfiguredObject;
-import org.apache.qpid.server.model.SystemConfig;
-import org.junit.jupiter.api.BeforeEach;
+import org.apache.camel.component.rabbitmq.test.infra.services.RabbitMQServiceFactory;
+import org.apache.camel.test.infra.rabbitmq.services.ConnectionProperties;
+import org.apache.camel.test.infra.rabbitmq.services.RabbitMQService;
+import org.apache.camel.test.junit5.CamelTestSupport;
import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.extension.RegisterExtension;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.testcontainers.containers.GenericContainer;
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
-public abstract class AbstractRabbitMQIntTest extends ContainerAwareTestSupport {
- protected static final String INITIAL_CONFIGURATION = "qpid-test-initial-config.json";
- protected static SystemLauncher systemLauncher = new SystemLauncher();
-
- // Container starts once per test class
- private static GenericContainer container;
+public abstract class AbstractRabbitMQIntTest extends CamelTestSupport {
+ // Note: this is using the RabbitMQService from this module so that we can also run
+ // tests using the embedded QPid broker.
+ @RegisterExtension
+ public static RabbitMQService service = RabbitMQServiceFactory.createService();
protected Logger log = LoggerFactory.getLogger(getClass());
- protected boolean isStartDocker() {
- return true;
- }
-
- @Override
- @BeforeEach
- public void setUp() throws Exception {
- super.setUp();
- }
-
/**
* Helper method for creating a RabbitMQ connection to the test instance of the RabbitMQ server.
*
@@ -64,43 +48,17 @@ public abstract class AbstractRabbitMQIntTest extends ContainerAwareTestSupport
*/
protected Connection connection() throws IOException, TimeoutException {
ConnectionFactory factory = new ConnectionFactory();
- factory.setHost("localhost");
- factory.setPort(5672);
- factory.setUsername("cameltest");
- factory.setPassword("cameltest");
- factory.setVirtualHost("/");
- return factory.newConnection();
- }
+ ConnectionProperties properties = service.connectionProperties();
- /**
- * Helper method for creating a Qpid Broker-J system configuration for the initiate of the local AMQP server.
- */
- protected static Map<String, Object> createQpidSystemConfig() {
- Map<String, Object> attributes = new HashMap<>();
- URL initialConfig = AbstractRabbitMQIntTest.class.getClassLoader().getResource(INITIAL_CONFIGURATION);
- attributes.put(ConfiguredObject.TYPE, "Memory");
- attributes.put(SystemConfig.INITIAL_CONFIGURATION_LOCATION, initialConfig.toExternalForm());
- attributes.put(SystemConfig.STARTUP_LOGGED_TO_SYSTEM_OUT, false);
-
- return attributes;
- }
+ factory.setHost(properties.hostname());
- @Override
- protected GenericContainer<?> createContainer() {
- container = isStartDocker() ? DockerTestUtils.rabbitMQContainer() : null;
- return (GenericContainer<?>) container;
- }
+ factory.setPort(properties.port());
- @Override
- protected void cleanupResources() throws Exception {
- super.cleanupResources();
+ factory.setUsername(properties.username());
- if (container != null) {
- container.stop();
- }
+ factory.setPassword(properties.password());
+ factory.setVirtualHost("/");
+ return factory.newConnection();
}
- protected long containerShutdownTimeout() {
- return TimeUnit.MINUTES.toSeconds(1L);
- }
}
diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/DockerTestUtils.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/DockerTestUtils.java
deleted file mode 100644
index 5e9ad05..0000000
--- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/DockerTestUtils.java
+++ /dev/null
@@ -1,49 +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.component.rabbitmq.integration;
-
-import java.util.Arrays;
-
-import org.apache.camel.test.testcontainers.junit5.Wait;
-import org.testcontainers.containers.GenericContainer;
-
-public class DockerTestUtils {
- public static final String CONTAINER_IMAGE = "rabbitmq:3-management";
- public static final String CONTAINER_NAME = "some-rabbit";
- public static final int EXPOSE_PORT_BROKER = 5672;
- public static final int EXPOSE_PORT_MANAGEMENT = 15672;
-
- protected DockerTestUtils() {
- }
-
- public static GenericContainer rabbitMQContainer() {
- // docker run -it -p 5672:5672 -p 15672:15672
- // -e RABBITMQ_DEFAULT_USER=cameltest
- // -e RABBITMQ_DEFAULT_PASS=cameltest
- // --hostname my-rabbit
- // --name some-rabbit rabbitmq:3-management
- GenericContainer container = new GenericContainer<>(CONTAINER_IMAGE).withNetworkAliases(CONTAINER_NAME)
- .withExposedPorts(EXPOSE_PORT_BROKER, EXPOSE_PORT_MANAGEMENT)
- .withEnv("RABBITMQ_DEFAULT_USER", "cameltest").withEnv("RABBITMQ_DEFAULT_PASS", "cameltest")
- .withCreateContainerCmdModifier(cmd -> cmd.withHostName("my-rabbit"))
- .waitingFor(Wait.forLogMessage(".*Server startup complete.*\n", 1));
- container.setPortBindings(Arrays.asList(String.format("%d:%d", EXPOSE_PORT_BROKER, EXPOSE_PORT_BROKER),
- String.format("%d:%d", EXPOSE_PORT_MANAGEMENT, EXPOSE_PORT_MANAGEMENT)));
-
- return container;
- }
-}
diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQBasicIntTest.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQBasicIntTest.java
index 1ca03fa..97df93c 100644
--- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQBasicIntTest.java
+++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQBasicIntTest.java
@@ -16,29 +16,31 @@
*/
package org.apache.camel.component.rabbitmq.integration;
-import org.apache.camel.Endpoint;
import org.apache.camel.EndpointInject;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.infra.rabbitmq.services.ConnectionProperties;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class RabbitMQBasicIntTest extends AbstractRabbitMQIntTest {
- // Startup RabbitMQ via Docker (see readme.txt in camel-rabbitmq folder)
-
- @EndpointInject("rabbitmq:localhost:5672/foo?username=cameltest&password=cameltest")
- private Endpoint foo;
-
- @EndpointInject("rabbitmq:localhost:5672/bar?username=cameltest&password=cameltest")
- private Endpoint bar;
+ String foo;
+ String bar;
@EndpointInject("mock:result")
private MockEndpoint mock;
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
+ ConnectionProperties connectionProperties = service.connectionProperties();
+ foo = String.format("rabbitmq:%s:%d/foo?username=%s&password=%s", connectionProperties.hostname(),
+ connectionProperties.port(), connectionProperties.username(), connectionProperties.password());
+
+ bar = String.format("rabbitmq:%s:%d/bar?username=%s&password=%s", connectionProperties.hostname(),
+ connectionProperties.port(), connectionProperties.username(), connectionProperties.password());
+
return new RouteBuilder() {
@Override
public void configure() throws Exception {
diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQConsumerIntTest.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQConsumerIntTest.java
index 021e3a8..9eb443f 100644
--- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQConsumerIntTest.java
+++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQConsumerIntTest.java
@@ -28,11 +28,11 @@ import java.util.concurrent.TimeoutException;
import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import org.apache.camel.BindToRegistry;
-import org.apache.camel.Endpoint;
import org.apache.camel.EndpointInject;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.component.rabbitmq.RabbitMQConstants;
+import org.apache.camel.test.infra.rabbitmq.services.ConnectionProperties;
import org.awaitility.Awaitility;
import org.junit.jupiter.api.Test;
@@ -43,21 +43,9 @@ public class RabbitMQConsumerIntTest extends AbstractRabbitMQIntTest {
private static final String QUEUE = "q1";
private static final String MSG = "hello world";
- @EndpointInject("rabbitmq:localhost:5672/" + EXCHANGE
- + "?username=cameltest&password=cameltest&arg.queue.x-single-active-consumer=true")
- private Endpoint from;
-
@EndpointInject("mock:result")
private MockEndpoint to;
- @EndpointInject("rabbitmq:localhost:5672/" + HEADERS_EXCHANGE
- + "?username=cameltest&password=cameltest&exchangeType=headers&queue=" + QUEUE + "&args=#args")
- private Endpoint headersExchangeWithQueue;
-
- @EndpointInject("rabbitmq:localhost:5672/" + "ex7"
- + "?username=cameltest&password=cameltest&exchangeType=headers&autoDelete=false&durable=true&queue=q7&arg.binding.fizz=buzz")
- private Endpoint headersExchangeWithQueueDefiniedInline;
-
@BindToRegistry("args")
private Map<String, Object> bindingArgs = new HashMap<String, Object>() {
{
@@ -67,13 +55,20 @@ public class RabbitMQConsumerIntTest extends AbstractRabbitMQIntTest {
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
+ ConnectionProperties connectionProperties = service.connectionProperties();
+
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from(from).to(to);
- from(headersExchangeWithQueue).to(to);
- from(headersExchangeWithQueueDefiniedInline).to(to);
+ fromF("rabbitmq:localhost:%d/%s?username=%s&password=%s&arg.queue.x-single-active-consumer=true",
+ connectionProperties.port(), EXCHANGE, connectionProperties.username(), connectionProperties.password())
+ .to(to);
+ fromF("rabbitmq:localhost:%d/%s?username=%s&password=%s&exchangeType=headers&queue=%s&args=#args",
+ connectionProperties.port(), HEADERS_EXCHANGE, connectionProperties.username(),
+ connectionProperties.password(), QUEUE).to(to);
+ fromF("rabbitmq:localhost:%d/ex7?username=%s&password=%s&exchangeType=headers&autoDelete=false&durable=true&queue=q7&arg.binding.fizz=buzz",
+ connectionProperties.port(), connectionProperties.username(), connectionProperties.password()).to(to);
}
};
}
diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQConsumerIntTestReplyTo.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQConsumerIntTestReplyTo.java
index 4ea10c1..942db0c 100644
--- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQConsumerIntTestReplyTo.java
+++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQConsumerIntTestReplyTo.java
@@ -26,9 +26,8 @@ import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.DefaultConsumer;
import com.rabbitmq.client.Envelope;
-import org.apache.camel.Endpoint;
-import org.apache.camel.EndpointInject;
import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.infra.rabbitmq.services.ConnectionProperties;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -48,9 +47,6 @@ public class RabbitMQConsumerIntTestReplyTo extends AbstractRabbitMQIntTest {
protected Channel channel;
- @EndpointInject("rabbitmq:localhost:5672/" + EXCHANGE + "?username=cameltest&password=cameltest&routingKey=" + ROUTING_KEY)
- private Endpoint from;
-
private Connection connection;
@BeforeEach
@@ -61,6 +57,8 @@ public class RabbitMQConsumerIntTestReplyTo extends AbstractRabbitMQIntTest {
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
+ ConnectionProperties connectionProperties = service.connectionProperties();
+
context().setTracing(true);
return new RouteBuilder() {
@@ -68,7 +66,9 @@ public class RabbitMQConsumerIntTestReplyTo extends AbstractRabbitMQIntTest {
public void configure() throws Exception {
log.info("Building routes...");
- from(from).log(body().toString()).setBody(simple(REPLY));
+ fromF("rabbitmq:localhost:%d/%s?username=%s&password=%s&routingKey=%s", connectionProperties.port(),
+ EXCHANGE, connectionProperties.username(), connectionProperties.password(), ROUTING_KEY)
+ .log(body().toString()).setBody(simple(REPLY));
}
};
}
diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQDeadLetterArgsIntTest.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQDeadLetterArgsIntTest.java
index a63391f..09b556c 100644
--- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQDeadLetterArgsIntTest.java
+++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQDeadLetterArgsIntTest.java
@@ -28,6 +28,7 @@ import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.component.rabbitmq.RabbitMQEndpoint;
+import org.apache.camel.test.infra.rabbitmq.services.ConnectionProperties;
import org.apache.camel.util.json.JsonArray;
import org.apache.camel.util.json.JsonObject;
import org.apache.camel.util.json.Jsoner;
@@ -37,8 +38,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
public class RabbitMQDeadLetterArgsIntTest extends AbstractRabbitMQIntTest {
- private static final String LOCAL_RABBITMQ_PARAMS
- = "hostname=localhost&portNumber=5672&username=cameltest&password=cameltest";
private static final String QUEUE = "queue";
private static final String DLQ = QUEUE + "_dlq";
private static final String QUEUE_SKIP_DECLARE = "queue_skip_declare";
@@ -69,13 +68,18 @@ public class RabbitMQDeadLetterArgsIntTest extends AbstractRabbitMQIntTest {
@Override
protected RouteBuilder createRouteBuilder() {
+ ConnectionProperties connectionProperties = service.connectionProperties();
+ final String localRabbitmqParams = String.format("hostname=%s&portNumber=%d&username=%s&password=%s",
+ connectionProperties.hostname(), connectionProperties.port(), connectionProperties.username(),
+ connectionProperties.password());
+
return new RouteBuilder() {
@Override
public void configure() {
final String endpointUri1 = String.format(
"rabbitmq:exchange?%s&queue=%s&deadLetterQueue=%s&autoAck=false&durable=true&args=#dlqArgs&deadLetterExchange=dlqexchange",
- LOCAL_RABBITMQ_PARAMS, QUEUE, DLQ);
+ localRabbitmqParams, QUEUE, DLQ);
from("direct:start")
.to(endpointUri1);
fromF(endpointUri1)
@@ -86,12 +90,12 @@ public class RabbitMQDeadLetterArgsIntTest extends AbstractRabbitMQIntTest {
final String endpointUri2 = String.format(
"rabbitmq:anotherExchange?%s&queue=%s&deadLetterQueue=%s&autoAck=false&durable=true&deadLetterExchange=anotherExchange&skipDlqDeclare=true",
- LOCAL_RABBITMQ_PARAMS, QUEUE_SKIP_DECLARE, DLQ_SKIP_DECLARE);
+ localRabbitmqParams, QUEUE_SKIP_DECLARE, DLQ_SKIP_DECLARE);
from("direct:start_skip_dlq_declare")
.to(endpointUri2);
from(endpointUri2)
.throwException(new RuntimeException("Simulated"));
- fromF("rabbitmq:anotherExchange?%s&queue=%s&args=#args", LOCAL_RABBITMQ_PARAMS, DLQ_SKIP_DECLARE)
+ fromF("rabbitmq:anotherExchange?%s&queue=%s&args=#args", localRabbitmqParams, DLQ_SKIP_DECLARE)
.convertBodyTo(String.class)
.to(receivedDlqEndpoint);
}
@@ -100,6 +104,8 @@ public class RabbitMQDeadLetterArgsIntTest extends AbstractRabbitMQIntTest {
@Test
public void testDlq() throws Exception {
+ ConnectionProperties connectionProperties = service.connectionProperties();
+
template.sendBody("direct:start_skip_dlq_declare", "Hi");
receivedDlqEndpoint.expectedMessageCount(1);
receivedDlqEndpoint.expectedBodiesReceived("Hi");
@@ -115,8 +121,9 @@ public class RabbitMQDeadLetterArgsIntTest extends AbstractRabbitMQIntTest {
String rabbitApiResponse = template.requestBody(
String.format(
- "http://localhost:%s/api/queues?authUsername=cameltest&authPassword=cameltest&authMethod=Basic&httpMethod=GET",
- DockerTestUtils.EXPOSE_PORT_MANAGEMENT),
+ "http://%s:%s/api/queues?authUsername=%s&authPassword=%s&authMethod=Basic&httpMethod=GET",
+ connectionProperties.hostname(), service.getHttpPort(), connectionProperties.username(),
+ connectionProperties.password()),
"", String.class);
JsonArray rabbitApiResponseJson = (JsonArray) Jsoner.deserialize(rabbitApiResponse);
diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQDeadLetterRoutingKeyIntTest.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQDeadLetterRoutingKeyIntTest.java
index f6e436e..a3197bf 100644
--- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQDeadLetterRoutingKeyIntTest.java
+++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQDeadLetterRoutingKeyIntTest.java
@@ -31,6 +31,7 @@ import org.apache.camel.Produce;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.infra.rabbitmq.services.ConnectionProperties;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -44,19 +45,6 @@ public class RabbitMQDeadLetterRoutingKeyIntTest extends AbstractRabbitMQIntTest
private static final Logger LOGGER = LoggerFactory.getLogger(RabbitMQDeadLetterRoutingKeyIntTest.class);
- private static final String CONSUMER
- = "rabbitmq:ex9?hostname=localhost&portNumber=5672&username=cameltest&password=cameltest"
- + "&skipExchangeDeclare=false"
- + "&skipQueueDeclare=false" + "&autoDelete=false" + "&durable=true" + "&autoAck=false" + "&queue=q9"
- + "&routingKey=rk1"
- + "&deadLetterExchange=dlx" + "&deadLetterQueue=dlq" + "&deadLetterExchangeType=fanout";
-
- private static final String CONSUMER_WITH_DEADLETTER_ROUTING_KEY
- = "rabbitmq:ex10?hostname=localhost&portNumber=5672&username=cameltest&password=cameltest"
- + "&skipExchangeDeclare=false" + "&skipQueueDeclare=false" + "&autoDelete=false&durable=true"
- + "&autoAck=false&queue=q10" + "&routingKey=rk1" + "&deadLetterExchange=dlx" + "&deadLetterQueue=dlq"
- + "&deadLetterExchangeType=fanout" + "&deadLetterRoutingKey=rk2";
-
private Connection connection;
private Channel channel;
private Channel deadLetterChannel;
@@ -69,12 +57,27 @@ public class RabbitMQDeadLetterRoutingKeyIntTest extends AbstractRabbitMQIntTest
@Override
protected RouteBuilder createRouteBuilder() {
+ ConnectionProperties connectionProperties = service.connectionProperties();
+
+ String consumer = String.format("rabbitmq:ex9?hostname=%s&portNumber=%d&username=%s&password=%s"
+ + "&skipExchangeDeclare=false&skipQueueDeclare=false&autoDelete=false&durable=true&autoAck=false"
+ + "&queue=q9&routingKey=rk1&deadLetterExchange=dlx&deadLetterQueue=dlq&deadLetterExchangeType=fanout",
+ connectionProperties.hostname(), connectionProperties.port(), connectionProperties.username(),
+ connectionProperties.password());
+
+ String consumerWithDlqRoutingKey = String.format("rabbitmq:ex10?hostname=%s&portNumber=%d&username=%s&password=%s"
+ + "&skipExchangeDeclare=false&skipQueueDeclare=false&autoDelete=false&durable=true"
+ + "&autoAck=false&queue=q10&routingKey=rk1&deadLetterExchange=dlx&deadLetterQueue=dlq"
+ + "&deadLetterExchangeType=fanout&deadLetterRoutingKey=rk2",
+ connectionProperties.hostname(), connectionProperties.port(), connectionProperties.username(),
+ connectionProperties.password());
+
return new RouteBuilder() {
@Override
public void configure() {
- from(CONSUMER).to(receivedEndpoint);
- from(CONSUMER_WITH_DEADLETTER_ROUTING_KEY).to(receivedEndpoint);
+ from(consumer).to(receivedEndpoint);
+ from(consumerWithDlqRoutingKey).to(receivedEndpoint);
}
};
}
diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQInOutIntTest.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQInOutIntTest.java
index 1d22e61..855378d 100644
--- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQInOutIntTest.java
+++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQInOutIntTest.java
@@ -28,7 +28,6 @@ import java.util.List;
import java.util.Map;
import org.apache.camel.CamelExecutionException;
-import org.apache.camel.Endpoint;
import org.apache.camel.EndpointInject;
import org.apache.camel.Exchange;
import org.apache.camel.ExchangePattern;
@@ -43,6 +42,7 @@ import org.apache.camel.component.rabbitmq.testbeans.TestPartiallySerializableOb
import org.apache.camel.component.rabbitmq.testbeans.TestSerializableObject;
import org.apache.camel.spi.Registry;
import org.apache.camel.support.SimpleRegistry;
+import org.apache.camel.test.infra.rabbitmq.services.ConnectionProperties;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
@@ -50,7 +50,7 @@ import org.junit.jupiter.api.TestMethodOrder;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
-@TestMethodOrder(MethodOrderer.Alphanumeric.class)
+@TestMethodOrder(MethodOrderer.MethodName.class)
public class RabbitMQInOutIntTest extends AbstractRabbitMQIntTest {
public static final String ROUTING_KEY = "rk5";
@@ -64,20 +64,6 @@ public class RabbitMQInOutIntTest extends AbstractRabbitMQIntTest {
@Produce("direct:rabbitMQ")
protected ProducerTemplate directProducer;
- @EndpointInject("rabbitmq:localhost:5672/" + EXCHANGE
- + "?threadPoolSize=1&exchangeType=direct&username=cameltest&password=cameltest"
- + "&autoAck=true&queue=q4&routingKey="
- + ROUTING_KEY + "&transferException=true&requestTimeout=" + TIMEOUT_MS
- + "&allowMessageBodySerialization=true")
- private Endpoint rabbitMQEndpoint;
-
- @EndpointInject("rabbitmq:localhost:5672/" + EXCHANGE_NO_ACK
- + "?threadPoolSize=1&exchangeType=direct&username=cameltest&password=cameltest"
- + "&autoAck=false&autoDelete=false&durable=false&queue=q5&routingKey=" + ROUTING_KEY
- + "&transferException=true&requestTimeout="
- + TIMEOUT_MS + "&args=#args" + "&allowMessageBodySerialization=true")
- private Endpoint noAutoAckEndpoint;
-
@EndpointInject("mock:result")
private MockEndpoint resultEndpoint;
@@ -94,6 +80,21 @@ public class RabbitMQInOutIntTest extends AbstractRabbitMQIntTest {
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
+ ConnectionProperties connectionProperties = service.connectionProperties();
+ String rabbitMQEndpoint = String
+ .format("rabbitmq:%s:%d/%s?threadPoolSize=1&exchangeType=direct&username=%s&password=%s"
+ + "&autoAck=true&queue=q4&routingKey=%s&transferException=true&requestTimeout=%d&allowMessageBodySerialization=true",
+ connectionProperties.hostname(), connectionProperties.port(), EXCHANGE,
+ connectionProperties.username(), connectionProperties.password(),
+ ROUTING_KEY, TIMEOUT_MS);
+
+ String noAutoAckEndpoint = String.format("rabbitmq:%s:%d/%s"
+ + "?threadPoolSize=1&exchangeType=direct&username=%s&password=%s"
+ + "&autoAck=false&autoDelete=false&durable=false&queue=q5&routingKey=%s"
+ + "&transferException=true&requestTimeout=%d&args=#args&allowMessageBodySerialization=true",
+ connectionProperties.hostname(), connectionProperties.port(), EXCHANGE_NO_ACK, connectionProperties.username(),
+ connectionProperties.password(), ROUTING_KEY, TIMEOUT_MS);
+
return new RouteBuilder() {
@Override
diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQLoadIntTest.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQLoadIntTest.java
index 2923d15..0e2d245 100644
--- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQLoadIntTest.java
+++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQLoadIntTest.java
@@ -31,6 +31,7 @@ import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.component.rabbitmq.RabbitMQConstants;
+import org.apache.camel.test.infra.rabbitmq.services.ConnectionProperties;
import org.junit.jupiter.api.Test;
/**
@@ -45,11 +46,6 @@ public class RabbitMQLoadIntTest extends AbstractRabbitMQIntTest {
@Produce("direct:rabbitMQ")
protected ProducerTemplate directProducer;
- @EndpointInject("rabbitmq:localhost:5672/ex4?username=cameltest&password=cameltest" + "&queue=q4&routingKey=" + ROUTING_KEY
- + "&threadPoolSize=" + (CONSUMER_COUNT + 5)
- + "&concurrentConsumers=" + CONSUMER_COUNT)
- private Endpoint rabbitMQEndpoint;
-
@EndpointInject("mock:producing")
private MockEndpoint producingMockEndpoint;
@@ -58,6 +54,14 @@ public class RabbitMQLoadIntTest extends AbstractRabbitMQIntTest {
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
+ ConnectionProperties connectionProperties = service.connectionProperties();
+
+ String rabbitMQEndpoint = String.format("rabbitmq:localhost:%d/ex4?username=%s&password=%s&queue=q4&routingKey=%s"
+ + "&threadPoolSize=%d&concurrentConsumers=%d",
+ connectionProperties.port(),
+ connectionProperties.username(), connectionProperties.password(), ROUTING_KEY, CONSUMER_COUNT + 5,
+ CONSUMER_COUNT);
+
return new RouteBuilder() {
@Override
diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQProducerIntTest.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQProducerIntTest.java
index d8efdc4..b0c39b4 100644
--- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQProducerIntTest.java
+++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQProducerIntTest.java
@@ -34,6 +34,7 @@ import org.apache.camel.RuntimeCamelException;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.rabbitmq.RabbitMQConstants;
import org.apache.camel.support.ObjectHelper;
+import org.apache.camel.test.infra.rabbitmq.services.ConnectionProperties;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -52,19 +53,6 @@ public class RabbitMQProducerIntTest extends AbstractRabbitMQIntTest {
private static final String EXCHANGE = "ex1";
private static final String ROUTE = "route1";
private static final String CUSTOM_HEADER = "CustomHeader";
- private static final String BASIC_URI_FORMAT
- = "rabbitmq:localhost:5672/%s?routingKey=%s&username=cameltest&password=cameltest&skipQueueDeclare=true";
- private static final String BASIC_URI = String.format(BASIC_URI_FORMAT, EXCHANGE, ROUTE);
- private static final String ALLOW_NULL_HEADERS = BASIC_URI + "&allowNullHeaders=true&allowCustomHeaders=false";
- private static final String ALLOW_CUSTOM_HEADERS = BASIC_URI + "&allowCustomHeaders=true";
- private static final String PUBLISHER_ACKNOWLEDGES_URI = BASIC_URI + "&mandatory=true&publisherAcknowledgements=true";
- private static final String PUBLISHER_ACKNOWLEDGES_BAD_ROUTE_URI
- = String.format(BASIC_URI_FORMAT, EXCHANGE, "route2") + "&publisherAcknowledgements=true";
- private static final String GUARANTEED_DELIVERY_URI = BASIC_URI + "&mandatory=true&guaranteedDeliveries=true";
- private static final String GUARANTEED_DELIVERY_BAD_ROUTE_NOT_MANDATORY_URI
- = String.format(BASIC_URI_FORMAT, EXCHANGE, "route2") + "&guaranteedDeliveries=true";
- private static final String GUARANTEED_DELIVERY_BAD_ROUTE_URI
- = String.format(BASIC_URI_FORMAT, EXCHANGE, "route2") + "&mandatory=true&guaranteedDeliveries=true";
@Produce("direct:start")
protected ProducerTemplate template;
@@ -96,22 +84,39 @@ public class RabbitMQProducerIntTest extends AbstractRabbitMQIntTest {
private Connection connection;
private Channel channel;
+ private String getBasicURI(String route) {
+ ConnectionProperties connectionProperties = service.connectionProperties();
+
+ return String.format("rabbitmq:%s:%d/%s?routingKey=%s&username=%s&password=%s&skipQueueDeclare=true",
+ connectionProperties.hostname(), connectionProperties.port(),
+ EXCHANGE, route, connectionProperties.username(), connectionProperties.password());
+ }
+
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
+ String basicURI = getBasicURI(ROUTE);
+ String allowNullHeaders = basicURI + "&allowNullHeaders=true&allowCustomHeaders=false";
+ String allowCustomHeaders = basicURI + "&allowCustomHeaders=true";
+ String publisherAcknowledgesUri = basicURI + "&mandatory=true&publisherAcknowledgements=true";
+ String publisherAcknowledgesBadRouteUri = getBasicURI("route2") + "&publisherAcknowledgements=true";
+ String guaranteedDeliveryUri = basicURI + "&mandatory=true&guaranteedDeliveries=true";
+ String guaranteedDeliveryBadRouteNotMandatoryUri = getBasicURI("route2") + "&guaranteedDeliveries=true";
+ String guaranteedDeliveryBadRouteUri = getBasicURI("route2") + "&mandatory=true&guaranteedDeliveries=true";
+
context().setTracing(true);
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("direct:start").to(BASIC_URI);
- from("direct:start-allow-null-headers").to(ALLOW_NULL_HEADERS);
- from("direct:start-not-allow-custom-headers").to(ALLOW_NULL_HEADERS);
- from("direct:start-allow-custom-headers").to(ALLOW_CUSTOM_HEADERS);
- from("direct:start-with-confirms").to(PUBLISHER_ACKNOWLEDGES_URI);
- from("direct:start-with-confirms-bad-route").to(PUBLISHER_ACKNOWLEDGES_BAD_ROUTE_URI);
- from("direct:start-with-guaranteed-delivery").to(GUARANTEED_DELIVERY_URI);
- from("direct:start-with-guaranteed-delivery-bad-route").to(GUARANTEED_DELIVERY_BAD_ROUTE_URI);
+ from("direct:start").to(basicURI);
+ from("direct:start-allow-null-headers").to(allowNullHeaders);
+ from("direct:start-not-allow-custom-headers").to(allowNullHeaders);
+ from("direct:start-allow-custom-headers").to(allowCustomHeaders);
+ from("direct:start-with-confirms").to(publisherAcknowledgesUri);
+ from("direct:start-with-confirms-bad-route").to(publisherAcknowledgesBadRouteUri);
+ from("direct:start-with-guaranteed-delivery").to(guaranteedDeliveryUri);
+ from("direct:start-with-guaranteed-delivery-bad-route").to(guaranteedDeliveryBadRouteUri);
from("direct:start-with-guaranteed-delivery-bad-route-but-not-mandatory")
- .to(GUARANTEED_DELIVERY_BAD_ROUTE_NOT_MANDATORY_URI);
+ .to(guaranteedDeliveryBadRouteNotMandatoryUri);
}
};
}
diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQReConnectionIntTest.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQReConnectionIntTest.java
index 536deee..ba84aed 100644
--- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQReConnectionIntTest.java
+++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQReConnectionIntTest.java
@@ -29,6 +29,7 @@ import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.component.rabbitmq.RabbitMQConstants;
+import org.apache.camel.test.infra.rabbitmq.services.ConnectionProperties;
import org.junit.jupiter.api.Test;
/**
@@ -48,11 +49,6 @@ public class RabbitMQReConnectionIntTest extends AbstractRabbitMQIntTest {
@Produce("direct:rabbitMQ")
protected ProducerTemplate directProducer;
- @EndpointInject("rabbitmq:localhost:5672/" + EXCHANGE + "?username=cameltest&password=cameltest"
- + "&queue=q3&routingKey=rk3" + "&automaticRecoveryEnabled=true"
- + "&requestedHeartbeat=1000" + "&connectionTimeout=5000")
- private Endpoint rabbitMQEndpoint;
-
@EndpointInject("mock:producing")
private MockEndpoint producingMockEndpoint;
@@ -61,6 +57,11 @@ public class RabbitMQReConnectionIntTest extends AbstractRabbitMQIntTest {
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
+ ConnectionProperties connectionProperties = service.connectionProperties();
+ String rabbitMQEndpoint = String.format("rabbitmq:localhost:%d/%s?username=%s&password=%s"
+ + "&queue=q3&routingKey=rk3&automaticRecoveryEnabled=true&requestedHeartbeat=1000&connectionTimeout=5000",
+ connectionProperties.port(), EXCHANGE, connectionProperties.username(), connectionProperties.password());
+
return new RouteBuilder() {
@Override
diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQRequeueHandledExceptionIntTest.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQRequeueHandledExceptionIntTest.java
index 658671a..61dbf08 100644
--- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQRequeueHandledExceptionIntTest.java
+++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQRequeueHandledExceptionIntTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.camel.component.rabbitmq.integration;
-import org.apache.camel.Endpoint;
import org.apache.camel.EndpointInject;
import org.apache.camel.ExchangePattern;
import org.apache.camel.Produce;
@@ -24,6 +23,7 @@ import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.component.rabbitmq.RabbitMQConstants;
+import org.apache.camel.test.infra.rabbitmq.services.ConnectionProperties;
import org.junit.jupiter.api.Test;
/**
@@ -35,10 +35,6 @@ public class RabbitMQRequeueHandledExceptionIntTest extends AbstractRabbitMQIntT
@Produce("direct:rabbitMQ")
protected ProducerTemplate directProducer;
- @EndpointInject("rabbitmq:localhost:5672/ex4?username=cameltest&password=cameltest" + "&autoAck=false&queue=q4&routingKey="
- + ROUTING_KEY)
- private Endpoint rabbitMQEndpoint;
-
@EndpointInject("mock:producing")
private MockEndpoint producingMockEndpoint;
@@ -47,6 +43,13 @@ public class RabbitMQRequeueHandledExceptionIntTest extends AbstractRabbitMQIntT
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
+ ConnectionProperties connectionProperties = service.connectionProperties();
+
+ String rabbitMQEndpoint
+ = String.format("rabbitmq:localhost:%d/ex4?username=%s&password=%s&autoAck=false&queue=q4&routingKey=%s",
+ connectionProperties.port(), connectionProperties.username(), connectionProperties.password(),
+ ROUTING_KEY);
+
return new RouteBuilder() {
@Override
diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQRequeueIntTest.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQRequeueIntTest.java
index d9a731e..7ce4d49 100644
--- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQRequeueIntTest.java
+++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQRequeueIntTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.camel.component.rabbitmq.integration;
-import org.apache.camel.Endpoint;
import org.apache.camel.EndpointInject;
import org.apache.camel.ExchangePattern;
import org.apache.camel.Produce;
@@ -24,6 +23,7 @@ import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.component.rabbitmq.RabbitMQConstants;
+import org.apache.camel.test.infra.rabbitmq.services.ConnectionProperties;
import org.awaitility.Awaitility;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
@@ -43,12 +43,6 @@ public class RabbitMQRequeueIntTest extends AbstractRabbitMQIntTest {
@Produce("direct:rabbitMQ")
protected ProducerTemplate directProducer;
- @EndpointInject("rabbitmq:localhost:5672/ex4?username=cameltest&password=cameltest"
- + "&autoAck=false&autoDelete=false&durable=true&queue=q4&deadLetterExchange=dlx&deadLetterExchangeType=fanout"
- + "&deadLetterQueue=" + DEAD_LETTER_QUEUE_NAME
- + "&routingKey=" + ROUTING_KEY)
- private Endpoint rabbitMQEndpoint;
-
@EndpointInject("mock:producing")
private MockEndpoint producingMockEndpoint;
@@ -80,6 +74,13 @@ public class RabbitMQRequeueIntTest extends AbstractRabbitMQIntTest {
@Override
protected RouteBuilder createRouteBuilder() {
+ ConnectionProperties connectionProperties = service.connectionProperties();
+ String rabbitMQEndpoint = String.format("rabbitmq:localhost:%d/ex4?username=%s&password=%s"
+ + "&autoAck=false&autoDelete=false&durable=true&queue=q4&deadLetterExchange=dlx&deadLetterExchangeType=fanout"
+ + "&deadLetterQueue=%s&routingKey=%s",
+ connectionProperties.port(), connectionProperties.username(),
+ connectionProperties.password(), DEAD_LETTER_QUEUE_NAME, ROUTING_KEY);
+
return new RouteBuilder() {
@Override
diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQRequeueUnhandledExceptionIntTest.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQRequeueUnhandledExceptionIntTest.java
index cf0da70..280eeb8 100644
--- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQRequeueUnhandledExceptionIntTest.java
+++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQRequeueUnhandledExceptionIntTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.camel.component.rabbitmq.integration;
-import org.apache.camel.Endpoint;
import org.apache.camel.EndpointInject;
import org.apache.camel.ExchangePattern;
import org.apache.camel.Produce;
@@ -24,6 +23,7 @@ import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.component.rabbitmq.RabbitMQConstants;
+import org.apache.camel.test.infra.rabbitmq.services.ConnectionProperties;
import org.junit.jupiter.api.Test;
/**
@@ -35,10 +35,6 @@ public class RabbitMQRequeueUnhandledExceptionIntTest extends AbstractRabbitMQIn
@Produce("direct:rabbitMQ")
protected ProducerTemplate directProducer;
- @EndpointInject("rabbitmq:localhost:5672/ex4?username=cameltest&password=cameltest" + "&autoAck=false&queue=q4&routingKey="
- + ROUTING_KEY)
- private Endpoint rabbitMQEndpoint;
-
@EndpointInject("mock:producing")
private MockEndpoint producingMockEndpoint;
@@ -47,6 +43,12 @@ public class RabbitMQRequeueUnhandledExceptionIntTest extends AbstractRabbitMQIn
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
+ ConnectionProperties connectionProperties = service.connectionProperties();
+ String rabbitMQEndpoint
+ = String.format("rabbitmq:localhost:%d/ex4?username=%s&password=%s&autoAck=false&queue=q4&routingKey=%s",
+ connectionProperties.port(), connectionProperties.username(), connectionProperties.password(),
+ ROUTING_KEY);
+
return new RouteBuilder() {
@Override
diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQSupendResumeIntTest.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQSupendResumeIntTest.java
index d01d445..b44fbb6 100644
--- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQSupendResumeIntTest.java
+++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQSupendResumeIntTest.java
@@ -18,12 +18,12 @@ package org.apache.camel.component.rabbitmq.integration;
import java.util.concurrent.TimeUnit;
-import org.apache.camel.Endpoint;
import org.apache.camel.EndpointInject;
import org.apache.camel.Produce;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.infra.rabbitmq.services.ConnectionProperties;
import org.junit.jupiter.api.Test;
public class RabbitMQSupendResumeIntTest extends AbstractRabbitMQIntTest {
@@ -32,15 +32,16 @@ public class RabbitMQSupendResumeIntTest extends AbstractRabbitMQIntTest {
@EndpointInject("mock:result")
private MockEndpoint resultEndpoint;
- @EndpointInject("rabbitmq:localhost:5672/" + EXCHANGE
- + "?username=cameltest&password=cameltest&queue=q6&routingKey=rk3&autoDelete=false")
- private Endpoint rabbitMQEndpoint;
-
@Produce("direct:start")
private ProducerTemplate template;
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
+ ConnectionProperties connectionProperties = service.connectionProperties();
+ String rabbitMQEndpoint = String.format(
+ "rabbitmq:localhost:%d/%susername=%s&password=%s&queue=q6&routingKey=rk3&autoDelete=false",
+ connectionProperties.port(), connectionProperties.username(), connectionProperties.password(), EXCHANGE);
+
return new RouteBuilder() {
@Override
diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQTemporaryQueueAutoRecoveryIntTest.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQTemporaryQueueAutoRecoveryIntTest.java
index c787515..1f25bdc 100644
--- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQTemporaryQueueAutoRecoveryIntTest.java
+++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQTemporaryQueueAutoRecoveryIntTest.java
@@ -21,7 +21,6 @@ import java.util.stream.StreamSupport;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.apache.camel.Endpoint;
import org.apache.camel.EndpointInject;
import org.apache.camel.Exchange;
import org.apache.camel.Produce;
@@ -29,6 +28,7 @@ import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.component.rabbitmq.RabbitMQConstants;
+import org.apache.camel.test.infra.rabbitmq.services.ConnectionProperties;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -57,13 +57,6 @@ public class RabbitMQTemporaryQueueAutoRecoveryIntTest extends AbstractRabbitMQI
@Produce(uri = "direct:rabbitMQApi-getExchangeBindings")
protected ProducerTemplate getExchangeBindingsProducer;
- @EndpointInject(uri = "rabbitmq:" + EXCHANGE + "?addresses=localhost:5672&username=cameltest&password=cameltest"
- + "&autoAck=false&queue=" + QUEUE + "&routingKey=" + ROUTING_KEY)
- private Endpoint rabbitMQEndpoint;
-
- @EndpointInject(uri = "http:localhost:15672/api?authMethod=Basic&authUsername=cameltest&authPassword=cameltest")
- private Endpoint rabbitMQApiEndpoint;
-
@EndpointInject(uri = "mock:consuming")
private MockEndpoint consumingMockEndpoint;
@@ -72,6 +65,16 @@ public class RabbitMQTemporaryQueueAutoRecoveryIntTest extends AbstractRabbitMQI
@Override
protected RouteBuilder createRouteBuilder() {
+ ConnectionProperties connectionProperties = service.connectionProperties();
+
+ String rabbitMQEndpoint
+ = String.format("rabbitmq:%s?addresses=%s:%d&username=%s&password=%s&autoAck=false&queue=%s&routingKey=%s",
+ EXCHANGE, connectionProperties.hostname(), connectionProperties.port(),
+ connectionProperties.username(), connectionProperties.password(), QUEUE, ROUTING_KEY);
+
+ String rabbitMQApiEndpoint = String.format("http:%s:%d/api?authMethod=Basic&authUsername=%s&authPassword=%s",
+ connectionProperties.hostname(), service.getHttpPort(), connectionProperties.username(),
+ connectionProperties.password());
return new RouteBuilder() {
diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/spring/AbstractRabbitMQSpringIntTest.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/spring/AbstractRabbitMQSpringIntTest.java
index cd829d8..b8fcbe6 100644
--- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/spring/AbstractRabbitMQSpringIntTest.java
+++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/spring/AbstractRabbitMQSpringIntTest.java
@@ -19,9 +19,11 @@ package org.apache.camel.component.rabbitmq.integration.spring;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
+import org.apache.camel.test.infra.rabbitmq.services.RabbitMQService;
+import org.apache.camel.test.infra.rabbitmq.services.RabbitMQServiceFactory;
import org.apache.camel.test.spring.junit5.CamelSpringTestSupport;
-import org.apache.camel.test.testcontainers.junit5.Containers;
import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.extension.RegisterExtension;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.support.AbstractApplicationContext;
@@ -30,8 +32,8 @@ import org.testcontainers.containers.GenericContainer;
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public abstract class AbstractRabbitMQSpringIntTest extends CamelSpringTestSupport {
- // Container starts once per test class
- protected static GenericContainer container;
+ @RegisterExtension
+ public static RabbitMQService service = RabbitMQServiceFactory.createService();
private static final Logger LOG = LoggerFactory.getLogger(AbstractRabbitMQSpringIntTest.class);
@@ -41,24 +43,7 @@ public abstract class AbstractRabbitMQSpringIntTest extends CamelSpringTestSuppo
@Override
protected AbstractApplicationContext createApplicationContext() {
- container = org.apache.camel.component.rabbitmq.integration.DockerTestUtils.rabbitMQContainer();
- this.containers.add(container);
- try {
- Containers.start(this.containers, null, 10);
- } catch (Exception e) {
- LOG.error("Failed to start RabbitMQ Container: {}", e.getMessage(), e);
- }
-
ClassPathXmlApplicationContext classPathXmlApplicationContext = new ClassPathXmlApplicationContext(getConfigLocation());
return classPathXmlApplicationContext;
}
-
- @Override
- protected void cleanupResources() throws Exception {
- super.cleanupResources();
-
- if (container != null) {
- container.stop();
- }
- }
}
diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQConsumerQpidTest.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQConsumerQpidTest.java
index 1e1dd6e..07cdfcc 100644
--- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQConsumerQpidTest.java
+++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQConsumerQpidTest.java
@@ -17,22 +17,7 @@
package org.apache.camel.component.rabbitmq.qpid;
import org.apache.camel.component.rabbitmq.integration.RabbitMQConsumerIntTest;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
public class RabbitMQConsumerQpidTest extends RabbitMQConsumerIntTest {
- @Override
- public boolean isStartDocker() {
- return false;
- }
- @BeforeAll
- public static void startBroker() throws Exception {
- systemLauncher.startup(createQpidSystemConfig());
- }
-
- @AfterAll
- public static void stopBroker() {
- systemLauncher.shutdown();
- }
}
diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQConsumerQpidTestReplyTo.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQConsumerQpidTestReplyTo.java
index 4c61f3f..ef5d92b 100644
--- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQConsumerQpidTestReplyTo.java
+++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQConsumerQpidTestReplyTo.java
@@ -17,25 +17,9 @@
package org.apache.camel.component.rabbitmq.qpid;
import org.apache.camel.component.rabbitmq.integration.RabbitMQConsumerIntTestReplyTo;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
public class RabbitMQConsumerQpidTestReplyTo extends RabbitMQConsumerIntTestReplyTo {
- @Override
- public boolean isStartDocker() {
- return false;
- }
-
- @BeforeAll
- public static void startBroker() throws Exception {
- systemLauncher.startup(createQpidSystemConfig());
- }
-
- @AfterAll
- public static void stopBroker() {
- systemLauncher.shutdown();
- }
@Override
@BeforeEach
diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQInOutQpidTest.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQInOutQpidTest.java
index cbc2df4..b5899f9 100644
--- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQInOutQpidTest.java
+++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQInOutQpidTest.java
@@ -17,22 +17,7 @@
package org.apache.camel.component.rabbitmq.qpid;
import org.apache.camel.component.rabbitmq.integration.RabbitMQInOutIntTest;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
public class RabbitMQInOutQpidTest extends RabbitMQInOutIntTest {
- @Override
- public boolean isStartDocker() {
- return false;
- }
- @BeforeAll
- public static void startBroker() throws Exception {
- systemLauncher.startup(createQpidSystemConfig());
- }
-
- @AfterAll
- public static void stopBroker() {
- systemLauncher.shutdown();
- }
}
diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQLoadQpidTest.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQLoadQpidTest.java
index 0055a18..2064722 100644
--- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQLoadQpidTest.java
+++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQLoadQpidTest.java
@@ -17,22 +17,7 @@
package org.apache.camel.component.rabbitmq.qpid;
import org.apache.camel.component.rabbitmq.integration.RabbitMQLoadIntTest;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
public class RabbitMQLoadQpidTest extends RabbitMQLoadIntTest {
- @Override
- public boolean isStartDocker() {
- return false;
- }
- @BeforeAll
- public static void startBroker() throws Exception {
- systemLauncher.startup(createQpidSystemConfig());
- }
-
- @AfterAll
- public static void stopBroker() {
- systemLauncher.shutdown();
- }
}
diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQProducerQpidTest.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQProducerQpidTest.java
index 335ad31..79a98dc 100644
--- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQProducerQpidTest.java
+++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQProducerQpidTest.java
@@ -20,25 +20,9 @@ import java.io.IOException;
import java.util.concurrent.TimeoutException;
import org.apache.camel.component.rabbitmq.integration.RabbitMQProducerIntTest;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
public class RabbitMQProducerQpidTest extends RabbitMQProducerIntTest {
- @Override
- public boolean isStartDocker() {
- return false;
- }
-
- @BeforeAll
- public static void startBroker() throws Exception {
- systemLauncher.startup(createQpidSystemConfig());
- }
-
- @AfterAll
- public static void stopBroker() {
- systemLauncher.shutdown();
- }
@Disabled
@Override
diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQReConnectionQpidTest.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQReConnectionQpidTest.java
index a66c80b..6a583c6 100644
--- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQReConnectionQpidTest.java
+++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQReConnectionQpidTest.java
@@ -17,22 +17,7 @@
package org.apache.camel.component.rabbitmq.qpid;
import org.apache.camel.component.rabbitmq.integration.RabbitMQReConnectionIntTest;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
public class RabbitMQReConnectionQpidTest extends RabbitMQReConnectionIntTest {
- @Override
- public boolean isStartDocker() {
- return false;
- }
- @BeforeAll
- public static void startBroker() throws Exception {
- systemLauncher.startup(createQpidSystemConfig());
- }
-
- @AfterAll
- public static void stopBroker() {
- systemLauncher.shutdown();
- }
}
diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQRequeueQpidTest.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQRequeueQpidTest.java
index 3f7008a..dcc00cc 100644
--- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQRequeueQpidTest.java
+++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQRequeueQpidTest.java
@@ -17,26 +17,10 @@
package org.apache.camel.component.rabbitmq.qpid;
import org.apache.camel.component.rabbitmq.integration.RabbitMQRequeueIntTest;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
public class RabbitMQRequeueQpidTest extends RabbitMQRequeueIntTest {
- @Override
- public boolean isStartDocker() {
- return false;
- }
-
- @BeforeAll
- public static void startBroker() throws Exception {
- systemLauncher.startup(createQpidSystemConfig());
- }
-
- @AfterAll
- public static void stopBroker() {
- systemLauncher.shutdown();
- }
@Disabled
@Override
diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQRequeueUnhandledExceptionQpidTest.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQRequeueUnhandledExceptionQpidTest.java
index 93eb772..cf64af6 100644
--- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQRequeueUnhandledExceptionQpidTest.java
+++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQRequeueUnhandledExceptionQpidTest.java
@@ -17,22 +17,7 @@
package org.apache.camel.component.rabbitmq.qpid;
import org.apache.camel.component.rabbitmq.integration.RabbitMQRequeueUnhandledExceptionIntTest;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
public class RabbitMQRequeueUnhandledExceptionQpidTest extends RabbitMQRequeueUnhandledExceptionIntTest {
- @Override
- public boolean isStartDocker() {
- return false;
- }
- @BeforeAll
- public static void startBroker() throws Exception {
- systemLauncher.startup(createQpidSystemConfig());
- }
-
- @AfterAll
- public static void stopBroker() {
- systemLauncher.shutdown();
- }
}
diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQSupendResumeQpidTest.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQSupendResumeQpidTest.java
index fd4d5a1..9fc96f5 100644
--- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQSupendResumeQpidTest.java
+++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQSupendResumeQpidTest.java
@@ -17,22 +17,7 @@
package org.apache.camel.component.rabbitmq.qpid;
import org.apache.camel.component.rabbitmq.integration.RabbitMQSupendResumeIntTest;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
public class RabbitMQSupendResumeQpidTest extends RabbitMQSupendResumeIntTest {
- @Override
- public boolean isStartDocker() {
- return false;
- }
- @BeforeAll
- public static void startBroker() throws Exception {
- systemLauncher.startup(createQpidSystemConfig());
- }
-
- @AfterAll
- public static void stopBroker() {
- systemLauncher.shutdown();
- }
}
diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/AbstractRabbitMQIntTest.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/test/infra/services/QpidEmbeddedService.java
similarity index 50%
copy from components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/AbstractRabbitMQIntTest.java
copy to components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/test/infra/services/QpidEmbeddedService.java
index 6852278..e54d3f63 100644
--- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/AbstractRabbitMQIntTest.java
+++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/test/infra/services/QpidEmbeddedService.java
@@ -14,63 +14,27 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.component.rabbitmq.integration;
-import java.io.IOException;
+package org.apache.camel.component.rabbitmq.test.infra.services;
+
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import com.rabbitmq.client.Connection;
-import com.rabbitmq.client.ConnectionFactory;
-import org.apache.camel.test.testcontainers.junit5.ContainerAwareTestSupport;
+import org.apache.camel.component.rabbitmq.integration.AbstractRabbitMQIntTest;
+import org.apache.camel.test.infra.rabbitmq.services.ConnectionProperties;
+import org.apache.camel.test.infra.rabbitmq.services.RabbitMQService;
import org.apache.qpid.server.SystemLauncher;
import org.apache.qpid.server.model.ConfiguredObject;
import org.apache.qpid.server.model.SystemConfig;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.TestInstance;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.testcontainers.containers.GenericContainer;
-@TestInstance(TestInstance.Lifecycle.PER_CLASS)
-public abstract class AbstractRabbitMQIntTest extends ContainerAwareTestSupport {
+public class QpidEmbeddedService implements RabbitMQService {
protected static final String INITIAL_CONFIGURATION = "qpid-test-initial-config.json";
protected static SystemLauncher systemLauncher = new SystemLauncher();
- // Container starts once per test class
- private static GenericContainer container;
-
- protected Logger log = LoggerFactory.getLogger(getClass());
-
- protected boolean isStartDocker() {
- return true;
- }
-
- @Override
- @BeforeEach
- public void setUp() throws Exception {
- super.setUp();
- }
-
- /**
- * Helper method for creating a RabbitMQ connection to the test instance of the RabbitMQ server.
- *
- * @return
- * @throws IOException
- * @throws TimeoutException
- */
- protected Connection connection() throws IOException, TimeoutException {
- ConnectionFactory factory = new ConnectionFactory();
- factory.setHost("localhost");
- factory.setPort(5672);
- factory.setUsername("cameltest");
- factory.setPassword("cameltest");
- factory.setVirtualHost("/");
- return factory.newConnection();
- }
+ private static final Logger LOG = LoggerFactory.getLogger(QpidEmbeddedService.class);
/**
* Helper method for creating a Qpid Broker-J system configuration for the initiate of the local AMQP server.
@@ -86,21 +50,48 @@ public abstract class AbstractRabbitMQIntTest extends ContainerAwareTestSupport
}
@Override
- protected GenericContainer<?> createContainer() {
- container = isStartDocker() ? DockerTestUtils.rabbitMQContainer() : null;
- return (GenericContainer<?>) container;
+ public ConnectionProperties connectionProperties() {
+ return new ConnectionProperties() {
+ @Override
+ public String username() {
+ return "cameltest";
+ }
+
+ @Override
+ public String password() {
+ return "cameltest";
+ }
+
+ @Override
+ public String hostname() {
+ return "localhost";
+ }
+
+ @Override
+ public int port() {
+ return 5672;
+ }
+ };
}
@Override
- protected void cleanupResources() throws Exception {
- super.cleanupResources();
+ public int getHttpPort() {
+ throw new UnsupportedOperationException("Qpid embedded broker does not have a HTTP admin service");
+ }
- if (container != null) {
- container.stop();
+ @Override
+ public void initialize() {
+ LOG.info("Trying to start Qpid embedded container");
+ try {
+ systemLauncher.startup(createQpidSystemConfig());
+ LOG.info("Qpid embedded service running on {}", getAmqpUrl());
+ } catch (Exception e) {
+ e.printStackTrace();
}
}
- protected long containerShutdownTimeout() {
- return TimeUnit.MINUTES.toSeconds(1L);
+ @Override
+ public void shutdown() {
+ systemLauncher.shutdown();
}
}
diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQConsumerQpidTest.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/test/infra/services/RabbitMQServiceFactory.java
similarity index 52%
copy from components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQConsumerQpidTest.java
copy to components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/test/infra/services/RabbitMQServiceFactory.java
index 1e1dd6e..34b630d 100644
--- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQConsumerQpidTest.java
+++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/test/infra/services/RabbitMQServiceFactory.java
@@ -14,25 +14,28 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.component.rabbitmq.qpid;
-import org.apache.camel.component.rabbitmq.integration.RabbitMQConsumerIntTest;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
+package org.apache.camel.component.rabbitmq.test.infra.services;
-public class RabbitMQConsumerQpidTest extends RabbitMQConsumerIntTest {
- @Override
- public boolean isStartDocker() {
- return false;
- }
+import org.apache.camel.test.infra.rabbitmq.services.RabbitMQService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public final class RabbitMQServiceFactory {
+ private static final Logger LOG = LoggerFactory.getLogger(RabbitMQServiceFactory.class);
+
+ private RabbitMQServiceFactory() {
- @BeforeAll
- public static void startBroker() throws Exception {
- systemLauncher.startup(createQpidSystemConfig());
}
- @AfterAll
- public static void stopBroker() {
- systemLauncher.shutdown();
+ public static RabbitMQService createService() {
+ String instanceType = System.getProperty("rabbitmq.instance.type");
+
+ if (instanceType != null && !instanceType.isEmpty() && instanceType.equals("qpid")) {
+ return new QpidEmbeddedService();
+ }
+
+ return org.apache.camel.test.infra.rabbitmq.services.RabbitMQServiceFactory.createService();
+
}
}
diff --git a/components/camel-rabbitmq/src/test/resources/RabbitMQSpringIntTest-context.xml b/components/camel-rabbitmq/src/test/resources/RabbitMQSpringIntTest-context.xml
index b6a6cb7..ab92173 100644
--- a/components/camel-rabbitmq/src/test/resources/RabbitMQSpringIntTest-context.xml
+++ b/components/camel-rabbitmq/src/test/resources/RabbitMQSpringIntTest-context.xml
@@ -23,17 +23,19 @@
http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">
+ <bean class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer"/>
+
<!-- START SNIPPET: custom connection factory -->
<bean class="com.rabbitmq.client.ConnectionFactory" id="customConnectionFactory">
- <property name="host" value="localhost"/>
- <property name="port" value="5672"/>
- <property name="username" value="cameltest"/>
- <property name="password" value="cameltest"/>
+ <property name="host" value="${rabbitmq.connection.hostname}"/>
+ <property name="port" value="${rabbitmq.connection.amqp}"/>
+ <property name="username" value="${rabbitmq.user.name}"/>
+ <property name="password" value="${rabbitmq.user.password}"/>
</bean>
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<route id="_route1">
<from id="_from1" uri="direct:rabbitMQ"/>
- <to id="_to1" uri="rabbitmq://localhost:5672/ex2?queue=q2&routingKey=rk2"/>
+ <to id="_to1" uri="rabbitmq://${rabbitmq.connection.hostname}:${rabbitmq.connection.amqp}/ex2?queue=q2&routingKey=rk2"/>
</route>
</camelContext>
<!-- END SNIPPET: example -->
diff --git a/parent/pom.xml b/parent/pom.xml
index 7d62fb4..2feade4 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -3524,6 +3524,11 @@
<version>${testcontainers-version}</version>
</dependency>
<dependency>
+ <groupId>org.testcontainers</groupId>
+ <artifactId>rabbitmq</artifactId>
+ <version>${testcontainers-version}</version>
+ </dependency>
+ <dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj-version}</version>
diff --git a/test-infra/camel-test-infra-rabbitmq/pom.xml b/test-infra/camel-test-infra-rabbitmq/pom.xml
new file mode 100644
index 0000000..81250cb
--- /dev/null
+++ b/test-infra/camel-test-infra-rabbitmq/pom.xml
@@ -0,0 +1,62 @@
+<?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-rabbitmq</artifactId>
+ <name>Camel :: Test Infra :: RabbitMQ</name>
+
+ <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>
+
+ <dependency>
+ <groupId>org.testcontainers</groupId>
+ <artifactId>rabbitmq</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-rabbitmq/src/main/resources/META-INF/MANIFEST.MF b/test-infra/camel-test-infra-rabbitmq/src/main/resources/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..e69de29
diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQReConnectionQpidTest.java b/test-infra/camel-test-infra-rabbitmq/src/test/java/org/apache/camel/test/infra/rabbitmq/common/RabbitMQProperties.java
similarity index 55%
copy from components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQReConnectionQpidTest.java
copy to test-infra/camel-test-infra-rabbitmq/src/test/java/org/apache/camel/test/infra/rabbitmq/common/RabbitMQProperties.java
index a66c80b..36dec62 100644
--- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQReConnectionQpidTest.java
+++ b/test-infra/camel-test-infra-rabbitmq/src/test/java/org/apache/camel/test/infra/rabbitmq/common/RabbitMQProperties.java
@@ -14,25 +14,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.component.rabbitmq.qpid;
-import org.apache.camel.component.rabbitmq.integration.RabbitMQReConnectionIntTest;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
+package org.apache.camel.test.infra.rabbitmq.common;
-public class RabbitMQReConnectionQpidTest extends RabbitMQReConnectionIntTest {
- @Override
- public boolean isStartDocker() {
- return false;
- }
+public final class RabbitMQProperties {
+ public static final String RABBITMQ_USER_NAME = "rabbitmq.user.name";
+ public static final String RABBITMQ_USER_PASSWORD = "rabbitmq.user.password";
+ public static final String RABBITMQ_CONNECTION_HOSTNAME = "rabbitmq.connection.hostname";
+ public static final String RABBITMQ_CONNECTION_AMQP = "rabbitmq.connection.amqp";
+ public static final String RABBITMQ_CONNECTION_AMQP_URL = "rabbitmq.connection.amqp.url";
+ public static final String RABBITMQ_CONNECTION_HTTP = "rabbitmq.connection.http";
- @BeforeAll
- public static void startBroker() throws Exception {
- systemLauncher.startup(createQpidSystemConfig());
- }
+ private RabbitMQProperties() {
- @AfterAll
- public static void stopBroker() {
- systemLauncher.shutdown();
}
}
diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQLoadQpidTest.java b/test-infra/camel-test-infra-rabbitmq/src/test/java/org/apache/camel/test/infra/rabbitmq/services/ConnectionProperties.java
similarity index 58%
copy from components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQLoadQpidTest.java
copy to test-infra/camel-test-infra-rabbitmq/src/test/java/org/apache/camel/test/infra/rabbitmq/services/ConnectionProperties.java
index 0055a18..f295315 100644
--- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/qpid/RabbitMQLoadQpidTest.java
+++ b/test-infra/camel-test-infra-rabbitmq/src/test/java/org/apache/camel/test/infra/rabbitmq/services/ConnectionProperties.java
@@ -14,25 +14,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.component.rabbitmq.qpid;
-import org.apache.camel.component.rabbitmq.integration.RabbitMQLoadIntTest;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
+package org.apache.camel.test.infra.rabbitmq.services;
-public class RabbitMQLoadQpidTest extends RabbitMQLoadIntTest {
- @Override
- public boolean isStartDocker() {
- return false;
- }
+public interface ConnectionProperties {
+ String username();
- @BeforeAll
- public static void startBroker() throws Exception {
- systemLauncher.startup(createQpidSystemConfig());
- }
+ String password();
- @AfterAll
- public static void stopBroker() {
- systemLauncher.shutdown();
- }
+ String hostname();
+
+ int port();
}
diff --git a/test-infra/camel-test-infra-rabbitmq/src/test/java/org/apache/camel/test/infra/rabbitmq/services/RabbitMQLocalContainerService.java b/test-infra/camel-test-infra-rabbitmq/src/test/java/org/apache/camel/test/infra/rabbitmq/services/RabbitMQLocalContainerService.java
new file mode 100644
index 0000000..343d8ce
--- /dev/null
+++ b/test-infra/camel-test-infra-rabbitmq/src/test/java/org/apache/camel/test/infra/rabbitmq/services/RabbitMQLocalContainerService.java
@@ -0,0 +1,90 @@
+/*
+ * 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.rabbitmq.services;
+
+import org.apache.camel.test.infra.rabbitmq.common.RabbitMQProperties;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testcontainers.containers.RabbitMQContainer;
+
+public class RabbitMQLocalContainerService implements RabbitMQService {
+ private static final Logger LOG = LoggerFactory.getLogger(RabbitMQLocalContainerService.class);
+
+ private final RabbitMQContainer container = new RabbitMQContainer("rabbitmq:3.8-management");
+
+ public RabbitMQLocalContainerService() {
+
+ }
+
+ @Override
+ public ConnectionProperties connectionProperties() {
+ return new ConnectionProperties() {
+ @Override
+ public String username() {
+ return container.getAdminUsername();
+ }
+
+ @Override
+ public String password() {
+ return container.getAdminPassword();
+ }
+
+ @Override
+ public String hostname() {
+ return container.getHost();
+ }
+
+ @Override
+ public int port() {
+ return container.getAmqpPort();
+ }
+ };
+ }
+
+ @Override
+ public String getAmqpUrl() {
+ return container.getAmqpUrl();
+ }
+
+ public int getHttpPort() {
+ return container.getHttpPort();
+ }
+
+ public void registerProperties() {
+ ConnectionProperties properties = connectionProperties();
+
+ System.setProperty(RabbitMQProperties.RABBITMQ_USER_NAME, properties.username());
+ System.setProperty(RabbitMQProperties.RABBITMQ_USER_PASSWORD, properties.password());
+ System.setProperty(RabbitMQProperties.RABBITMQ_CONNECTION_HOSTNAME, properties.hostname());
+ System.setProperty(RabbitMQProperties.RABBITMQ_CONNECTION_AMQP, String.valueOf(properties.port()));
+ }
+
+ @Override
+ public void initialize() {
+ LOG.info("Trying to start RabbitMQ container");
+ container.start();
+ LOG.info("RabbitMQ container running on {}", container.getAmqpUrl());
+
+ registerProperties();
+ }
+
+ @Override
+ public void shutdown() {
+ container.stop();
+ }
+}
diff --git a/test-infra/camel-test-infra-rabbitmq/src/test/java/org/apache/camel/test/infra/rabbitmq/services/RabbitMQRemoteService.java b/test-infra/camel-test-infra-rabbitmq/src/test/java/org/apache/camel/test/infra/rabbitmq/services/RabbitMQRemoteService.java
new file mode 100644
index 0000000..7360cc7
--- /dev/null
+++ b/test-infra/camel-test-infra-rabbitmq/src/test/java/org/apache/camel/test/infra/rabbitmq/services/RabbitMQRemoteService.java
@@ -0,0 +1,67 @@
+/*
+ * 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.rabbitmq.services;
+
+import org.apache.camel.test.infra.rabbitmq.common.RabbitMQProperties;
+
+public class RabbitMQRemoteService implements RabbitMQService {
+
+ @Override
+ public ConnectionProperties connectionProperties() {
+ return new ConnectionProperties() {
+ @Override
+ public String username() {
+ return System.getProperty(RabbitMQProperties.RABBITMQ_USER_NAME);
+ }
+
+ @Override
+ public String password() {
+ return System.getProperty(RabbitMQProperties.RABBITMQ_USER_PASSWORD);
+ }
+
+ @Override
+ public String hostname() {
+ return System.getProperty(RabbitMQProperties.RABBITMQ_CONNECTION_HOSTNAME);
+ }
+
+ @Override
+ public int port() {
+ String amqPort = System.getProperty(RabbitMQProperties.RABBITMQ_CONNECTION_AMQP, "5672");
+
+ return Integer.parseInt(amqPort);
+ }
+ };
+ }
+
+ @Override
+ public int getHttpPort() {
+ String httpPort = System.getProperty(RabbitMQProperties.RABBITMQ_CONNECTION_HTTP, "15672");
+
+ return Integer.parseInt(httpPort);
+ }
+
+ @Override
+ public void initialize() {
+
+ }
+
+ @Override
+ public void shutdown() {
+
+ }
+}
diff --git a/test-infra/camel-test-infra-rabbitmq/src/test/java/org/apache/camel/test/infra/rabbitmq/services/RabbitMQService.java b/test-infra/camel-test-infra-rabbitmq/src/test/java/org/apache/camel/test/infra/rabbitmq/services/RabbitMQService.java
new file mode 100644
index 0000000..b14a3f2
--- /dev/null
+++ b/test-infra/camel-test-infra-rabbitmq/src/test/java/org/apache/camel/test/infra/rabbitmq/services/RabbitMQService.java
@@ -0,0 +1,69 @@
+/*
+ * 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.rabbitmq.services;
+
+import org.junit.jupiter.api.extension.AfterAllCallback;
+import org.junit.jupiter.api.extension.BeforeAllCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
+
+public interface RabbitMQService extends BeforeAllCallback, AfterAllCallback {
+
+ /**
+ * The connection properties for the service
+ *
+ * @return The connection properties (host, port, username, password)
+ */
+ ConnectionProperties connectionProperties();
+
+ /**
+ * Gets the connection URI
+ *
+ * @return the connection URI in the format amqp://host:port
+ */
+ default String getAmqpUrl() {
+ ConnectionProperties properties = connectionProperties();
+ return String.format("amqp://%s:%s", properties.hostname(), properties.port());
+ }
+
+ /**
+ * Gets the HTTP port
+ *
+ * @return the HTTP port
+ */
+ int getHttpPort();
+
+ /**
+ * Perform any initialization necessary
+ */
+ void initialize();
+
+ /**
+ * Shuts down the service after the test has completed
+ */
+ void shutdown();
+
+ @Override
+ default void afterAll(ExtensionContext extensionContext) throws Exception {
+ shutdown();
+ }
+
+ @Override
+ default void beforeAll(ExtensionContext extensionContext) throws Exception {
+ initialize();
+ }
+}
diff --git a/test-infra/camel-test-infra-rabbitmq/src/test/java/org/apache/camel/test/infra/rabbitmq/services/RabbitMQServiceFactory.java b/test-infra/camel-test-infra-rabbitmq/src/test/java/org/apache/camel/test/infra/rabbitmq/services/RabbitMQServiceFactory.java
new file mode 100644
index 0000000..32fc48c
--- /dev/null
+++ b/test-infra/camel-test-infra-rabbitmq/src/test/java/org/apache/camel/test/infra/rabbitmq/services/RabbitMQServiceFactory.java
@@ -0,0 +1,45 @@
+/*
+ * 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.rabbitmq.services;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public final class RabbitMQServiceFactory {
+ private static final Logger LOG = LoggerFactory.getLogger(RabbitMQServiceFactory.class);
+
+ private RabbitMQServiceFactory() {
+
+ }
+
+ public static RabbitMQService createService() {
+ String instanceType = System.getProperty("rabbitmq.instance.type");
+
+ if (instanceType == null || instanceType.equals("local-rabbitmq-container")) {
+ return new RabbitMQLocalContainerService();
+ }
+
+ if (instanceType.equals("remote")) {
+ return new RabbitMQRemoteService();
+ }
+
+ LOG.error("rabbit-mq instance must be one of 'local-rabbitmq-container' or 'remote");
+ throw new UnsupportedOperationException(String.format("Invalid rabbitmq instance type: %s", instanceType));
+
+ }
+}
diff --git a/test-infra/pom.xml b/test-infra/pom.xml
index 002eb03..c83bbad 100644
--- a/test-infra/pom.xml
+++ b/test-infra/pom.xml
@@ -44,5 +44,6 @@
<module>camel-test-infra-elasticsearch</module>
<module>camel-test-infra-couchbase</module>
<module>camel-test-infra-mongodb</module>
+ <module>camel-test-infra-rabbitmq</module>
</modules>
</project>
\ No newline at end of file