From e56bd909425cf89248af3b617a25a972857e2fc6 Mon Sep 17 00:00:00 2001 From: James Netherton Date: Wed, 23 Oct 2024 10:55:08 +0100 Subject: [PATCH] Add a basic test for pipes --- integration-tests/kamelet/pom.xml | 17 +++++++ .../component/kamelet/it/KameletResource.java | 7 +++ .../src/main/resources/application.properties | 6 +-- .../greeting-from-property.kamelet.yaml | 44 +++++++++++++++++++ .../main/resources/pipes/greeting-pipe.yaml | 31 +++++++++++++ .../component/kamelet/it/KameletTest.java | 8 ++++ 6 files changed, 110 insertions(+), 3 deletions(-) create mode 100644 integration-tests/kamelet/src/main/resources/kamelets/greeting-from-property.kamelet.yaml create mode 100644 integration-tests/kamelet/src/main/resources/pipes/greeting-pipe.yaml diff --git a/integration-tests/kamelet/pom.xml b/integration-tests/kamelet/pom.xml index ad46deebb8d..0aafd2bd40b 100644 --- a/integration-tests/kamelet/pom.xml +++ b/integration-tests/kamelet/pom.xml @@ -51,6 +51,10 @@ org.apache.camel.quarkus camel-quarkus-xml-io-dsl + + org.apache.camel.quarkus + camel-quarkus-yaml-dsl + org.apache.camel.quarkus camel-quarkus-seda @@ -210,6 +214,19 @@ + + org.apache.camel.quarkus + camel-quarkus-yaml-dsl-deployment + ${project.version} + pom + test + + + * + * + + + diff --git a/integration-tests/kamelet/src/main/java/org/apache/camel/quarkus/component/kamelet/it/KameletResource.java b/integration-tests/kamelet/src/main/java/org/apache/camel/quarkus/component/kamelet/it/KameletResource.java index f9bb2f9af76..b8bf3516faf 100644 --- a/integration-tests/kamelet/src/main/java/org/apache/camel/quarkus/component/kamelet/it/KameletResource.java +++ b/integration-tests/kamelet/src/main/java/org/apache/camel/quarkus/component/kamelet/it/KameletResource.java @@ -109,4 +109,11 @@ public String kameletLocationAtRuntime(@PathParam("name") String name) { public String greeting() { return consumerTemplate.receiveBody("seda:greeting", 10000, String.class); } + + @Path("/pipe") + @GET + @Produces(MediaType.TEXT_PLAIN) + public String pipe() { + return consumerTemplate.receiveBody("seda:greetingFromProperty", 10000, String.class); + } } diff --git a/integration-tests/kamelet/src/main/resources/application.properties b/integration-tests/kamelet/src/main/resources/application.properties index 0b6ffc878c5..296f9d8bf1c 100644 --- a/integration-tests/kamelet/src/main/resources/application.properties +++ b/integration-tests/kamelet/src/main/resources/application.properties @@ -15,10 +15,10 @@ ## limitations under the License. ## --------------------------------------------------------------------------- camel.kamelet.setBodyFromProperties.bodyValueFromProperty=Camel Quarkus Kamelet Property +camel.main.routes-include-pattern=pipes/greeting-pipe.yaml -quarkus.camel.kamelet.identifiers = injector,logger,greeting +quarkus.camel.kamelet.identifiers = injector,logger,greeting,greeting-from-property # this is needed to actually test that kamelet are preloaded at build time: camel.component.kamelet.location = file:/invalid - -quarkus.native.resources.includes=kamelets-runtime/*.xml \ No newline at end of file +quarkus.native.resources.includes=kamelets-runtime/*.xml,pipes/*.yaml \ No newline at end of file diff --git a/integration-tests/kamelet/src/main/resources/kamelets/greeting-from-property.kamelet.yaml b/integration-tests/kamelet/src/main/resources/kamelets/greeting-from-property.kamelet.yaml new file mode 100644 index 00000000000..280dfed300a --- /dev/null +++ b/integration-tests/kamelet/src/main/resources/kamelets/greeting-from-property.kamelet.yaml @@ -0,0 +1,44 @@ +# +# 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/v1 +kind: Kamelet +metadata: + name: greeting-from-property + labels: + camel.apache.org/kamelet.type: "source" + camel.apache.org/kamelet.name: "greeting" + camel.apache.org/kamelet.version: "v1" + camel.apache.org/kamelet.revision: "1" +spec: + definition: + title: "Greeting" + description: "Send a greeting" + properties: + greeting: + title: Greeting + description: The greeting to send. + type: string + example: Hello World + dependencies: + - "camel:timer" + template: + from: + uri: timer:greetFromProperty?repeatCount=1&delay=-1 + steps: + - setBody: + constant: "{{greeting}}" diff --git a/integration-tests/kamelet/src/main/resources/pipes/greeting-pipe.yaml b/integration-tests/kamelet/src/main/resources/pipes/greeting-pipe.yaml new file mode 100644 index 00000000000..acb0cabbbc5 --- /dev/null +++ b/integration-tests/kamelet/src/main/resources/pipes/greeting-pipe.yaml @@ -0,0 +1,31 @@ +# +# 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/v1 +kind: Pipe +metadata: + name: greeting-pipe +spec: + source: + ref: + kind: Kamelet + apiVersion: camel.apache.org/v1 + name: greeting-from-property + properties: + greeting: "Hello Pipe" + sink: + uri: "seda:greetingFromProperty" diff --git a/integration-tests/kamelet/src/test/java/org/apache/camel/quarkus/component/kamelet/it/KameletTest.java b/integration-tests/kamelet/src/test/java/org/apache/camel/quarkus/component/kamelet/it/KameletTest.java index e95c0efdf9f..8eedef0f8d8 100644 --- a/integration-tests/kamelet/src/test/java/org/apache/camel/quarkus/component/kamelet/it/KameletTest.java +++ b/integration-tests/kamelet/src/test/java/org/apache/camel/quarkus/component/kamelet/it/KameletTest.java @@ -122,4 +122,12 @@ public void testKameletWithBean() { .statusCode(200) .body(is("Hello World")); } + + @Test + public void pipe() { + RestAssured.get("/kamelet/pipe") + .then() + .statusCode(200) + .body(is("Hello Pipe")); + } }