You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by al...@apache.org on 2019/10/05 15:31:16 UTC

[camel] branch CAMEL-13965 updated (86bf27c -> ef60e10)

This is an automated email from the ASF dual-hosted git repository.

aldettinger pushed a change to branch CAMEL-13965
in repository https://gitbox.apache.org/repos/asf/camel.git.


 discard 86bf27c  CAMEL-14307: Created camel-testcontainers-junit5 from camel-testcontainers
     new ef60e10  CAMEL-14037: Created camel-testcontainers-junit5 from camel-test-containers

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (86bf27c)
            \
             N -- N -- N   refs/heads/CAMEL-13965 (ef60e10)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 components/camel-consul/pom.xml                     | 10 ----------
 .../camel/component/consul/ConsulCatalogTest.java   | 16 ++++++++--------
 .../component/consul/ConsulClientKeyValueTest.java  |  5 +----
 .../component/consul/ConsulCoordinatesTest.java     | 20 ++++++++++----------
 .../camel/component/consul/ConsulEventTest.java     |  6 +-----
 .../component/consul/ConsulEventWatchTest.java      |  2 +-
 .../camel/component/consul/ConsulHealthTest.java    | 12 +++++-------
 .../camel/component/consul/ConsulKeyValueTest.java  |  5 +----
 .../component/consul/ConsulKeyValueWatchTest.java   |  2 +-
 .../camel/component/consul/ConsulRegistryTest.java  | 21 ++++++++++-----------
 .../component/consul/ConsulRegistryUtilsTest.java   |  6 +++---
 .../camel/component/consul/ConsulSessionTest.java   | 18 +++++++++---------
 .../camel/component/consul/ConsulTestSupport.java   | 11 ++++++++---
 .../cloud/ConsulDefaultServiceCallRouteTest.java    |  2 +-
 .../cloud/ConsulRibbonServiceCallRouteTest.java     |  2 +-
 .../ConsulServiceCallWithRegistrationTest.java      | 10 ++++------
 .../consul/cloud/ConsulServiceDiscoveryTest.java    |  5 +----
 .../cloud/ConsulServiceRegistrationTestBase.java    |  5 +----
 .../consul/cloud/ConsulServiceRegistryTest.java     |  4 +---
 .../apache/camel/test/junit5/CamelTestSupport.java  |  7 -------
 20 files changed, 67 insertions(+), 102 deletions(-)


[camel] 01/01: CAMEL-14037: Created camel-testcontainers-junit5 from camel-test-containers

Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aldettinger pushed a commit to branch CAMEL-13965
in repository https://gitbox.apache.org/repos/asf/camel.git

commit ef60e10f7927fb992d72218ba5582c0c36110882
Author: aldettinger <al...@gmail.com>
AuthorDate: Sat Oct 5 17:25:31 2019 +0200

    CAMEL-14037: Created camel-testcontainers-junit5 from camel-test-containers
---
 apache-camel/pom.xml                               |   5 +
 apache-camel/src/main/descriptors/common-bin.xml   |   1 +
 bom/camel-bom/pom.xml                              |   5 +
 components/camel-testcontainers-junit5/pom.xml     | 159 +++++++++++++++++++++
 .../src/main/docs/testcontainers-junit5.adoc       | 136 ++++++++++++++++++
 .../junit5/ContainerAwareTestSupport.java          | 108 ++++++++++++++
 .../junit5/ContainerPropertiesFunction.java        |  74 ++++++++++
 .../test/testcontainers/junit5/Containers.java     |  84 +++++++++++
 .../camel/test/testcontainers/junit5/Wait.java     |  69 +++++++++
 .../junit5/ContainerAwareTestSupportIT.java        |  53 +++++++
 .../src/test/resources/log4j2.properties           |  30 ++++
 components/pom.xml                                 |   1 +
 docs/components/modules/ROOT/nav.adoc              |   1 +
 .../modules/ROOT/pages/testcontainers-junit5.adoc  | 137 ++++++++++++++++++
 parent/pom.xml                                     |   5 +
 .../camel-spring-boot-dependencies/pom.xml         |   5 +
 16 files changed, 873 insertions(+)

diff --git a/apache-camel/pom.xml b/apache-camel/pom.xml
index f0279da..505dd0a 100644
--- a/apache-camel/pom.xml
+++ b/apache-camel/pom.xml
@@ -1523,6 +1523,11 @@
     </dependency>
     <dependency>
       <groupId>org.apache.camel</groupId>
+      <artifactId>camel-testcontainers-junit5</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
       <artifactId>camel-testcontainers-spring</artifactId>
       <version>${project.version}</version>
     </dependency>
diff --git a/apache-camel/src/main/descriptors/common-bin.xml b/apache-camel/src/main/descriptors/common-bin.xml
index 6438386..404e758 100644
--- a/apache-camel/src/main/descriptors/common-bin.xml
+++ b/apache-camel/src/main/descriptors/common-bin.xml
@@ -325,6 +325,7 @@
         <include>org.apache.camel:camel-test-spring</include>
         <include>org.apache.camel:camel-test-spring-junit5</include>
         <include>org.apache.camel:camel-testcontainers</include>
+        <include>org.apache.camel:camel-testcontainers-junit5</include>
         <include>org.apache.camel:camel-testcontainers-spring</include>
         <include>org.apache.camel:camel-thrift</include>
         <include>org.apache.camel:camel-tika</include>
diff --git a/bom/camel-bom/pom.xml b/bom/camel-bom/pom.xml
index 041167d..a15a7cb 100644
--- a/bom/camel-bom/pom.xml
+++ b/bom/camel-bom/pom.xml
@@ -2935,6 +2935,11 @@
       </dependency>
       <dependency>
         <groupId>org.apache.camel</groupId>
+        <artifactId>camel-testcontainers-junit5</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.camel</groupId>
         <artifactId>camel-testcontainers-spring</artifactId>
         <version>${project.version}</version>
       </dependency>
diff --git a/components/camel-testcontainers-junit5/pom.xml b/components/camel-testcontainers-junit5/pom.xml
new file mode 100644
index 0000000..b80f32d
--- /dev/null
+++ b/components/camel-testcontainers-junit5/pom.xml
@@ -0,0 +1,159 @@
+<?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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.camel</groupId>
+        <artifactId>components</artifactId>
+        <version>3.0.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>camel-testcontainers-junit5</artifactId>
+    <packaging>jar</packaging>
+
+    <name>Camel :: Testcontainers :: JUnit 5</name>
+    <description>Camel support for testcontainers with JUnit 5</description>
+
+    <properties>
+        <firstVersion>3.0.0</firstVersion>
+        <label>testing,java,docker</label>
+
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-test-junit5</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.testcontainers</groupId>
+            <artifactId>testcontainers</artifactId>
+            <version>${testcontainers-version}</version>
+        </dependency>
+
+        <!-- optional dependencies for running tests -->
+        <dependency>
+            <groupId>org.assertj</groupId>
+            <artifactId>assertj-core</artifactId>
+            <version>${assertj-version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-api</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-core</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-slf4j-impl</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+    </dependencies>
+
+    <profiles>
+          <profile>
+            <id>testcontainers-skip-tests</id>
+            <activation>
+                <activeByDefault>true</activeByDefault>
+            </activation>
+            <build>
+                <plugins>
+                    <plugin>
+                        <artifactId>maven-surefire-plugin</artifactId>
+                        <configuration>
+                            <skipTests>true</skipTests>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+        <!-- activate integration test if the docker socket file is accessible -->
+        <profile>
+            <id>testcontainers-integration-tests-docker-file</id>
+            <activation>
+                <file>
+                    <exists>/var/run/docker.sock</exists>
+                </file>
+            </activation>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-failsafe-plugin</artifactId>
+                        <configuration>
+                            <skipTests>${skipTests}</skipTests>
+                            <systemPropertyVariables>
+                                <visibleassertions.silence>true</visibleassertions.silence>
+                            </systemPropertyVariables>
+                        </configuration>
+                        <executions>
+                            <execution>
+                                <goals>
+                                    <goal>integration-test</goal>
+                                    <goal>verify</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+
+        <!-- activate integration test if the DOCKER_HOST env var is set -->
+        <profile>
+            <id>testcontainers-integration-tests-docker-env</id>
+            <activation>
+                <property>
+                    <name>env.DOCKER_HOST</name>
+                </property>
+            </activation>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-failsafe-plugin</artifactId>
+                        <configuration>
+                            <skipTests>${skipTests}</skipTests>
+                            <systemPropertyVariables>
+                                <visibleassertions.silence>true</visibleassertions.silence>
+                            </systemPropertyVariables>
+                        </configuration>
+                        <executions>
+                            <execution>
+                                <goals>
+                                    <goal>integration-test</goal>
+                                    <goal>verify</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+</project>
diff --git a/components/camel-testcontainers-junit5/src/main/docs/testcontainers-junit5.adoc b/components/camel-testcontainers-junit5/src/main/docs/testcontainers-junit5.adoc
new file mode 100644
index 0000000..53353a3
--- /dev/null
+++ b/components/camel-testcontainers-junit5/src/main/docs/testcontainers-junit5.adoc
@@ -0,0 +1,136 @@
+= Testcontainers
+
+*Available since 3.0.0*
+
+Testing camel components is sometime complex because the 3rd party system a component interacts with does not provide testing facilities and/or is only available as a native application. To reduce this complexity, *Camel Testcontainers JUnit 5* extends standard camel test support providing a way to create and interact with containerized applications.
+
+In order to define leverage testcontainers, add the following dependency to your pom:
+
+[source,xml]
+----
+<dependency>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>camel-testcontainers-junit5</artifactId>
+    <version>x.x.x</version>
+    <!-- use the same version as your Camel core version -->
+    <scope>test</scope>
+</dependency>
+----
+
+[TIP]
+====
+To learn more about testcontainers, please have a look at the https://www.testcontainers.org[official documentation]
+====
+
+To leverage testcontainers in your tests, you can use `ContainerAwareTestSupport` which is an extension of `CamelTestSupport` which:
+
+- create/destroy containers according to camel context lifecycle
+- inject a custom `PropertiesFunction` to access container specific options from properties
+
+
+To create a container you need to override:
+[source, java]
+----
+protected GenericContainer<?> createContainer()
+----
+
+If you need to create more than one container, you can override the following method:
+[source, java]
+----
+protected List<GenericContainer<?>> createContainers()
+----
+
+The methods above are invoked before the camel context starts and blocks until the containers are reported to be alive. Containers are destroyed once the camel context stops.
+
+[source,java]
+.Example
+----
+@Override
+protected GenericContainer<?> createContainer() {
+    return new GenericContainer<>("consul:1.0.7")
+        .withNetworkAliases("myconsul") // <1>
+        .withExposedPorts(8500)
+        .waitingFor(Wait.forLogMessageContaining("Synced node info", 1)) // <2>
+        .withCommand(
+            "agent",
+            "-dev",
+            "-server",
+            "-bootstrap",
+            "-client",
+            "0.0.0.0",
+            "-log-level",
+            "trace"
+        );
+}
+----
+<1> container name/alias
+<2> container startup condition
+
+[IMPORTANT]
+====
+It is important to give a name/alias to the container so you can then use properties functions to retrieve information such as container's host and port mapping.
+====
+[TIP]
+====
+You may need to wait for some condition to be satisfied before starting your test, to do so you need to configure the test suite to wait for such event using `GenericContainer.waitingFor`. Testcontainers provide a number of ready to use waiting strategy, for more info see the official testcontainers documentation.
+====
+
+Camel Testcontainer provides a PropertiesFunction implementation that can be used to:
+
+- retrieve the container host with the following syntax `container:host:$\{container-name\}`
+- retrieve the port mapping with the following syntax `container:port:$\{exposed-port\}@$\{container-name\}`
+
+[source,java]
+.Example
+----
+public class MyTest extends ContainerAwareTestSupport {
+    @Test
+    public void testPropertyPlaceholders() throws Exception {
+        GenericContainer<?> container = getContainer("myconsul");
+
+        String host = context.resolvePropertyPlaceholders("{{container:host:myconsul}}");
+        assertThat(host).isEqualTo(container.getContainerIpAddress());
+
+        String port = context.resolvePropertyPlaceholders("{{container:port:8500@myconsul}}");
+        assertThat(port).isEqualTo("" + container.getMappedPort(8500));
+    }
+
+    @Override
+    protected GenericContainer<?> createContainer() {
+        return new GenericContainer<>("consul:1.0.7")
+            .withNetworkAliases("myconsul")
+            .withExposedPorts(8500)
+            .waitingFor(Wait.forLogMessageContaining("Synced node info", 1))
+            .withCommand(
+                "agent",
+                "-dev",
+                "-server",
+                "-bootstrap",
+                "-client",
+                "0.0.0.0",
+                "-log-level",
+                "trace"
+            );
+    }
+}
+----
+
+== Migrating Camel Testcontainers Tests from JUnit 4 to JUnit 5
+Find below some hints to help in migrating camel testcontainers tests from JUnit 4 to JUnit 5.
+
+=== Referencing the Camel Testcontainers JUnit5 library in your project
+Projects using `camel-testcontainers` would need to use `camel-testcontainers-junit5`. For instance, maven users would update their pom.xml file as below:
+----
+<dependency>
+  <groupId>org.apache.camel</groupId>
+  <artifactId>camel-testcontainers-junit5</artifactId>
+  <scope>test</scope>
+</dependency>
+----
+
+Tips: It's possible to run JUnit4 & JUnit5 based camel tests side by side including the following dependencies `camel-testcontainers`,
+`camel-testcontainers-junit5` and `junit-vintage-engine`. This configuration allows to migrate a camel test at once.
+
+=== Typical migration steps linked to JUnit 5 support in Camel Testcontainers
+* Migration steps linked to xref:components::test-junit5.adoc[JUnit 5 support in Camel Test itself] should have been applied first
+* Imports of `org.apache.camel.test.testcontainers.\*` should be replaced with `org.apache.camel.test.testcontainers.junit5.*`
diff --git a/components/camel-testcontainers-junit5/src/main/java/org/apache/camel/test/testcontainers/junit5/ContainerAwareTestSupport.java b/components/camel-testcontainers-junit5/src/main/java/org/apache/camel/test/testcontainers/junit5/ContainerAwareTestSupport.java
new file mode 100644
index 0000000..3c4a13a
--- /dev/null
+++ b/components/camel-testcontainers-junit5/src/main/java/org/apache/camel/test/testcontainers/junit5/ContainerAwareTestSupport.java
@@ -0,0 +1,108 @@
+/*
+ * 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.testcontainers.junit5;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.properties.PropertiesComponent;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.containers.Network;
+
+public class ContainerAwareTestSupport extends CamelTestSupport {
+    private List<GenericContainer<?>> containers = new CopyOnWriteArrayList<>();
+
+    // ******************
+    // Setup
+    // ******************
+
+    @Override
+    protected void setupResources() throws Exception {
+        super.setupResources();
+
+        containers.clear();
+        containers.addAll(createContainers());
+
+        final Network network = containerNetwork();
+        final long timeout = containersStartupTimeout();
+
+        Containers.start(containers, network, timeout);
+    }
+
+    @Override
+    protected void cleanupResources() throws Exception {
+        super.cleanupResources();
+
+        Containers.stop(containers, containerShutdownTimeout());
+    }
+
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        final CamelContext context = super.createCamelContext();
+        final PropertiesComponent pc = (PropertiesComponent)context.getPropertiesComponent();
+
+        pc.addFunction(new ContainerPropertiesFunction(containers));
+
+        return context;
+    }
+
+    // ******************
+    // Containers set-up
+    // ******************
+
+    protected GenericContainer<?> createContainer() {
+        return null;
+    }
+
+    protected List<GenericContainer<?>> createContainers() {
+        GenericContainer<?> container = createContainer();
+
+        return container == null ? Collections.emptyList() : Collections.singletonList(container);
+    }
+
+    protected long containersStartupTimeout() {
+        return TimeUnit.MINUTES.toSeconds(1);
+    }
+
+    protected long containerShutdownTimeout() {
+        return TimeUnit.MINUTES.toSeconds(1);
+    }
+
+    protected Network containerNetwork() {
+        return null;
+    }
+
+    // ******************
+    // Helpers
+    // ******************
+
+    protected GenericContainer<?> getContainer(String containerName) {
+        return Containers.lookup(containers, containerName);
+    }
+
+    protected String getContainerHost(String containerName) {
+        return getContainer(containerName).getContainerIpAddress();
+    }
+
+    protected int getContainerPort(String containerName, int originalPort) {
+        return getContainer(containerName).getMappedPort(originalPort);
+    }
+}
diff --git a/components/camel-testcontainers-junit5/src/main/java/org/apache/camel/test/testcontainers/junit5/ContainerPropertiesFunction.java b/components/camel-testcontainers-junit5/src/main/java/org/apache/camel/test/testcontainers/junit5/ContainerPropertiesFunction.java
new file mode 100644
index 0000000..cb2862c
--- /dev/null
+++ b/components/camel-testcontainers-junit5/src/main/java/org/apache/camel/test/testcontainers/junit5/ContainerPropertiesFunction.java
@@ -0,0 +1,74 @@
+/*
+ * 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.testcontainers.junit5;
+
+import java.util.List;
+
+import org.apache.camel.component.properties.PropertiesFunction;
+import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.StringHelper;
+import org.testcontainers.containers.GenericContainer;
+
+public class ContainerPropertiesFunction implements PropertiesFunction {
+    private final List<GenericContainer<?>> containers;
+
+    public ContainerPropertiesFunction(List<GenericContainer<?>> containers) {
+        this.containers = ObjectHelper.notNull(containers, "Containers");
+    }
+
+    @Override
+    public String getName() {
+        return "container";
+    }
+
+    @Override
+    public String apply(String remainder) {
+        final String type = StringHelper.before(remainder, ":");
+        final String query = StringHelper.after(remainder, ":");
+
+        if (ObjectHelper.isEmpty(type)) {
+            throw new IllegalArgumentException("container function syntax is container:type:query");
+        }
+
+        if ("host".equalsIgnoreCase(type)) {
+            String name = StringHelper.after(remainder, ":");
+
+            if (ObjectHelper.isEmpty(name)) {
+                throw new IllegalArgumentException("unable to determine container name");
+            }
+
+            return Containers.lookup(containers, StringHelper.after(remainder, ":")).getContainerIpAddress();
+        }
+
+        if ("port".equalsIgnoreCase(type)) {
+            String port = StringHelper.before(query, "@");
+            String name = StringHelper.after(query, "@");
+
+            if (ObjectHelper.isEmpty(port)) {
+                throw new IllegalArgumentException("unable to determine original port");
+            }
+
+            if (ObjectHelper.isEmpty(name)) {
+                throw new IllegalArgumentException("unable to determine container name");
+            }
+
+            return Integer.toString(Containers.lookup(containers, name).getMappedPort(Integer.parseInt(port)));
+        }
+
+        throw new IllegalArgumentException("Unsupported type: " + type);
+    }
+}
diff --git a/components/camel-testcontainers-junit5/src/main/java/org/apache/camel/test/testcontainers/junit5/Containers.java b/components/camel-testcontainers-junit5/src/main/java/org/apache/camel/test/testcontainers/junit5/Containers.java
new file mode 100644
index 0000000..7e26024
--- /dev/null
+++ b/components/camel-testcontainers-junit5/src/main/java/org/apache/camel/test/testcontainers/junit5/Containers.java
@@ -0,0 +1,84 @@
+/*
+ * 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.testcontainers.junit5;
+
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import static java.util.stream.Collectors.joining;
+
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.containers.Network;
+import org.testcontainers.containers.output.Slf4jLogConsumer;
+
+public final class Containers {
+    private static final Logger LOGGER = LoggerFactory.getLogger(Containers.class);
+
+    private Containers() {
+    }
+
+    public static void start(List<GenericContainer<?>> containers, Network network, long timeout) throws Exception {
+        final CountDownLatch latch = new CountDownLatch(containers.size());
+
+        for (GenericContainer<?> container : containers) {
+            if (ObjectHelper.isEmpty(container.getNetworkAliases())) {
+                throw new IllegalStateException("Container should have at least a network alias");
+            }
+
+            if (network != null) {
+                container.withNetwork(network);
+            }
+
+            // Add custom logger
+            container.withLogConsumer(new Slf4jLogConsumer(LOGGER).withPrefix(container.getNetworkAliases().stream().collect(joining(","))));
+
+            new Thread(() -> {
+                container.start();
+                latch.countDown();
+            }).start();
+        }
+
+        latch.await(timeout, TimeUnit.SECONDS);
+    }
+
+    public static void stop(List<GenericContainer<?>> containers, long timeout) throws Exception {
+        final CountDownLatch latch = new CountDownLatch(containers.size());
+
+        for (GenericContainer<?> container : containers) {
+            new Thread(() -> {
+                container.stop();
+                latch.countDown();
+            }).start();
+        }
+
+        latch.await(timeout, TimeUnit.SECONDS);
+    }
+
+    public static GenericContainer<?> lookup(List<GenericContainer<?>> containers, String containerName) {
+        for (GenericContainer<?> container : containers) {
+            if (container.getNetworkAliases().contains(containerName)) {
+                return container;
+            }
+        }
+
+        throw new IllegalArgumentException("No container with name " + containerName + " found");
+    }
+}
diff --git a/components/camel-testcontainers-junit5/src/main/java/org/apache/camel/test/testcontainers/junit5/Wait.java b/components/camel-testcontainers-junit5/src/main/java/org/apache/camel/test/testcontainers/junit5/Wait.java
new file mode 100644
index 0000000..258b8b2
--- /dev/null
+++ b/components/camel-testcontainers-junit5/src/main/java/org/apache/camel/test/testcontainers/junit5/Wait.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.testcontainers.junit5;
+
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.function.Predicate;
+
+import com.github.dockerjava.api.DockerClient;
+import org.testcontainers.DockerClientFactory;
+import org.testcontainers.containers.ContainerLaunchException;
+import org.testcontainers.containers.output.OutputFrame;
+import org.testcontainers.containers.output.WaitingConsumer;
+import org.testcontainers.containers.wait.strategy.AbstractWaitStrategy;
+import org.testcontainers.containers.wait.strategy.WaitStrategy;
+import org.testcontainers.utility.LogUtils;
+
+public class Wait extends org.testcontainers.containers.wait.strategy.Wait {
+    /**
+     * Convenience method to return a WaitStrategy for log messages using a
+     * predicate.
+     *
+     * @param predicate the predicate to apply to log messages
+     * @param times the number of times the pattern is expected
+     * @return WaitStrategy
+     */
+    public static WaitStrategy forLogPredicate(Predicate<OutputFrame> predicate, int times) {
+        return new AbstractWaitStrategy() {
+            @Override
+            protected void waitUntilReady() {
+                final DockerClient client = DockerClientFactory.instance().client();
+                final WaitingConsumer waitingConsumer = new WaitingConsumer();
+
+                LogUtils.followOutput(client, waitStrategyTarget.getContainerId(), waitingConsumer);
+
+                try {
+                    waitingConsumer.waitUntil(predicate, startupTimeout.getSeconds(), TimeUnit.SECONDS, times);
+                } catch (TimeoutException e) {
+                    throw new ContainerLaunchException("Timed out");
+                }
+            }
+        };
+    }
+
+    /**
+     * Convenience method to return a WaitStrategy for log messages.
+     *
+     * @param text the text to find
+     * @param times the number of times the pattern is expected
+     * @return WaitStrategy
+     */
+    public static WaitStrategy forLogMessageContaining(String text, int times) {
+        return forLogPredicate(u -> u.getUtf8String().contains(text), times);
+    }
+}
diff --git a/components/camel-testcontainers-junit5/src/test/java/org/apache/camel/test/testcontainers/junit5/ContainerAwareTestSupportIT.java b/components/camel-testcontainers-junit5/src/test/java/org/apache/camel/test/testcontainers/junit5/ContainerAwareTestSupportIT.java
new file mode 100644
index 0000000..ce0cfc7
--- /dev/null
+++ b/components/camel-testcontainers-junit5/src/test/java/org/apache/camel/test/testcontainers/junit5/ContainerAwareTestSupportIT.java
@@ -0,0 +1,53 @@
+/*
+ * 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.testcontainers.junit5;
+
+import org.assertj.core.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.testcontainers.containers.GenericContainer;
+
+public class ContainerAwareTestSupportIT extends ContainerAwareTestSupport {
+    @Test
+    public void testPropertyPlaceholders() throws Exception {
+        final GenericContainer<?> container = getContainer("myconsul");
+
+        final String host = context.resolvePropertyPlaceholders("{{container:host:myconsul}}");
+        Assertions.assertThat(host).isEqualTo(container.getContainerIpAddress());
+
+        final String port = context.resolvePropertyPlaceholders("{{container:port:8500@myconsul}}");
+        Assertions.assertThat(port).isEqualTo("" + container.getMappedPort(8500));
+    }
+
+    @Override
+    protected GenericContainer<?> createContainer() {
+        return new GenericContainer<>("consul:1.5.3")
+            .withNetworkAliases("myconsul")
+            .withExposedPorts(8500)
+            .waitingFor(Wait.forLogMessageContaining("Synced node info", 1))
+            .withCommand(
+                "agent",
+                "-dev",
+                "-server",
+                "-bootstrap",
+                "-client",
+                "0.0.0.0",
+                "-log-level",
+                "trace"
+            );
+    }
+
+}
diff --git a/components/camel-testcontainers-junit5/src/test/resources/log4j2.properties b/components/camel-testcontainers-junit5/src/test/resources/log4j2.properties
new file mode 100644
index 0000000..7db2ad4
--- /dev/null
+++ b/components/camel-testcontainers-junit5/src/test/resources/log4j2.properties
@@ -0,0 +1,30 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+appender.file.type = File
+appender.file.name = file
+appender.file.fileName = target/camel-testcontainers.log
+appender.file.layout.type = PatternLayout
+appender.file.layout.pattern = %d %-5p %c{1} - %m %n
+appender.out.type = Console
+appender.out.name = out
+appender.out.layout.type = PatternLayout
+appender.out.layout.pattern = [%30.30t] %-30.30c{1} %-5p %m%n
+logger.spring.name = org.apache.camel.test.testcontainers
+logger.spring.level = DEBUG
+rootLogger.level = INFO
+rootLogger.appenderRef.file.ref = file
diff --git a/components/pom.xml b/components/pom.xml
index a4133d1..a650994 100644
--- a/components/pom.xml
+++ b/components/pom.xml
@@ -67,6 +67,7 @@
         <module>camel-testcontainers-spring</module>
         <module>camel-test-junit5</module>
         <module>camel-test-spring-junit5</module>
+        <module>camel-testcontainers-junit5</module>
         <module>camel-blueprint</module>
         <module>camel-spring</module>
         <module>camel-groovy</module>
diff --git a/docs/components/modules/ROOT/nav.adoc b/docs/components/modules/ROOT/nav.adoc
index c75996a..ffe054b 100644
--- a/docs/components/modules/ROOT/nav.adoc
+++ b/docs/components/modules/ROOT/nav.adoc
@@ -353,6 +353,7 @@
 * xref:test-spring-junit5.adoc[Camel Test Spring JUnit 5]
 * xref:test-spring.adoc[Test Spring]
 * xref:test.adoc[Test Module]
+* xref:testcontainers-junit5.adoc[Testcontainers]
 * xref:testcontainers-spring.adoc[Testcontainers Spring]
 * xref:testcontainers.adoc[Testcontainers]
 * xref:thrift-component.adoc[Thrift Component]
diff --git a/docs/components/modules/ROOT/pages/testcontainers-junit5.adoc b/docs/components/modules/ROOT/pages/testcontainers-junit5.adoc
new file mode 100644
index 0000000..3d6e7e6
--- /dev/null
+++ b/docs/components/modules/ROOT/pages/testcontainers-junit5.adoc
@@ -0,0 +1,137 @@
+= Testcontainers
+:page-source: components/camel-testcontainers-junit5/src/main/docs/testcontainers-junit5.adoc
+
+*Available since 3.0.0*
+
+Testing camel components is sometime complex because the 3rd party system a component interacts with does not provide testing facilities and/or is only available as a native application. To reduce this complexity, *Camel Testcontainers JUnit 5* extends standard camel test support providing a way to create and interact with containerized applications.
+
+In order to define leverage testcontainers, add the following dependency to your pom:
+
+[source,xml]
+----
+<dependency>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>camel-testcontainers-junit5</artifactId>
+    <version>x.x.x</version>
+    <!-- use the same version as your Camel core version -->
+    <scope>test</scope>
+</dependency>
+----
+
+[TIP]
+====
+To learn more about testcontainers, please have a look at the https://www.testcontainers.org[official documentation]
+====
+
+To leverage testcontainers in your tests, you can use `ContainerAwareTestSupport` which is an extension of `CamelTestSupport` which:
+
+- create/destroy containers according to camel context lifecycle
+- inject a custom `PropertiesFunction` to access container specific options from properties
+
+
+To create a container you need to override:
+[source, java]
+----
+protected GenericContainer<?> createContainer()
+----
+
+If you need to create more than one container, you can override the following method:
+[source, java]
+----
+protected List<GenericContainer<?>> createContainers()
+----
+
+The methods above are invoked before the camel context starts and blocks until the containers are reported to be alive. Containers are destroyed once the camel context stops.
+
+[source,java]
+.Example
+----
+@Override
+protected GenericContainer<?> createContainer() {
+    return new GenericContainer<>("consul:1.0.7")
+        .withNetworkAliases("myconsul") // <1>
+        .withExposedPorts(8500)
+        .waitingFor(Wait.forLogMessageContaining("Synced node info", 1)) // <2>
+        .withCommand(
+            "agent",
+            "-dev",
+            "-server",
+            "-bootstrap",
+            "-client",
+            "0.0.0.0",
+            "-log-level",
+            "trace"
+        );
+}
+----
+<1> container name/alias
+<2> container startup condition
+
+[IMPORTANT]
+====
+It is important to give a name/alias to the container so you can then use properties functions to retrieve information such as container's host and port mapping.
+====
+[TIP]
+====
+You may need to wait for some condition to be satisfied before starting your test, to do so you need to configure the test suite to wait for such event using `GenericContainer.waitingFor`. Testcontainers provide a number of ready to use waiting strategy, for more info see the official testcontainers documentation.
+====
+
+Camel Testcontainer provides a PropertiesFunction implementation that can be used to:
+
+- retrieve the container host with the following syntax `container:host:$\{container-name\}`
+- retrieve the port mapping with the following syntax `container:port:$\{exposed-port\}@$\{container-name\}`
+
+[source,java]
+.Example
+----
+public class MyTest extends ContainerAwareTestSupport {
+    @Test
+    public void testPropertyPlaceholders() throws Exception {
+        GenericContainer<?> container = getContainer("myconsul");
+
+        String host = context.resolvePropertyPlaceholders("{{container:host:myconsul}}");
+        assertThat(host).isEqualTo(container.getContainerIpAddress());
+
+        String port = context.resolvePropertyPlaceholders("{{container:port:8500@myconsul}}");
+        assertThat(port).isEqualTo("" + container.getMappedPort(8500));
+    }
+
+    @Override
+    protected GenericContainer<?> createContainer() {
+        return new GenericContainer<>("consul:1.0.7")
+            .withNetworkAliases("myconsul")
+            .withExposedPorts(8500)
+            .waitingFor(Wait.forLogMessageContaining("Synced node info", 1))
+            .withCommand(
+                "agent",
+                "-dev",
+                "-server",
+                "-bootstrap",
+                "-client",
+                "0.0.0.0",
+                "-log-level",
+                "trace"
+            );
+    }
+}
+----
+
+== Migrating Camel Testcontainers Tests from JUnit 4 to JUnit 5
+Find below some hints to help in migrating camel testcontainers tests from JUnit 4 to JUnit 5.
+
+=== Referencing the Camel Testcontainers JUnit5 library in your project
+Projects using `camel-testcontainers` would need to use `camel-testcontainers-junit5`. For instance, maven users would update their pom.xml file as below:
+----
+<dependency>
+  <groupId>org.apache.camel</groupId>
+  <artifactId>camel-testcontainers-junit5</artifactId>
+  <scope>test</scope>
+</dependency>
+----
+
+Tips: It's possible to run JUnit4 & JUnit5 based camel tests side by side including the following dependencies `camel-testcontainers`,
+`camel-testcontainers-junit5` and `junit-vintage-engine`. This configuration allows to migrate a camel test at once.
+
+=== Typical migration steps linked to JUnit 5 support in Camel Testcontainers
+* Migration steps linked to xref:components::test-junit5.adoc[JUnit 5 support in Camel Test itself] should have been applied first
+* Imports of `org.apache.camel.test.testcontainers.\*` should be replaced with `org.apache.camel.test.testcontainers.junit5.*`
diff --git a/parent/pom.xml b/parent/pom.xml
index 9c669a9..eee95cc 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -2272,6 +2272,11 @@
       </dependency>
       <dependency>
         <groupId>org.apache.camel</groupId>
+        <artifactId>camel-testcontainers-junit5</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.camel</groupId>
         <artifactId>camel-testcontainers-spring</artifactId>
         <version>${project.version}</version>
       </dependency>
diff --git a/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml b/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml
index ad12838..637bd7b 100644
--- a/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml
+++ b/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml
@@ -3165,6 +3165,11 @@
       </dependency>
       <dependency>
         <groupId>org.apache.camel</groupId>
+        <artifactId>camel-testcontainers-junit5</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.camel</groupId>
         <artifactId>camel-testcontainers-spring</artifactId>
         <version>${project.version}</version>
       </dependency>