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 2021/08/23 15:34:30 UTC
[camel-quarkus] branch main updated: Test setting the kamelet from
an external file provided at runtime #3025
This is an automated email from the ASF dual-hosted git repository.
aldettinger pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/main by this push:
new 2aa2c66 Test setting the kamelet from an external file provided at runtime #3025
2aa2c66 is described below
commit 2aa2c661681b46a0615ac01a2047ee523e295062
Author: aldettinger <al...@gmail.com>
AuthorDate: Mon Aug 23 13:11:22 2021 +0200
Test setting the kamelet from an external file provided at runtime #3025
---
integration-tests/kamelet/pom.xml | 17 ++++++++++++++
.../component/kamelet/it/KameletResource.java | 8 +++++++
.../component/kamelet/it/KameletRoutes.java | 7 ++++++
.../src/main/resources/application.properties | 4 +++-
.../resources/kamelets-runtime/upper-kamelet.xml | 27 ++++++++++++++++++++++
.../quarkus/component/kamelet/it/KameletTest.java | 9 ++++++++
6 files changed, 71 insertions(+), 1 deletion(-)
diff --git a/integration-tests/kamelet/pom.xml b/integration-tests/kamelet/pom.xml
index 2290e42..8adbc4c 100644
--- a/integration-tests/kamelet/pom.xml
+++ b/integration-tests/kamelet/pom.xml
@@ -60,6 +60,10 @@
<artifactId>camel-quarkus-bean</artifactId>
</dependency>
<dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-xml-io-dsl</artifactId>
+ </dependency>
+ <dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
@@ -133,6 +137,19 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-xml-io-dsl-deployment</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
</dependencies>
<profiles>
diff --git a/integration-tests/kamelet/src/main/java/org/apache/camel/quarkus/component/kamelet/it/KameletResource.java b/integration-tests/kamelet/src/main/java/org/apache/camel/quarkus/component/kamelet/it/KameletResource.java
index d899853..090f8c4 100644
--- a/integration-tests/kamelet/src/main/java/org/apache/camel/quarkus/component/kamelet/it/KameletResource.java
+++ b/integration-tests/kamelet/src/main/java/org/apache/camel/quarkus/component/kamelet/it/KameletResource.java
@@ -96,4 +96,12 @@ public class KameletResource {
return builder.build();
}
+
+ @Path("/locationAtRuntime/{name}")
+ @POST
+ @Produces(MediaType.TEXT_PLAIN)
+ public String kameletLocationAtRuntime(@PathParam("name") String name) {
+ return fluentProducerTemplate.to("direct:kamelet-location-at-runtime").withBody(name).request(String.class);
+ }
+
}
diff --git a/integration-tests/kamelet/src/main/java/org/apache/camel/quarkus/component/kamelet/it/KameletRoutes.java b/integration-tests/kamelet/src/main/java/org/apache/camel/quarkus/component/kamelet/it/KameletRoutes.java
index 7cbc140..80f48b1 100644
--- a/integration-tests/kamelet/src/main/java/org/apache/camel/quarkus/component/kamelet/it/KameletRoutes.java
+++ b/integration-tests/kamelet/src/main/java/org/apache/camel/quarkus/component/kamelet/it/KameletRoutes.java
@@ -62,6 +62,9 @@ public class KameletRoutes extends RouteBuilder {
from("direct:chain")
.to("kamelet:echo/1?prefix=Camel Quarkus&suffix=Chained")
.to("kamelet:echo/2?prefix=Hello&suffix=Route");
+
+ from("direct:kamelet-location-at-runtime")
+ .kamelet("upper?location=classpath:kamelets-runtime/upper-kamelet.xml");
}
@RegisterForReflection
@@ -71,4 +74,8 @@ public class KameletRoutes extends RouteBuilder {
exchange.getMessage().setBody(exchange.getMessage().getBody(String.class) + "-suffix");
}
}
+
+ @RegisterForReflection(fields = false, targets = { String.class })
+ public static class StringUpperCaseReflectionForUpperKamelet {
+ }
}
diff --git a/integration-tests/kamelet/src/main/resources/application.properties b/integration-tests/kamelet/src/main/resources/application.properties
index dd2333e..cff0cd1 100644
--- a/integration-tests/kamelet/src/main/resources/application.properties
+++ b/integration-tests/kamelet/src/main/resources/application.properties
@@ -19,4 +19,6 @@ camel.kamelet.setBodyFromProperties.bodyValueFromProperty=Camel Quarkus Kamelet
quarkus.camel.kamelet.identifiers = injector,logger
# this is needed to actually test that kamelet are preloaded at build time:
-camel.component.kamelet.location = file:/invalid
\ No newline at end of file
+camel.component.kamelet.location = file:/invalid
+
+quarkus.native.resources.includes=kamelets-runtime/*.xml
\ No newline at end of file
diff --git a/integration-tests/kamelet/src/main/resources/kamelets-runtime/upper-kamelet.xml b/integration-tests/kamelet/src/main/resources/kamelets-runtime/upper-kamelet.xml
new file mode 100644
index 0000000..be105f1
--- /dev/null
+++ b/integration-tests/kamelet/src/main/resources/kamelets-runtime/upper-kamelet.xml
@@ -0,0 +1,27 @@
+<?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.
+
+-->
+<routeTemplate id="upper">
+ <route>
+ <from uri="kamelet:source"/>
+ <transform>
+ <simple>${body.toUpperCase()}</simple>
+ </transform>
+ </route>
+</routeTemplate>
\ No newline at end of file
diff --git a/integration-tests/kamelet/src/test/java/org/apache/camel/quarkus/component/kamelet/it/KameletTest.java b/integration-tests/kamelet/src/test/java/org/apache/camel/quarkus/component/kamelet/it/KameletTest.java
index 7beefc3..58dd488 100644
--- a/integration-tests/kamelet/src/test/java/org/apache/camel/quarkus/component/kamelet/it/KameletTest.java
+++ b/integration-tests/kamelet/src/test/java/org/apache/camel/quarkus/component/kamelet/it/KameletTest.java
@@ -102,4 +102,13 @@ class KameletTest {
assertTrue(jsonAsArrayList.contains("injector"));
assertTrue(jsonAsArrayList.contains("logger"));
}
+
+ @Test
+ public void testKameletLocationAtRuntime() {
+ RestAssured.given()
+ .post("/kamelet/locationAtRuntime/Hello")
+ .then()
+ .statusCode(200)
+ .body(is("HELLO"));
+ }
}