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 2021/05/27 08:00:13 UTC

[camel-k-runtime] branch camel-main updated: Converted the the KameletReifyTestResource to use Camel's test infra and fixed errors

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

orpiske pushed a commit to branch camel-main
in repository https://gitbox.apache.org/repos/asf/camel-k-runtime.git


The following commit(s) were added to refs/heads/camel-main by this push:
     new 9364856  Converted the the KameletReifyTestResource to use Camel's test infra and fixed errors
9364856 is described below

commit 936485655af989c2874a59f2c8ed278dc7997d8d
Author: Otavio Rodolfo Piske <op...@redhat.com>
AuthorDate: Wed May 26 17:23:10 2021 +0200

    Converted the the KameletReifyTestResource to use Camel's test infra and fixed errors
---
 itests/camel-k-itests-kamelet-reify/pom.xml        | 23 +++++++++--
 .../kameletreify/KameletReifyTestResource.java     | 46 +++++++++++-----------
 2 files changed, 44 insertions(+), 25 deletions(-)

diff --git a/itests/camel-k-itests-kamelet-reify/pom.xml b/itests/camel-k-itests-kamelet-reify/pom.xml
index 87bad88..2745910 100644
--- a/itests/camel-k-itests-kamelet-reify/pom.xml
+++ b/itests/camel-k-itests-kamelet-reify/pom.xml
@@ -98,9 +98,26 @@
         </dependency>
 
         <dependency>
-            <groupId>org.apache.camel.quarkus</groupId>
-            <artifactId>camel-quarkus-integration-testcontainers-support</artifactId>
-            <version>${camel-quarkus-version}</version>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-test-infra-common</artifactId>
+            <version>${camel-version}</version>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-test-infra-messaging-common</artifactId>
+            <version>${camel-version}</version>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-test-infra-artemis</artifactId>
+            <version>${camel-version}</version>
+            <type>test-jar</type>
             <scope>test</scope>
         </dependency>
 
diff --git a/itests/camel-k-itests-kamelet-reify/src/test/java/org/apache/camel/k/quarkus/kameletreify/KameletReifyTestResource.java b/itests/camel-k-itests-kamelet-reify/src/test/java/org/apache/camel/k/quarkus/kameletreify/KameletReifyTestResource.java
index e324d83..aff3a9d 100644
--- a/itests/camel-k-itests-kamelet-reify/src/test/java/org/apache/camel/k/quarkus/kameletreify/KameletReifyTestResource.java
+++ b/itests/camel-k-itests-kamelet-reify/src/test/java/org/apache/camel/k/quarkus/kameletreify/KameletReifyTestResource.java
@@ -16,39 +16,47 @@
  */
 package org.apache.camel.k.quarkus.kameletreify;
 
+import java.util.Arrays;
 import java.util.Map;
 
+import com.github.dockerjava.api.model.Ulimit;
 import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
+import org.apache.camel.test.infra.artemis.services.ArtemisContainer;
+import org.apache.camel.test.infra.messaging.services.MessagingLocalContainerService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.testcontainers.containers.GenericContainer;
-import org.testcontainers.containers.output.Slf4jLogConsumer;
-import org.testcontainers.containers.wait.strategy.Wait;
-import org.testcontainers.utility.TestcontainersConfiguration;
+
+import org.apache.camel.test.infra.messaging.services.MessagingService;
+import org.apache.camel.test.infra.messaging.services.MessagingServiceFactory;
 
 
 public class KameletReifyTestResource implements QuarkusTestResourceLifecycleManager {
     private static final Logger LOGGER = LoggerFactory.getLogger(KameletReifyTestResource.class);
 
-    private static final String ACTIVEMQ_IMAGE = "rmohr/activemq:5.15.9-alpine";
-    private static final int TCP_PORT = 61616;
+    private static MessagingService messagingService = MessagingServiceFactory
+            .builder()
+            .addLocalMapping(KameletReifyTestResource::createLocalService)
+            .build();
+
+    public static MessagingLocalContainerService<ArtemisContainer> createLocalService() {
+        ArtemisContainer artemisContainer = new ArtemisContainer();
 
-    private GenericContainer<?> container;
+        artemisContainer.withCreateContainerCmdModifier( c -> c.getHostConfig()
+                .withUlimits(Arrays.asList(new Ulimit("nofile", 5000L, 5000L))));
+
+        return new MessagingLocalContainerService<>(artemisContainer, c -> c.defaultEndpoint());
+    }
 
     @Override
     public Map<String, String> start() {
-        LOGGER.info(TestcontainersConfiguration.getInstance().toString());
-
         try {
-            container = new GenericContainer<>(ACTIVEMQ_IMAGE)
-                .withExposedPorts(TCP_PORT)
-                .withLogConsumer(new Slf4jLogConsumer(LOGGER))
-                .waitingFor(Wait.forListeningPort());
+            System.out.println("Starting ...");
+            messagingService.initialize();
 
-            container.start();
+            System.out.println("Using endpoint: " + messagingService.defaultEndpoint());
 
             return Map.of(
-                "amqBrokerUrl", String.format("tcp://%s:%d", container.getContainerIpAddress(), container.getMappedPort(TCP_PORT)),
+                "amqBrokerUrl", messagingService.defaultEndpoint(),
                 "amqQueueName", "my-queue"
             );
         } catch (Exception e) {
@@ -58,13 +66,7 @@ public class KameletReifyTestResource implements QuarkusTestResourceLifecycleMan
 
     @Override
     public void stop() {
-        try {
-            if (container != null) {
-                container.stop();
-            }
-        } catch (Exception e) {
-            // ignored
-        }
+
     }
 }