Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test setting the kamelet from an external file provided at runtime #3025 #3026

Merged
merged 1 commit into from
Aug 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 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>
aldettinger marked this conversation as resolved.
Show resolved Hide resolved
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
Expand Down Expand Up @@ -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>
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"));
}
}