Skip to content

Commit

Permalink
loaders: add itest for kotlin on quarkus (disabled because of quarkus…
Browse files Browse the repository at this point in the history
  • Loading branch information
lburgazzoli committed Sep 2, 2020
1 parent ab885e7 commit 2ac8d86
Show file tree
Hide file tree
Showing 11 changed files with 293 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?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.k</groupId>
<artifactId>camel-k-quarkus-itests</artifactId>
<version>1.5.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>camel-k-quarkus-itests-loader-kotlin</artifactId>

<dependencies>
<dependency>
<groupId>org.apache.camel.k</groupId>
<artifactId>camel-k-quarkus-loader-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>org.apache.camel.k</groupId>
<artifactId>camel-k-quarkus-itests-loader-support</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>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>${build-helper-maven-plugin.version}</version>
<executions>
<execution>
<id>reserve-network-port</id>
<goals>
<goal>reserve-network-port</goal>
</goals>
<phase>process-resources</phase>
<configuration>
<portNames>
<portName>test.http.port.jvm</portName>
<portName>test.http.port.native</portName>
</portNames>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus.version}</version>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemProperties>
<quarkus.http.test-port>${test.http.port.jvm}</quarkus.http.test-port>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
</systemProperties>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* 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.k.loader.kotlin.quarkus;

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.json.JsonObject;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.apache.camel.CamelContext;
import org.apache.camel.Consume;
import org.apache.camel.k.loader.support.LoaderSupport;

@Path("/test")
@ApplicationScoped
public class Application {
@Inject
CamelContext context;

@POST
@Path("/load-routes/{name}")
@Consume(MediaType.TEXT_PLAIN)
@Produces(MediaType.APPLICATION_JSON)
public JsonObject loadRoutes(@PathParam("name") String name, String code) throws Exception {
return LoaderSupport.inspectSource(context, name, "kts", code);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## ---------------------------------------------------------------------------
## 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.log.console.enable = true
quarkus.banner.enabled = false

#
# Quarkus :: Camel
#
quarkus.camel.routes-discovery.enabled = false
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* 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.k.loader.kotlin.quarkus;

import java.io.IOException;
import java.io.InputStream;

import javax.ws.rs.core.MediaType;

import io.quarkus.test.junit.DisabledOnNativeImage;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.path.json.JsonPath;
import org.apache.camel.util.IOHelper;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

@Disabled("https://github.com/quarkusio/quarkus/issues/11549")
@DisabledOnNativeImage
@QuarkusTest
public class KotlinLoaderTest {
@Test
public void testLoadRoutes() throws IOException {
String code;

try (InputStream is = KotlinLoaderTest.class.getResourceAsStream("/routes.kts")) {
code = IOHelper.loadText(is);
}

JsonPath p = RestAssured.given()
.contentType(MediaType.TEXT_PLAIN)
.accept(MediaType.APPLICATION_JSON)
.body(code)
.post("/test/load-routes/MyRoute")
.then()
.statusCode(200)
.extract()
.body()
.jsonPath();

assertThat(p.getList("components", String.class)).contains("direct", "log");
assertThat(p.getList("routes", String.class)).contains("kotlin");
assertThat(p.getList("endpoints", String.class)).contains("direct://kotlin", "log://kotlin");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* 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.
*/

from("direct:kotlin")
.routeId("kotlin")
.to("log:kotlin")
1 change: 1 addition & 0 deletions camel-k-quarkus/camel-k-quarkus-itests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<module>camel-k-quarkus-itests-knative</module>
<module>camel-k-quarkus-itests-loader-support</module>
<module>camel-k-quarkus-itests-loader-groovy</module>
<module>camel-k-quarkus-itests-loader-kotlin</module>
<module>camel-k-quarkus-itests-loader-java</module>
<module>camel-k-quarkus-itests-loader-js</module>
<module>camel-k-quarkus-itests-loader-xml</module>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@
<groupId>org.apache.camel.k</groupId>
<artifactId>camel-k-quarkus-loader-kotlin</artifactId>
</dependency>

<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-kotlin-deployment</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
12 changes: 12 additions & 0 deletions camel-k-quarkus/camel-k-quarkus-loader-kotlin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@

<artifactId>camel-k-quarkus-loader-kotlin-parent</artifactId>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-bom</artifactId>
<version>${kotlin.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<modules>
<module>runtime</module>
<module>deployment</module>
Expand Down
17 changes: 0 additions & 17 deletions camel-k-quarkus/camel-k-quarkus-loader-kotlin/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,15 @@

<artifactId>camel-k-quarkus-loader-kotlin</artifactId>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-bom</artifactId>
<version>${kotlin.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.apache.camel.k</groupId>
<artifactId>camel-k-loader-kotlin</artifactId>
</dependency>

<dependency>
<groupId>org.apache.camel.k</groupId>
<artifactId>camel-k-quarkus-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-kotlin</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
7 changes: 7 additions & 0 deletions camel-k-quarkus/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-bom</artifactId>
<version>${kotlin.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-bom</artifactId>
Expand Down
7 changes: 7 additions & 0 deletions examples/camel-k-runtime-example-quarkus-kotlin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-bom</artifactId>
<version>${kotlin.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-bom</artifactId>
Expand Down

0 comments on commit 2ac8d86

Please sign in to comment.