This is an automated email from the ASF dual-hosted git repository. lburgazzoli pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-k-runtime.git
The following commit(s) were added to refs/heads/master by this push: new 8914c7c quarkus: consolidate knative integration tests 8914c7c is described below commit 8914c7c7060776279e09d244ecec9526eb71030a Author: Luca Burgazzoli <lburgazz...@gmail.com> AuthorDate: Tue Sep 22 19:09:33 2020 +0200 quarkus: consolidate knative integration tests --- .github/workflows/ci-build.yml | 1 - .../camel-k-quarkus-itests-knative/pom.xml | 37 +++-- .../camel/k/quarkus/it/KnativeApplication.java | 33 ++++ .../knative/KnativeComponentApplication.java | 72 --------- .../src/main/resources/application.properties | 5 - .../src/main/resources/env.json | 13 -- .../org/apache/camel/k/quarkus/it/KnativeIT.java | 0 .../KnativeTest.java} | 46 ++++-- .../k/quarkus/knative/KnativeComponentIT.java | 23 --- .../src/test/resources/routes.properties | 0 .../src/test/resources/routes.yaml | 9 ++ .../camel-k-quarkus-itests-runtime-knative/pom.xml | 175 --------------------- .../src/main/resources/application.properties | 23 --- .../org/apache/camel/k/quarkus/it/KnativeTest.java | 41 ----- .../src/test/resources/env.json | 20 --- camel-k-quarkus/camel-k-quarkus-itests/pom.xml | 1 - .../camel/component/knative/spi/CloudEvent.java | 14 ++ 17 files changed, 113 insertions(+), 400 deletions(-) diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index fef69cd..7a0dc49 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -112,7 +112,6 @@ jobs: - :camel-k-quarkus-itests-core - :camel-k-quarkus-itests-runtime - :camel-k-quarkus-itests-runtime-kamelet - - :camel-k-quarkus-itests-runtime-knative - :camel-k-quarkus-itests-cron - :camel-k-quarkus-itests-master - :camel-k-quarkus-itests-kamelet diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/pom.xml b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/pom.xml index 8a6493b..80857c2 100644 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/pom.xml +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/pom.xml @@ -30,10 +30,25 @@ <dependencies> <dependency> <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-runtime-quarkus</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.k</groupId> <artifactId>camel-k-quarkus-knative</artifactId> </dependency> + <dependency> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-quarkus-loader-yaml</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-direct</artifactId> + </dependency> - <!-- quarkus dependencies --> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-jsonb</artifactId> + </dependency> <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-resteasy</artifactId> @@ -61,7 +76,6 @@ </dependency> </dependencies> - <build> <plugins> <plugin> @@ -100,13 +114,16 @@ <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> + <environmentVariables> + <CAMEL_K_ROUTES>file:${project.basedir}/src/test/resources/routes.yaml</CAMEL_K_ROUTES> + <CAMEL_K_CONF>${project.basedir}/src/test/resources/routes.properties</CAMEL_K_CONF> + <__CAMEL_KNATIVE_CONFIGURATION>file:${project.basedir}/src/test/resources/env.json</__CAMEL_KNATIVE_CONFIGURATION> + <CAMEL_KNATIVE_LISTENING_PORT>${test.http.port.jvm}</CAMEL_KNATIVE_LISTENING_PORT> + </environmentVariables> <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> - <environmentVariables> - <CAMEL_KNATIVE_CONFIGURATION>file:${project.basedir}/src/main/resources/env.json</CAMEL_KNATIVE_CONFIGURATION> - </environmentVariables> </configuration> </plugin> </plugins> @@ -135,13 +152,16 @@ <goal>verify</goal> </goals> <configuration> + <environmentVariables> + <CAMEL_K_ROUTES>file:${project.basedir}/src/test/resources/routes.yaml</CAMEL_K_ROUTES> + <CAMEL_K_CONF>${project.basedir}/src/test/resources/routes.properties</CAMEL_K_CONF> + <__CAMEL_KNATIVE_CONFIGURATION>file:${project.basedir}/src/test/resources/env.json</__CAMEL_KNATIVE_CONFIGURATION> + <CAMEL_KNATIVE_LISTENING_PORT>${test.http.port.native}</CAMEL_KNATIVE_LISTENING_PORT> + </environmentVariables> <systemProperties> <quarkus.http.test-port>${test.http.port.native}</quarkus.http.test-port> <native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path> </systemProperties> - <environmentVariables> - <CAMEL_KNATIVE_CONFIGURATION>file:${project.basedir}/src/main/resources/env.json</CAMEL_KNATIVE_CONFIGURATION> - </environmentVariables> </configuration> </execution> </executions> @@ -151,5 +171,4 @@ </profile> </profiles> - </project> diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-knative/src/main/java/org/apache/camel/k/quarkus/it/KnativeApplication.java b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/src/main/java/org/apache/camel/k/quarkus/it/KnativeApplication.java similarity index 64% rename from camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-knative/src/main/java/org/apache/camel/k/quarkus/it/KnativeApplication.java rename to camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/src/main/java/org/apache/camel/k/quarkus/it/KnativeApplication.java index e0375fd..7ee97b6 100644 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-knative/src/main/java/org/apache/camel/k/quarkus/it/KnativeApplication.java +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/src/main/java/org/apache/camel/k/quarkus/it/KnativeApplication.java @@ -16,15 +16,23 @@ */ package org.apache.camel.k.quarkus.it; +import java.util.Map; + import javax.enterprise.context.ApplicationScoped; import javax.inject.Inject; +import javax.json.Json; +import javax.json.JsonObject; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import io.quarkus.runtime.annotations.RegisterForReflection; +import org.apache.camel.CamelContext; import org.apache.camel.FluentProducerTemplate; +import org.apache.camel.component.knative.KnativeEndpoint; import org.apache.camel.component.knative.spi.Knative; import org.apache.camel.component.knative.spi.KnativeEnvironment; import org.eclipse.microprofile.config.inject.ConfigProperty; @@ -34,8 +42,28 @@ import org.eclipse.microprofile.config.inject.ConfigProperty; @ApplicationScoped public class KnativeApplication { @Inject + CamelContext context; + @Inject FluentProducerTemplate template; + @SuppressWarnings("unchecked") + @GET + @Path("/inspect") + @Consumes(MediaType.TEXT_PLAIN) + @Produces(MediaType.APPLICATION_JSON) + public JsonObject inspect() { + var endpoint = context.getEndpoint("knative:endpoint/from", KnativeEndpoint.class); + var envMeta = endpoint.getConfiguration().getEnvironment().lookup(Knative.Type.endpoint, "from") + .filter(entry -> Knative.EndpointKind.source.name().equals(entry.getMetadata().get(Knative.CAMEL_ENDPOINT_KIND))) + .findFirst() + .map(def -> Json.createObjectBuilder((Map)def.getMetadata())) + .orElseThrow(IllegalArgumentException::new); + + return Json.createObjectBuilder() + .add("env-meta", envMeta) + .build(); + } + @POST @Path("/execute") @Produces(MediaType.TEXT_PLAIN) @@ -52,6 +80,11 @@ public class KnativeApplication { .withMeta(Knative.CAMEL_ENDPOINT_KIND, Knative.EndpointKind.source) .withMeta(Knative.SERVICE_META_PATH, "/knative") .build(), + KnativeEnvironment.serviceBuilder(Knative.Type.endpoint, "from") + .withMeta(Knative.CAMEL_ENDPOINT_KIND, Knative.EndpointKind.source) + .withMeta(Knative.SERVICE_META_PATH, "/knative") + .withMeta(Knative.KNATIVE_EVENT_TYPE, "camel.k.evt") + .build(), KnativeEnvironment.serviceBuilder(Knative.Type.endpoint, "process") .withMeta(Knative.CAMEL_ENDPOINT_KIND, Knative.EndpointKind.sink) .withMeta(Knative.SERVICE_META_URL, String.format("http://localhost:%d/knative", port)) diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/src/main/java/org/apache/camel/k/quarkus/knative/KnativeComponentApplication.java b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/src/main/java/org/apache/camel/k/quarkus/knative/KnativeComponentApplication.java deleted file mode 100644 index 8c8245f..0000000 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/src/main/java/org/apache/camel/k/quarkus/knative/KnativeComponentApplication.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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.quarkus.knative; - -import java.util.Locale; -import java.util.Map; - -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.json.Json; -import javax.json.JsonObject; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - -import org.apache.camel.CamelContext; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.knative.KnativeEndpoint; -import org.apache.camel.component.knative.spi.Knative; - - -@Path("/test") -@ApplicationScoped -public class KnativeComponentApplication { - @Inject - CamelContext context; - - @SuppressWarnings("unchecked") - @GET - @Path("/inspect") - @Consumes(MediaType.TEXT_PLAIN) - @Produces(MediaType.APPLICATION_JSON) - public JsonObject inspect() { - var endpoint = context.getEndpoint("knative:endpoint/from", KnativeEndpoint.class); - var envMeta = endpoint.getConfiguration().getEnvironment().lookup(Knative.Type.endpoint, "from") - .filter(entry -> Knative.EndpointKind.source.name().equals(entry.getMetadata().get(Knative.CAMEL_ENDPOINT_KIND))) - .findFirst() - .map(def -> Json.createObjectBuilder((Map)def.getMetadata())) - .orElseThrow(IllegalArgumentException::new); - - return Json.createObjectBuilder() - .add("env-meta", envMeta) - .build(); - } - - @javax.enterprise.inject.Produces - public RouteBuilder routes() { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - from("knative:endpoint/from") - .transform().body(String.class, b -> b.toUpperCase(Locale.US)); - } - }; - } -} diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/src/main/resources/application.properties b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/src/main/resources/application.properties index 3f6864a..3ce5493 100644 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/src/main/resources/application.properties +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/src/main/resources/application.properties @@ -21,8 +21,3 @@ quarkus.log.console.enable = false quarkus.banner.enabled = false -# -# Quarkus :: Camel -# -quarkus.camel.routes-discovery.enabled = false - diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/src/main/resources/env.json b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/src/main/resources/env.json deleted file mode 100644 index 1ba0ae6..0000000 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/src/main/resources/env.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "services": [ - { - "type": "endpoint", - "name": "from", - "metadata": { - "service.path": "/knative", - "camel.endpoint.kind": "source", - "knative.event.type": "camel.k.evt" - } - } - ] -} \ No newline at end of file diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-knative/src/test/java/org/apache/camel/k/quarkus/it/KnativeIT.java b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/src/test/java/org/apache/camel/k/quarkus/it/KnativeIT.java similarity index 100% rename from camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-knative/src/test/java/org/apache/camel/k/quarkus/it/KnativeIT.java rename to camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/src/test/java/org/apache/camel/k/quarkus/it/KnativeIT.java diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/src/test/java/org/apache/camel/k/quarkus/knative/KnativeComponentTest.java b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/src/test/java/org/apache/camel/k/quarkus/it/KnativeTest.java similarity index 64% rename from camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/src/test/java/org/apache/camel/k/quarkus/knative/KnativeComponentTest.java rename to camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/src/test/java/org/apache/camel/k/quarkus/it/KnativeTest.java index 5d05eb4..7b8e933 100644 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/src/test/java/org/apache/camel/k/quarkus/knative/KnativeComponentTest.java +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/src/test/java/org/apache/camel/k/quarkus/it/KnativeTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.k.quarkus.knative; +package org.apache.camel.k.quarkus.it; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; @@ -35,7 +35,8 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.hamcrest.Matchers.is; @QuarkusTest -public class KnativeComponentTest { +public class KnativeTest { + @Test public void inspect() { JsonPath p = RestAssured.given() @@ -44,7 +45,7 @@ public class KnativeComponentTest { .get("/test/inspect") .then() .statusCode(200) - .extract() + .extract() .body() .jsonPath(); @@ -55,23 +56,34 @@ public class KnativeComponentTest { } @Test - public void invoke() { + public void invokeEndpoint() { final String payload = "test"; given() .body(payload) .header(Exchange.CONTENT_TYPE, "text/plain") - .header(CloudEvents.v1_0.mandatoryAttribute(CloudEvent.CAMEL_CLOUD_EVENT_VERSION).http(), CloudEvents.v1_0.version()) - .header(CloudEvents.v1_0.mandatoryAttribute(CloudEvent.CAMEL_CLOUD_EVENT_TYPE).http(), "org.apache.camel.event") - .header(CloudEvents.v1_0.mandatoryAttribute(CloudEvent.CAMEL_CLOUD_EVENT_ID).http(), "myEventID") - .header(CloudEvents.v1_0.mandatoryAttribute(CloudEvent.CAMEL_CLOUD_EVENT_TIME).http(), DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(ZonedDateTime.now())) - .header(CloudEvents.v1_0.mandatoryAttribute(CloudEvent.CAMEL_CLOUD_EVENT_SOURCE).http(), "/somewhere") - .when() - .post("/knative") - .then() - .statusCode(200) - .body(is(payload.toUpperCase())) - .extract() - .asString(); + .header(CloudEvents.v1_0.httpAttribute(CloudEvent.CAMEL_CLOUD_EVENT_VERSION), CloudEvents.v1_0.version()) + .header(CloudEvents.v1_0.httpAttribute(CloudEvent.CAMEL_CLOUD_EVENT_TYPE), "org.apache.camel.event") + .header(CloudEvents.v1_0.httpAttribute(CloudEvent.CAMEL_CLOUD_EVENT_ID), "myEventID") + .header(CloudEvents.v1_0.httpAttribute(CloudEvent.CAMEL_CLOUD_EVENT_TIME), DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(ZonedDateTime.now())) + .header(CloudEvents.v1_0.httpAttribute(CloudEvent.CAMEL_CLOUD_EVENT_SOURCE), "/somewhere") + .when() + .post("/knative") + .then() + .statusCode(200) + .body(is(payload.toUpperCase())); + } + + @Test + public void invokeRoute() { + final String payload = "hello"; + + RestAssured.given() + .accept(MediaType.TEXT_PLAIN) + .body(payload) + .post("/test/execute") + .then() + .statusCode(200) + .body(is(payload.toUpperCase())); } -} +} \ No newline at end of file diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/src/test/java/org/apache/camel/k/quarkus/knative/KnativeComponentIT.java b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/src/test/java/org/apache/camel/k/quarkus/knative/KnativeComponentIT.java deleted file mode 100644 index 23a6d20..0000000 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/src/test/java/org/apache/camel/k/quarkus/knative/KnativeComponentIT.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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.quarkus.knative; - -import io.quarkus.test.junit.NativeImageTest; - -@NativeImageTest -public class KnativeComponentIT extends KnativeComponentTest { -} \ No newline at end of file diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-knative/src/test/resources/routes.properties b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/src/test/resources/routes.properties similarity index 100% rename from camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-knative/src/test/resources/routes.properties rename to camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/src/test/resources/routes.properties diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-knative/src/test/resources/routes.yaml b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/src/test/resources/routes.yaml similarity index 81% rename from camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-knative/src/test/resources/routes.yaml rename to camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/src/test/resources/routes.yaml index b402418..749f6dd 100644 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-knative/src/test/resources/routes.yaml +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/src/test/resources/routes.yaml @@ -19,10 +19,19 @@ uri: "direct:process" steps: - to: "knative:endpoint/process" + - from: uri: "knative:endpoint/process" steps: - convert-body-to: type: "java.lang.String" - set-body: + simple: "${in.body.toUpperCase()}" + +- from: + uri: "knative:endpoint/from" + steps: + - convert-body-to: + type: "java.lang.String" + - set-body: simple: "${in.body.toUpperCase()}" \ No newline at end of file diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-knative/pom.xml b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-knative/pom.xml deleted file mode 100644 index d722f01..0000000 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-knative/pom.xml +++ /dev/null @@ -1,175 +0,0 @@ -<?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-runtime-knative</artifactId> - - <dependencies> - <dependency> - <groupId>org.apache.camel.k</groupId> - <artifactId>camel-k-runtime-quarkus</artifactId> - </dependency> - <dependency> - <groupId>org.apache.camel.k</groupId> - <artifactId>camel-k-quarkus-knative</artifactId> - </dependency> - <dependency> - <groupId>org.apache.camel.k</groupId> - <artifactId>camel-k-quarkus-loader-yaml</artifactId> - </dependency> - <dependency> - <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-direct</artifactId> - </dependency> - - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-jsonb</artifactId> - </dependency> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-resteasy</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> - </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> - <environmentVariables> - <CAMEL_K_ROUTES>file:${project.basedir}/src/test/resources/routes.yaml</CAMEL_K_ROUTES> - <CAMEL_K_CONF>${project.basedir}/src/test/resources/routes.properties</CAMEL_K_CONF> - <__CAMEL_KNATIVE_CONFIGURATION>file:${project.basedir}/src/test/resources/env.json</__CAMEL_KNATIVE_CONFIGURATION> - <CAMEL_KNATIVE_LISTENING_PORT>${test.http.port.jvm}</CAMEL_KNATIVE_LISTENING_PORT> - </environmentVariables> - <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> - - <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> - <configuration> - <environmentVariables> - <CAMEL_K_ROUTES>file:${project.basedir}/src/test/resources/routes.yaml</CAMEL_K_ROUTES> - <CAMEL_K_CONF>${project.basedir}/src/test/resources/routes.properties</CAMEL_K_CONF> - <__CAMEL_KNATIVE_CONFIGURATION>file:${project.basedir}/src/test/resources/env.json</__CAMEL_KNATIVE_CONFIGURATION> - <CAMEL_KNATIVE_LISTENING_PORT>${test.http.port.native}</CAMEL_KNATIVE_LISTENING_PORT> - </environmentVariables> - <systemProperties> - <quarkus.http.test-port>${test.http.port.native}</quarkus.http.test-port> - <native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path> - </systemProperties> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> - </profile> - </profiles> - -</project> diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-knative/src/main/resources/application.properties b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-knative/src/main/resources/application.properties deleted file mode 100644 index 3ce5493..0000000 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-knative/src/main/resources/application.properties +++ /dev/null @@ -1,23 +0,0 @@ -## --------------------------------------------------------------------------- -## 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 = false -quarkus.banner.enabled = false - diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-knative/src/test/java/org/apache/camel/k/quarkus/it/KnativeTest.java b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-knative/src/test/java/org/apache/camel/k/quarkus/it/KnativeTest.java deleted file mode 100644 index 7e093ca..0000000 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-knative/src/test/java/org/apache/camel/k/quarkus/it/KnativeTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.quarkus.it; - -import javax.ws.rs.core.MediaType; - -import io.quarkus.test.junit.QuarkusTest; -import io.restassured.RestAssured; -import org.junit.jupiter.api.Test; - -import static org.hamcrest.Matchers.is; - -@QuarkusTest -public class KnativeTest { - @Test - public void invoke() { - final String payload = "hello"; - - RestAssured.given() - .accept(MediaType.TEXT_PLAIN) - .body(payload) - .post("/test/execute") - .then() - .statusCode(200) - .body(is(payload.toUpperCase())); - } -} \ No newline at end of file diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-knative/src/test/resources/env.json b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-knative/src/test/resources/env.json deleted file mode 100644 index 4c3e66c..0000000 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-knative/src/test/resources/env.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "services": [ - { - "type": "endpoint", - "name": "process", - "metadata": { - "camel.endpoint.kind": "source", - "service.path": "/knative" - } - }, - { - "type": "endpoint", - "name": "process", - "metadata": { - "service.url": "http://localhost:{{env:HTTP_TEST_PORT}}/knative", - "camel.endpoint.kind": "sink" - } - } - ] -} \ No newline at end of file diff --git a/camel-k-quarkus/camel-k-quarkus-itests/pom.xml b/camel-k-quarkus/camel-k-quarkus-itests/pom.xml index 302aed9..e75e73e 100644 --- a/camel-k-quarkus/camel-k-quarkus-itests/pom.xml +++ b/camel-k-quarkus/camel-k-quarkus-itests/pom.xml @@ -44,7 +44,6 @@ <module>camel-k-quarkus-itests-polyglot</module> <module>camel-k-quarkus-itests-runtime</module> <module>camel-k-quarkus-itests-runtime-kamelet</module> - <module>camel-k-quarkus-itests-runtime-knative</module> </modules> </project> diff --git a/camel-knative/camel-knative-api/src/main/java/org/apache/camel/component/knative/spi/CloudEvent.java b/camel-knative/camel-knative-api/src/main/java/org/apache/camel/component/knative/spi/CloudEvent.java index bc92f38..d044629 100644 --- a/camel-knative/camel-knative-api/src/main/java/org/apache/camel/component/knative/spi/CloudEvent.java +++ b/camel-knative/camel-knative-api/src/main/java/org/apache/camel/component/knative/spi/CloudEvent.java @@ -65,6 +65,20 @@ public interface CloudEvent { .orElseThrow(() -> new IllegalArgumentException("Unable to find attribute with id: " + id)); } + /** + * Mandatory find http attribute by id. + */ + default String httpAttribute(String id) { + return mandatoryAttribute(id).http(); + } + + /** + * Mandatory find json attribute by id. + */ + default String jsonAttribute(String id) { + return mandatoryAttribute(id).json(); + } + interface Attribute { /** * The ID of the attributes, can be used to look it up.