Skip to content

Commit

Permalink
Test setting the kamelet from an external file provided at runtime #3025
Browse files Browse the repository at this point in the history
  • Loading branch information
aldettinger committed Aug 23, 2021
1 parent b8ba5f4 commit 87d3226
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 1 deletion.
4 changes: 4 additions & 0 deletions integration-tests/kamelet/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
<groupId>org.apache.camel.quarkus</groupId>
<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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,12 @@ public JsonArray list() {

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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ public void configure() throws Exception {
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
Expand All @@ -71,4 +74,8 @@ public void process(Exchange exchange) {
exchange.getMessage().setBody(exchange.getMessage().getBody(String.class) + "-suffix");
}
}

@RegisterForReflection(fields = false, targets = { String.class })
public static class StringUpperCaseReflectionForUpperKamelet {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
camel.component.kamelet.location = file:/invalid

quarkus.native.resources.includes=kamelets-runtime/*.xml
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,13 @@ public void testDiscovered() {
assertTrue(jsonAsArrayList.contains("injector"));
assertTrue(jsonAsArrayList.contains("logger"));
}

@Test
public void testKameletLocationAtRuntime() {
RestAssured.given()
.post("/kamelet/locationAtRuntime/Hello")
.then()
.statusCode(200)
.body(is("HELLO"));
}
}

0 comments on commit 87d3226

Please sign in to comment.