This is an automated email from the ASF dual-hosted git repository.
aldettinger pushed a commit to branch camel-quarkus-main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus-examples.git
The following commit(s) were added to refs/heads/camel-quarkus-main by this
push:
new f9421dc Add Kamelet example #2731 (#42)
f9421dc is described below
commit f9421dcd30b054ae2a0e7ea0da0c71707346d2e9
Author: Amos Feng <[email protected]>
AuthorDate: Wed Jun 30 04:24:27 2021 +0800
Add Kamelet example #2731 (#42)
---
.github/test-categories.yaml | 3 +-
docs/modules/ROOT/attachments/examples.json | 5 +
kamelet-chucknorris/README.adoc | 66 +++++
kamelet-chucknorris/pom.xml | 311 +++++++++++++++++++++
.../src/main/java/org/acme/kamelet/MyRoute.java | 28 ++
.../src/main/resources/application.properties | 25 ++
.../kamelets/chuck-norris-source.kamelet.yaml | 59 ++++
.../test/java/org/acme/kamelet/ChuckNorrisIT.java | 24 ++
.../java/org/acme/kamelet/ChuckNorrisTest.java | 104 +++++++
9 files changed, 624 insertions(+), 1 deletion(-)
diff --git a/.github/test-categories.yaml b/.github/test-categories.yaml
index 27d5d6e..199ada7 100644
--- a/.github/test-categories.yaml
+++ b/.github/test-categories.yaml
@@ -36,4 +36,5 @@ examples-timer-log-3:
- timer-log-spring
- timer-log-xml
examples-other:
- - kafka
\ No newline at end of file
+ - kafka
+ - kamelet-chucknorris
diff --git a/docs/modules/ROOT/attachments/examples.json
b/docs/modules/ROOT/attachments/examples.json
index 60f045d..ba8ae60 100644
--- a/docs/modules/ROOT/attachments/examples.json
+++ b/docs/modules/ROOT/attachments/examples.json
@@ -30,6 +30,11 @@
"link": "https://github.com/apache/camel-quarkus-examples/tree/main/kafka"
},
{
+ "title": "Kamelet Chuck Norris",
+ "description": "Shows how you can build a simple Kamelet and use with your
Camel applications.",
+ "link":
"https://github.com/apache/camel-quarkus-examples/tree/main/kamelet-chucknorris"
+ },
+ {
"title": "Kotlin Hello World",
"description": "Shows how to define Camel routes using Kotlin programming
language",
"link":
"https://github.com/apache/camel-quarkus-examples/tree/main/timer-log-kotlin"
diff --git a/kamelet-chucknorris/README.adoc b/kamelet-chucknorris/README.adoc
new file mode 100644
index 0000000..992cab9
--- /dev/null
+++ b/kamelet-chucknorris/README.adoc
@@ -0,0 +1,66 @@
+= Kamelet Chuck Norris: A Camel Quarkus example
+:cq-example-description: An example that shows how you can build a simple
Kamelet and use with your Camel applications.
+
+{cq-description}
+
+The kamelet is created as a YAML file in the `src/main/resources/kamelets`
directory.
+We have developed a Chuck Norris Kamelet that periodically gets a joke from
the Chuck Norris internet database.
+
+A Camel route is coded in Java in the
`src/main/java/org/acme/kamelet/MyRoute.java` file
+that uses the Kamelet, and log the result from the Kamelet to the console.
+
+TIP: Check the
https://camel.apache.org/camel-quarkus/latest/first-steps.html[Camel Quarkus
User guide] for prerequisites
+and other general information.
+
+== Start in the Development mode
+
+[source,shell]
+----
+$ mvn clean compile quarkus:dev
+----
+
+The above command compiles the project, starts the application and lets the
Quarkus tooling watch for changes in your
+workspace. Any modifications in your project will automatically take effect in
the running application.
+
+TIP: Please refer to the Development mode section of
+https://camel.apache.org/camel-quarkus/latest/first-steps.html#_development_mode[Camel
Quarkus User guide] for more details.
+
+Then look at the log output in the console. As we run the example
+in Quarkus Dev Mode, you can edit the source code and have live updates.
+
+=== Package and run the application
+
+Once you are done with developing you may want to package and run the
application.
+
+TIP: Find more details about the JVM mode and Native mode in the Package and
run section of
+https://camel.apache.org/camel-quarkus/latest/first-steps.html#_package_and_run_the_application[Camel
Quarkus User guide]
+
+=== JVM mode
+
+[source,shell]
+----
+$ mvn clean package
+$ java -jar target/quarkus-app/quarkus-run.jar
+...
+[io.quarkus] (main) camel-quarkus-examples-... started in 1.163s.
+----
+
+=== Native mode
+
+IMPORTANT: Native mode requires having GraalVM and other tools installed.
Please check the Prerequisites section
+of
https://camel.apache.org/camel-quarkus/latest/first-steps.html#_prerequisites[Camel
Quarkus User guide].
+
+To prepare a native executable using GraalVM, run the following command:
+
+[source,shell]
+----
+$ mvn clean package -Pnative
+$ ./target/*-runner
+...
+[io.quarkus] (main) camel-quarkus-examples-... started in 0.013s.
+...
+----
+
+== Feedback
+
+Please report bugs and propose improvements via
https://github.com/apache/camel-quarkus/issues[GitHub issues of Camel Quarkus]
project.
diff --git a/kamelet-chucknorris/pom.xml b/kamelet-chucknorris/pom.xml
new file mode 100644
index 0000000..2fce091
--- /dev/null
+++ b/kamelet-chucknorris/pom.xml
@@ -0,0 +1,311 @@
+<?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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>camel-quarkus-examples-kamelet-chucknorris</artifactId>
+ <groupId>org.apache.camel.quarkus.examples</groupId>
+ <version>2.0.0-SNAPSHOT</version>
+
+ <name>Camel Quarkus :: Examples :: Kamelet Chuck Norris</name>
+ <description>Camel Quarkus Example :: Kamelet Chuck Norris</description>
+
+ <properties>
+ <camel-quarkus.version>2.1.0-SNAPSHOT</camel-quarkus.version>
+ <quarkus.version>2.0.0.Final</quarkus.version>
+
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+ <maven.compiler.target>1.8</maven.compiler.target>
+ <maven.compiler.source>1.8</maven.compiler.source>
+
<maven.compiler.testTarget>${maven.compiler.target}</maven.compiler.testTarget>
+
<maven.compiler.testSource>${maven.compiler.source}</maven.compiler.testSource>
+
+ <formatter-maven-plugin.version>2.11.0</formatter-maven-plugin.version>
+ <impsort-maven-plugin.version>1.3.2</impsort-maven-plugin.version>
+ <maven-compiler-plugin.version>3.8.0</maven-compiler-plugin.version>
+ <maven-jar-plugin.version>3.2.0</maven-jar-plugin.version>
+ <maven-resources-plugin.version>3.1.0</maven-resources-plugin.version>
+ <maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
+ <mycila-license.version>3.0</mycila-license.version>
+
+
<quarkus.runner>${project.build.directory}/quarkus-app/quarkus-run.jar</quarkus.runner>
+ </properties>
+
+ <dependencyManagement>
+ <dependencies>
+ <!-- Import BOM -->
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-bom</artifactId>
+ <version>${camel-quarkus.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-bom-test</artifactId>
+ <version>${camel-quarkus.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-kamelet</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-timer</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-jsonpath</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-http</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-log</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-microprofile-health</artifactId>
+ </dependency>
+
+ <!-- Test -->
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-junit5</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.rest-assured</groupId>
+ <artifactId>rest-assured</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.awaitility</groupId>
+ <artifactId>awaitility</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+
<artifactId>camel-quarkus-integration-tests-process-executor-support</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+
+ <plugin>
+ <groupId>net.revelc.code.formatter</groupId>
+ <artifactId>formatter-maven-plugin</artifactId>
+ <version>${formatter-maven-plugin.version}</version>
+ <configuration>
+
<configFile>${maven.multiModuleProjectDirectory}/eclipse-formatter-config.xml</configFile>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>net.revelc.code</groupId>
+ <artifactId>impsort-maven-plugin</artifactId>
+ <version>${impsort-maven-plugin.version}</version>
+ <configuration>
+ <groups>java.,javax.,org.w3c.,org.xml.,junit.</groups>
+ <removeUnused>true</removeUnused>
+ <staticAfter>true</staticAfter>
+
<staticGroups>java.,javax.,org.w3c.,org.xml.,junit.</staticGroups>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>${maven-compiler-plugin.version}</version>
+ <configuration>
+ <showDeprecation>true</showDeprecation>
+ <showWarnings>true</showWarnings>
+ <compilerArgs>
+ <arg>-Xlint:unchecked</arg>
+ </compilerArgs>
+ </configuration>
+ </plugin>
+
+ <!-- Move surefire:test to integration-test phase to be able
to execute the runner JAR from a test -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>${maven-surefire-plugin.version}</version>
+ <executions>
+ <execution>
+ <id>default-test</id>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <phase>integration-test</phase>
+ <configuration>
+ <failIfNoTests>false</failIfNoTests>
+ <systemProperties>
+
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
+
<quarkus.runner>${quarkus.runner}</quarkus.runner>
+ </systemProperties>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-maven-plugin</artifactId>
+ <version>${quarkus.version}</version>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <version>${maven-surefire-plugin.version}</version>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>${maven-jar-plugin.version}</version>
+ </plugin>
+
+ <plugin>
+ <groupId>com.mycila</groupId>
+ <artifactId>license-maven-plugin</artifactId>
+ <version>${mycila-license.version}</version>
+ <configuration>
+ <failIfUnknown>true</failIfUnknown>
+
<header>${maven.multiModuleProjectDirectory}/header.txt</header>
+ <excludes>
+ <exclude>**/*.adoc</exclude>
+ <exclude>**/*.txt</exclude>
+ <exclude>**/LICENSE.txt</exclude>
+ <exclude>**/LICENSE</exclude>
+ <exclude>**/NOTICE.txt</exclude>
+ <exclude>**/NOTICE</exclude>
+ <exclude>**/README</exclude>
+ <exclude>**/pom.xml.versionsBackup</exclude>
+ </excludes>
+ <mapping>
+ <java>SLASHSTAR_STYLE</java>
+ <properties>CAMEL_PROPERTIES_STYLE</properties>
+ <kt>SLASHSTAR_STYLE</kt>
+ </mapping>
+ <headerDefinitions>
+
<headerDefinition>${maven.multiModuleProjectDirectory}/license-properties-headerdefinition.xml</headerDefinition>
+ </headerDefinitions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+
+ <plugins>
+ <plugin>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>build</id>
+ <goals>
+ <goal>build</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>net.revelc.code.formatter</groupId>
+ <artifactId>formatter-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>format</id>
+ <goals>
+ <goal>format</goal>
+ </goals>
+ <phase>process-sources</phase>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>net.revelc.code</groupId>
+ <artifactId>impsort-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>sort-imports</id>
+ <goals>
+ <goal>sort</goal>
+ </goals>
+ <phase>process-sources</phase>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>native</id>
+ <activation>
+ <property>
+ <name>native</name>
+ </property>
+ </activation>
+ <properties>
+ <quarkus.package.type>native</quarkus.package.type>
+
<quarkus.runner>${project.build.directory}/${project.artifactId}-${project.version}-runner</quarkus.runner>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ <configuration>
+ <systemPropertyVariables>
+
<quarkus.package.type>${quarkus.package.type}</quarkus.package.type>
+
<quarkus.runner>${quarkus.runner}</quarkus.runner>
+ </systemPropertyVariables>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
diff --git a/kamelet-chucknorris/src/main/java/org/acme/kamelet/MyRoute.java
b/kamelet-chucknorris/src/main/java/org/acme/kamelet/MyRoute.java
new file mode 100644
index 0000000..98e06f6
--- /dev/null
+++ b/kamelet-chucknorris/src/main/java/org/acme/kamelet/MyRoute.java
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+package org.acme.kamelet;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class MyRoute extends RouteBuilder {
+
+ @Override
+ public void configure() {
+ from("kamelet:chuck-norris-source")
+ .log("${body}");
+ }
+}
diff --git a/kamelet-chucknorris/src/main/resources/application.properties
b/kamelet-chucknorris/src/main/resources/application.properties
new file mode 100644
index 0000000..8c1f12d
--- /dev/null
+++ b/kamelet-chucknorris/src/main/resources/application.properties
@@ -0,0 +1,25 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+#
+# Quarkus
+#
+quarkus.banner.enabled = false
+quarkus.log.file.enable = true
+
+# Camel
+quarkus.camel.kamelet.identifiers = chuck-norris-source
diff --git
a/kamelet-chucknorris/src/main/resources/kamelets/chuck-norris-source.kamelet.yaml
b/kamelet-chucknorris/src/main/resources/kamelets/chuck-norris-source.kamelet.yaml
new file mode 100644
index 0000000..7304c60
--- /dev/null
+++
b/kamelet-chucknorris/src/main/resources/kamelets/chuck-norris-source.kamelet.yaml
@@ -0,0 +1,59 @@
+#
+# 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.
+#
+
+apiVersion: camel.apache.org/v1alpha1
+kind: Kamelet
+metadata:
+ name: chuck-norris-source
+ annotations:
+ camel.apache.org/kamelet.support.level: "Preview"
+ camel.apache.org/catalog.version: "main-SNAPSHOT"
+ camel.apache.org/kamelet.icon:
data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pg0KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDE5LjAuMCwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPg0KPHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJDYXBhXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4Ig0KCSB2aWV3Qm94PSIwIDAgNTEyIDUxMiIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDA
[...]
+ camel.apache.org/provider: "Apache Software Foundation"
+ camel.apache.org/kamelet.group: "Chuck Norris"
+ labels:
+ camel.apache.org/kamelet.type: "source"
+spec:
+ definition:
+ title: "Chuck Norris Source"
+ description: |-
+ Gets peridically Chuck Norris jokes from http://www.icndb.com/
+ type: object
+ properties:
+ period:
+ title: Period
+ description: The interval (msec) to wait before getting the next joke
+ type: integer
+ default: 10000
+ types:
+ out:
+ mediaType: text/plain
+ dependencies:
+ - "camel:kamelet"
+ - "camel:timer"
+ - "camel:http"
+ - "camel:jsonpath"
+ flow:
+ from:
+ uri: "timer:chuck"
+ parameters:
+ period: "{{period}}"
+ steps:
+ - to: "http://api.icndb.com/jokes/random"
+ - set-body:
+ jsonpath: "$.value.joke"
+ - to: "kamelet:sink"
\ No newline at end of file
diff --git
a/kamelet-chucknorris/src/test/java/org/acme/kamelet/ChuckNorrisIT.java
b/kamelet-chucknorris/src/test/java/org/acme/kamelet/ChuckNorrisIT.java
new file mode 100644
index 0000000..6996582
--- /dev/null
+++ b/kamelet-chucknorris/src/test/java/org/acme/kamelet/ChuckNorrisIT.java
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+package org.acme.kamelet;
+
+import io.quarkus.test.junit.NativeImageTest;
+
+@NativeImageTest
+class ChuckNorrisIT extends ChuckNorrisTest {
+
+}
diff --git
a/kamelet-chucknorris/src/test/java/org/acme/kamelet/ChuckNorrisTest.java
b/kamelet-chucknorris/src/test/java/org/acme/kamelet/ChuckNorrisTest.java
new file mode 100644
index 0000000..9329ba6
--- /dev/null
+++ b/kamelet-chucknorris/src/test/java/org/acme/kamelet/ChuckNorrisTest.java
@@ -0,0 +1,104 @@
+/*
+ * 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.
+ */
+package org.acme.kamelet;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import org.apache.camel.quarkus.test.support.process.QuarkusProcessExecutor;
+import org.apache.commons.io.FileUtils;
+import org.junit.jupiter.api.Test;
+import org.zeroturnaround.exec.StartedProcess;
+
+import static org.awaitility.Awaitility.await;
+
+@QuarkusTest
+public class ChuckNorrisTest {
+
+ private static final String PACKAGE_TYPE =
System.getProperty("quarkus.package.type");
+
+ @Test
+ public void testTimerLogMain() throws IOException {
+ QuarkusRunnerExecutor quarkusProcessExecutor = new
QuarkusRunnerExecutor();
+ StartedProcess process = quarkusProcessExecutor.start();
+
+ awaitStartup(quarkusProcessExecutor);
+
+ try {
+ File quarkusLogFile = getQuarkusLogFile();
+ await().atMost(10L, TimeUnit.SECONDS).pollDelay(1,
TimeUnit.SECONDS).until(() -> {
+ String log = FileUtils.readFileToString(quarkusLogFile,
StandardCharsets.UTF_8);
+ return log.contains("Chuck Norris");
+ });
+ } finally {
+ if (process != null && process.getProcess().isAlive()) {
+ process.getProcess().destroy();
+ }
+ }
+ }
+
+ private File getQuarkusLogFile() {
+ String pathPrefix = "target/quarkus";
+ if (isNative()) {
+ pathPrefix += "-native";
+ }
+ return new File(pathPrefix + ".log");
+ }
+
+ private void awaitStartup(QuarkusProcessExecutor quarkusProcessExecutor) {
+ await().atMost(10, TimeUnit.SECONDS).pollDelay(1,
TimeUnit.SECONDS).until(() -> {
+ return isApplicationHealthy(quarkusProcessExecutor.getHttpPort());
+ });
+ }
+
+ private boolean isApplicationHealthy(int port) {
+ try {
+ int status = RestAssured.given()
+ .port(port)
+ .get("/q/health")
+ .then()
+ .extract()
+ .statusCode();
+ return status == 200;
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
+ private static boolean isNative() {
+ return PACKAGE_TYPE != null && PACKAGE_TYPE.equals("native");
+ }
+
+ static final class QuarkusRunnerExecutor extends QuarkusProcessExecutor {
+ @Override
+ protected List<String> command(String... args) {
+ List<String> command = super.command(args);
+ if (isNative()) {
+
command.add("-Dquarkus.log.file.path=target/quarkus-native.log");
+ } else {
+ command.add(1, "-Dquarkus.log.file.path=target/quarkus.log");
+ }
+ return command;
+ }
+
+ }
+}