You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pp...@apache.org on 2020/09/02 20:27:08 UTC

[camel-quarkus] branch master updated: Add integration tests for the camel-quarkus-kotlin extension

This is an automated email from the ASF dual-hosted git repository.

ppalaga pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git


The following commit(s) were added to refs/heads/master by this push:
     new 6146df8  Add integration tests for the camel-quarkus-kotlin extension
6146df8 is described below

commit 6146df88a7acb090998984c4cbc756ee38183ec1
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Wed Sep 2 18:46:19 2020 +0200

    Add integration tests for the camel-quarkus-kotlin extension
---
 integration-tests/kotlin/pom.xml                   | 180 +++++++++++++++++++++
 .../apache/camel/quarkus/kotlin/KotlinResource.kt  |  48 ++++++
 .../apache/camel/quarkus/kotlin/KotlinRoutes.kt    |  39 +++++
 .../org/apache/camel/quarkus/kotlin/KotlinIT.kt    |  22 +++
 .../org/apache/camel/quarkus/kotlin/KotlinTest.kt  |  39 +++++
 integration-tests/pom.xml                          |   1 +
 tooling/scripts/test-categories.yaml               |   1 +
 7 files changed, 330 insertions(+)

diff --git a/integration-tests/kotlin/pom.xml b/integration-tests/kotlin/pom.xml
new file mode 100644
index 0000000..1177906
--- /dev/null
+++ b/integration-tests/kotlin/pom.xml
@@ -0,0 +1,180 @@
+<?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">
+    <parent>
+        <groupId>org.apache.camel.quarkus</groupId>
+        <artifactId>camel-quarkus-integration-tests</artifactId>
+        <version>1.1.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>camel-quarkus-integration-test-kotlin</artifactId>
+    <name>Camel Quarkus :: Integration Tests :: Kotlin :: Tests</name>
+    <description>The camel integration tests</description>
+
+    <properties>
+        <!-- mvnd, a.k.a. Maven Daemon: https://github.com/mvndaemon/mvnd -->
+        <!-- The following rule tells mvnd to build the listed deployment modules before this module. -->
+        <!-- This is important because mvnd builds modules in parallel by default. The deployment modules are not -->
+        <!-- explicit dependencies of this module in the Maven sense, although they are required by the Quarkus Maven plugin. -->
+        <!-- Please update the rule whenever you change the dependencies of this module by running -->
+        <!--     mvn process-resources -Pformat    from the root directory -->
+        <mvnd.builder.rule>camel-quarkus-direct-deployment,camel-quarkus-kotlin-deployment,camel-quarkus-log-deployment</mvnd.builder.rule>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-kotlin</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-direct</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-log</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>io.quarkus</groupId>
+            <artifactId>quarkus-jsonb</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>io.quarkus</groupId>
+            <artifactId>quarkus-resteasy-jsonb</artifactId>
+        </dependency>
+
+        <!-- test dependencies -->
+        <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.assertj</groupId>
+            <artifactId>assertj-core</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-integration-test-support</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>io.quarkus</groupId>
+                <artifactId>quarkus-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>build</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.jetbrains.kotlin</groupId>
+                <artifactId>kotlin-maven-plugin</artifactId>
+                <version>${kotlin.version}</version>
+                <executions>
+                    <execution>
+                        <id>compile</id>
+                        <goals>
+                            <goal>compile</goal>
+                        </goals>
+                        <configuration>
+                            <sourceDirs>
+                                <sourceDir>${project.basedir}/src/main/kotlin</sourceDir>
+                            </sourceDirs>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>test-compile</id>
+                        <goals>
+                            <goal>test-compile</goal>
+                        </goals>
+                        <configuration>
+                            <sourceDirs>
+                                <sourceDir>${project.basedir}/src/test/kotlin</sourceDir>
+                            </sourceDirs>
+                        </configuration>
+                    </execution>
+                </executions>
+                <configuration>
+                    <compilerPlugins>
+                        <plugin>all-open</plugin>
+                    </compilerPlugins>
+                    <pluginOptions>
+                        <option>all-open:annotation=javax.enterprise.inject.Produces</option>
+                        <option>all-open:annotation=javax.inject.Singleton</option>
+                        <option>all-open:annotation=javax.enterprise.context.ApplicationScoped</option>
+                    </pluginOptions>
+                </configuration>
+                <dependencies>
+                    <dependency>
+                        <groupId>org.jetbrains.kotlin</groupId>
+                        <artifactId>kotlin-maven-allopen</artifactId>
+                        <version>${kotlin.version}</version>
+                    </dependency>
+                </dependencies>
+            </plugin>
+        </plugins>
+    </build>
+
+    <profiles>
+        <profile>
+            <id>native</id>
+            <activation>
+                <property>
+                    <name>native</name>
+                </property>
+            </activation>
+            <properties>
+                <quarkus.package.type>native</quarkus.package.type>
+            </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>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+
+</project>
diff --git a/integration-tests/kotlin/src/main/kotlin/org/apache/camel/quarkus/kotlin/KotlinResource.kt b/integration-tests/kotlin/src/main/kotlin/org/apache/camel/quarkus/kotlin/KotlinResource.kt
new file mode 100644
index 0000000..072e9bc
--- /dev/null
+++ b/integration-tests/kotlin/src/main/kotlin/org/apache/camel/quarkus/kotlin/KotlinResource.kt
@@ -0,0 +1,48 @@
+/*
+ * 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.apache.camel.quarkus.kotlin
+
+import org.apache.camel.CamelContext
+import org.apache.camel.Route
+import java.util.stream.Collectors
+import javax.enterprise.context.ApplicationScoped
+import javax.inject.Inject
+import javax.json.Json
+import javax.json.JsonObject
+import javax.ws.rs.GET
+import javax.ws.rs.Path
+import javax.ws.rs.Produces
+import javax.ws.rs.core.MediaType
+
+
+@Path("/test")
+@ApplicationScoped
+class KotlinResource {
+    @Inject
+    var context: CamelContext? = null
+
+    @Path("/describe-context")
+    @GET
+    @Produces(MediaType.APPLICATION_JSON)
+    fun describeMain(): JsonObject? {
+        val routes = context!!.routes.stream().map { obj: Route -> obj.id }.collect(Collectors.toList())
+
+        return Json.createObjectBuilder()
+                .add("routes", Json.createArrayBuilder(routes))
+                .build()
+    }
+}
\ No newline at end of file
diff --git a/integration-tests/kotlin/src/main/kotlin/org/apache/camel/quarkus/kotlin/KotlinRoutes.kt b/integration-tests/kotlin/src/main/kotlin/org/apache/camel/quarkus/kotlin/KotlinRoutes.kt
new file mode 100644
index 0000000..a9d2ce0
--- /dev/null
+++ b/integration-tests/kotlin/src/main/kotlin/org/apache/camel/quarkus/kotlin/KotlinRoutes.kt
@@ -0,0 +1,39 @@
+/*
+ * 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.apache.camel.quarkus.kotlin
+
+import org.apache.camel.builder.LambdaRouteBuilder
+import javax.enterprise.context.ApplicationScoped
+import javax.enterprise.inject.Produces
+
+
+@ApplicationScoped
+class KotlinRoutes {
+    @Produces
+    fun withRoutesDsl() = routes {
+        from("direct:dsl")
+            .routeId("routes-dsl")
+            .log("\${body}")
+    }
+
+    @Produces
+    fun withLambda() = LambdaRouteBuilder {
+        it.from("direct:lambda")
+                .routeId("lambda-dsl")
+                .log("\${body}")
+    }
+}
\ No newline at end of file
diff --git a/integration-tests/kotlin/src/test/kotlin/org/apache/camel/quarkus/kotlin/KotlinIT.kt b/integration-tests/kotlin/src/test/kotlin/org/apache/camel/quarkus/kotlin/KotlinIT.kt
new file mode 100644
index 0000000..5e0a8f7
--- /dev/null
+++ b/integration-tests/kotlin/src/test/kotlin/org/apache/camel/quarkus/kotlin/KotlinIT.kt
@@ -0,0 +1,22 @@
+/*
+ * 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.apache.camel.quarkus.kotlin
+
+import io.quarkus.test.junit.NativeImageTest
+
+@NativeImageTest
+class KotlinIT : KotlinTest()
\ No newline at end of file
diff --git a/integration-tests/kotlin/src/test/kotlin/org/apache/camel/quarkus/kotlin/KotlinTest.kt b/integration-tests/kotlin/src/test/kotlin/org/apache/camel/quarkus/kotlin/KotlinTest.kt
new file mode 100644
index 0000000..29298b6
--- /dev/null
+++ b/integration-tests/kotlin/src/test/kotlin/org/apache/camel/quarkus/kotlin/KotlinTest.kt
@@ -0,0 +1,39 @@
+/*
+ * 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.apache.camel.quarkus.kotlin
+
+import io.quarkus.test.junit.QuarkusTest
+import io.restassured.RestAssured
+import org.assertj.core.api.Assertions.assertThat
+import org.junit.jupiter.api.Test
+import javax.ws.rs.core.MediaType
+
+@QuarkusTest
+open class KotlinTest {
+    @Test
+    fun `routes are created`() {
+        val p = RestAssured.given()
+                .accept(MediaType.APPLICATION_JSON)["/test/describe-context"]
+                .then()
+                .statusCode(200)
+                .extract()
+                .body()
+                .jsonPath()
+
+        assertThat(p.getList("routes", String::class.java)).contains("routes-dsl", "lambda-dsl")
+    }
+}
diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml
index 97a3685..405ede2 100644
--- a/integration-tests/pom.xml
+++ b/integration-tests/pom.xml
@@ -105,6 +105,7 @@
         <module>jsonpath</module>
         <module>jta</module>
         <module>kafka</module>
+        <module>kotlin</module>
         <module>kubernetes</module>
         <module>kudu</module>
         <module>mail</module>
diff --git a/tooling/scripts/test-categories.yaml b/tooling/scripts/test-categories.yaml
index 81d20b1..05cfdcf 100644
--- a/tooling/scripts/test-categories.yaml
+++ b/tooling/scripts/test-categories.yaml
@@ -97,6 +97,7 @@ misc:
   - stream
   - tika
   - as2
+  - kotlin
 networking2-dataformats:
   - git
   - mail