This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 7c808a1 CAMEL-16650: camel-kamelet - Add option to configure location
for kamelet template to load from resource.
7c808a1 is described below
commit 7c808a16e86ae610d272779ab3711e5902b23a92
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri Jun 18 21:40:13 2021 +0200
CAMEL-16650: camel-kamelet - Add option to configure location for kamelet
template to load from resource.
---
components/camel-kamelet/pom.xml | 6 ---
.../component/kamelet/KameletLocationTest.java | 54 ++++++++++++++++++++++
2 files changed, 54 insertions(+), 6 deletions(-)
diff --git a/components/camel-kamelet/pom.xml b/components/camel-kamelet/pom.xml
index 6b29d32..61d8b1e 100644
--- a/components/camel-kamelet/pom.xml
+++ b/components/camel-kamelet/pom.xml
@@ -74,12 +74,6 @@
<artifactId>camel-direct</artifactId>
<scope>test</scope>
</dependency>
- <!-- TODO: circular
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-xml-io-dsl</artifactId>
- <scope>test</scope>
- </dependency> -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test-junit5</artifactId>
diff --git
a/components/camel-kamelet/src/test/java/org/apache/camel/component/kamelet/KameletLocationTest.java
b/components/camel-kamelet/src/test/java/org/apache/camel/component/kamelet/KameletLocationTest.java
index a1101a7..64123e8 100644
---
a/components/camel-kamelet/src/test/java/org/apache/camel/component/kamelet/KameletLocationTest.java
+++
b/components/camel-kamelet/src/test/java/org/apache/camel/component/kamelet/KameletLocationTest.java
@@ -16,14 +16,24 @@
*/
package org.apache.camel.component.kamelet;
+import org.apache.camel.CamelContext;
import org.apache.camel.RoutesBuilder;
import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.spi.Resource;
+import org.apache.camel.spi.RoutesBuilderLoader;
import org.apache.camel.test.junit5.CamelTestSupport;
import org.apache.http.annotation.Obsolete;
import org.junit.jupiter.api.Test;
public class KameletLocationTest extends CamelTestSupport {
+ @Override
+ protected CamelContext createCamelContext() throws Exception {
+ CamelContext context = super.createCamelContext();
+ context.getRegistry().bind("routes-builder-loader-xml", new
MyRoutesLoader());
+ return context;
+ }
+
@Test
public void testOne() throws Exception {
getMockEndpoint("mock:result").expectedBodiesReceived("HELLO");
@@ -43,6 +53,50 @@ public class KameletLocationTest extends CamelTestSupport {
assertMockEndpointsSatisfied();
}
+ // we cannot use camel-xml-io-dsl to load the XML route so we fool Camel
+ // and use this class that has the route template hardcoded from java
+ public class MyRoutesLoader implements RoutesBuilderLoader {
+
+ private CamelContext camelContext;
+
+ @Override
+ public CamelContext getCamelContext() {
+ return camelContext;
+ }
+
+ @Override
+ public void setCamelContext(CamelContext camelContext) {
+ this.camelContext = camelContext;
+ }
+
+ @Override
+ public String getSupportedExtension() {
+ return "xml";
+ }
+
+ @Override
+ public RoutesBuilder loadRoutesBuilder(Resource resource) throws
Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ routeTemplate("upper")
+ .from("kamelet:source")
+ .transform().simple("${body.toUpperCase()}");
+ }
+ };
+ }
+
+ @Override
+ public void start() {
+ // noop
+ }
+
+ @Override
+ public void stop() {
+ // noop
+ }
+ }
+
// **********************************************
//
// test set-up