This is an automated email from the ASF dual-hosted git repository. oscerd pushed a commit to branch chore/tier3-messaging-citrus-tests in repository https://gitbox.apache.org/repos/asf/camel-kamelets.git
commit e815538f15087c16913ec54de59b487db1923f55 Author: Andrea Cosentino <[email protected]> AuthorDate: Mon Jul 13 14:35:23 2026 +0200 chore: Add Citrus integration tests for MQTT5 and NATS kamelets Add container-based Citrus integration tests for 4 messaging kamelets using the generic container: DSL with Testcontainers: - mqtt5-source/sink (eclipse-mosquitto:2 container) - nats-source/sink (nats:2 container with HTTP health check on :8222) Each test runs both source and sink in a combined flow: start container, subscribe via source kamelet, publish via sink kamelet, verify source receives the message. All tests use Camel route YAML format per issue #2873. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Signed-off-by: Andrea Cosentino <[email protected]> --- tests/camel-kamelets-itest/pom.xml | 10 +++ .../src/test/java/Mqtt5IT.java | 33 ++++++++++ .../camel-kamelets-itest/src/test/java/NatsIT.java | 33 ++++++++++ .../src/test/resources/mqtt5/mosquitto.conf | 2 + .../src/test/resources/mqtt5/mqtt5-sink-route.yaml | 32 +++++++++ .../mqtt5-sink-to-source-route.citrus.it.yaml | 75 ++++++++++++++++++++++ .../test/resources/mqtt5/mqtt5-source-route.yaml | 27 ++++++++ .../src/test/resources/nats/nats-sink-route.yaml | 32 +++++++++ .../nats/nats-sink-to-source-route.citrus.it.yaml | 72 +++++++++++++++++++++ .../src/test/resources/nats/nats-source-route.yaml | 26 ++++++++ 10 files changed, 342 insertions(+) diff --git a/tests/camel-kamelets-itest/pom.xml b/tests/camel-kamelets-itest/pom.xml index 912dbd9ff..ffbd1b0d2 100644 --- a/tests/camel-kamelets-itest/pom.xml +++ b/tests/camel-kamelets-itest/pom.xml @@ -141,6 +141,16 @@ <artifactId>camel-cassandraql</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-paho-mqtt5</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-nats</artifactId> + <scope>test</scope> + </dependency> <!-- Citrus --> <dependency> diff --git a/tests/camel-kamelets-itest/src/test/java/Mqtt5IT.java b/tests/camel-kamelets-itest/src/test/java/Mqtt5IT.java new file mode 100644 index 000000000..19e137cb9 --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/java/Mqtt5IT.java @@ -0,0 +1,33 @@ +/* + * 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. + */ + +import java.util.stream.Stream; + +import org.citrusframework.common.TestLoader; +import org.citrusframework.junit.jupiter.CitrusSupport; +import org.citrusframework.junit.jupiter.CitrusTestFactory; +import org.citrusframework.junit.jupiter.CitrusTestFactorySupport; +import org.junit.jupiter.api.DynamicTest; + +@CitrusSupport +public class Mqtt5IT { + + @CitrusTestFactory + public Stream<DynamicTest> mqtt5() { + return CitrusTestFactorySupport.factory(TestLoader.YAML).packageScan("mqtt5"); + } +} diff --git a/tests/camel-kamelets-itest/src/test/java/NatsIT.java b/tests/camel-kamelets-itest/src/test/java/NatsIT.java new file mode 100644 index 000000000..a7c768685 --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/java/NatsIT.java @@ -0,0 +1,33 @@ +/* + * 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. + */ + +import java.util.stream.Stream; + +import org.citrusframework.common.TestLoader; +import org.citrusframework.junit.jupiter.CitrusSupport; +import org.citrusframework.junit.jupiter.CitrusTestFactory; +import org.citrusframework.junit.jupiter.CitrusTestFactorySupport; +import org.junit.jupiter.api.DynamicTest; + +@CitrusSupport +public class NatsIT { + + @CitrusTestFactory + public Stream<DynamicTest> nats() { + return CitrusTestFactorySupport.factory(TestLoader.YAML).packageScan("nats"); + } +} diff --git a/tests/camel-kamelets-itest/src/test/resources/mqtt5/mosquitto.conf b/tests/camel-kamelets-itest/src/test/resources/mqtt5/mosquitto.conf new file mode 100644 index 000000000..c8348ac43 --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/mqtt5/mosquitto.conf @@ -0,0 +1,2 @@ +listener 1883 +allow_anonymous true diff --git a/tests/camel-kamelets-itest/src/test/resources/mqtt5/mqtt5-sink-route.yaml b/tests/camel-kamelets-itest/src/test/resources/mqtt5/mqtt5-sink-route.yaml new file mode 100644 index 000000000..4b99efbb7 --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/mqtt5/mqtt5-sink-route.yaml @@ -0,0 +1,32 @@ +# --------------------------------------------------------------------------- +# 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. +# --------------------------------------------------------------------------- + +- route: + from: + uri: "timer:tick" + parameters: + period: "10000" + repeatCount: 1 + steps: + - setBody: + constant: "{{test.message}}" + - log: "${body}" + - to: + uri: "kamelet:mqtt5-sink" + parameters: + topic: "{{mqtt.topic}}" + brokerUrl: "{{mqtt.brokerUrl}}" diff --git a/tests/camel-kamelets-itest/src/test/resources/mqtt5/mqtt5-sink-to-source-route.citrus.it.yaml b/tests/camel-kamelets-itest/src/test/resources/mqtt5/mqtt5-sink-to-source-route.citrus.it.yaml new file mode 100644 index 000000000..85dd3a7a8 --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/mqtt5/mqtt5-sink-to-source-route.citrus.it.yaml @@ -0,0 +1,75 @@ +# --------------------------------------------------------------------------- +# 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. +# --------------------------------------------------------------------------- + +name: mqtt5-sink-to-source-route-test +variables: + - name: "test.message" + value: "hello-mqtt5-test" + - name: "mqtt.topic" + value: "test/topic" +actions: + # Start Mosquitto container + - testcontainers: + start: + container: + name: "mosquitto" + image: "eclipse-mosquitto:2" + exposedPorts: + - 1883 + waitFor: + disabled: true + command: "mosquitto -c /dev/null -p 1883" + + # Wait for Mosquitto to be ready + - sleep: + milliseconds: 3000 + + # Start source (subscriber) first + - camel: + jbang: + run: + integration: + file: "mqtt5/mqtt5-source-route.yaml" + systemProperties: + properties: + - name: "mqtt.topic" + value: "${mqtt.topic}" + - name: "mqtt.brokerUrl" + value: "tcp://${CITRUS_TESTCONTAINERS_MOSQUITTO_HOST}:${CITRUS_TESTCONTAINERS_MOSQUITTO_SERVICE_PORT}" + + # Start sink (publisher) + - camel: + jbang: + run: + waitForRunningState: false + integration: + file: "mqtt5/mqtt5-sink-route.yaml" + systemProperties: + properties: + - name: "test.message" + value: "${test.message}" + - name: "mqtt.topic" + value: "${mqtt.topic}" + - name: "mqtt.brokerUrl" + value: "tcp://${CITRUS_TESTCONTAINERS_MOSQUITTO_HOST}:${CITRUS_TESTCONTAINERS_MOSQUITTO_SERVICE_PORT}" + + # Verify source received the message + - camel: + jbang: + verify: + integration: "mqtt5-source-route" + logMessage: "${test.message}" diff --git a/tests/camel-kamelets-itest/src/test/resources/mqtt5/mqtt5-source-route.yaml b/tests/camel-kamelets-itest/src/test/resources/mqtt5/mqtt5-source-route.yaml new file mode 100644 index 000000000..6519ba526 --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/mqtt5/mqtt5-source-route.yaml @@ -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. +# --------------------------------------------------------------------------- + +- route: + from: + uri: "kamelet:mqtt5-source" + parameters: + topic: "{{mqtt.topic}}" + brokerUrl: "{{mqtt.brokerUrl}}" + clientId: "mqtt5-source-test" + steps: + - to: + uri: "kamelet:log-sink" diff --git a/tests/camel-kamelets-itest/src/test/resources/nats/nats-sink-route.yaml b/tests/camel-kamelets-itest/src/test/resources/nats/nats-sink-route.yaml new file mode 100644 index 000000000..04d4fa2eb --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/nats/nats-sink-route.yaml @@ -0,0 +1,32 @@ +# --------------------------------------------------------------------------- +# 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. +# --------------------------------------------------------------------------- + +- route: + from: + uri: "timer:tick" + parameters: + period: "10000" + repeatCount: 1 + steps: + - setBody: + constant: "{{test.message}}" + - log: "${body}" + - to: + uri: "kamelet:nats-sink" + parameters: + topic: "{{nats.topic}}" + servers: "{{nats.servers}}" diff --git a/tests/camel-kamelets-itest/src/test/resources/nats/nats-sink-to-source-route.citrus.it.yaml b/tests/camel-kamelets-itest/src/test/resources/nats/nats-sink-to-source-route.citrus.it.yaml new file mode 100644 index 000000000..0a3df946a --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/nats/nats-sink-to-source-route.citrus.it.yaml @@ -0,0 +1,72 @@ +# --------------------------------------------------------------------------- +# 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. +# --------------------------------------------------------------------------- + +name: nats-sink-to-source-route-test +variables: + - name: "test.message" + value: "hello-nats-test" + - name: "nats.topic" + value: "test-topic" +actions: + # Start NATS container + - testcontainers: + start: + container: + name: "nats" + image: "nats:2" + exposedPorts: + - 4222 + - 8222 + command: "-m 8222" + waitFor: + url: "http://localhost:8222" + + # Start source (subscriber) first + - camel: + jbang: + run: + integration: + file: "nats/nats-source-route.yaml" + systemProperties: + properties: + - name: "nats.topic" + value: "${nats.topic}" + - name: "nats.servers" + value: "nats://${CITRUS_TESTCONTAINERS_NATS_HOST}:${CITRUS_TESTCONTAINERS_NATS_SERVICE_PORT}" + + # Start sink (publisher) + - camel: + jbang: + run: + waitForRunningState: false + integration: + file: "nats/nats-sink-route.yaml" + systemProperties: + properties: + - name: "test.message" + value: "${test.message}" + - name: "nats.topic" + value: "${nats.topic}" + - name: "nats.servers" + value: "nats://${CITRUS_TESTCONTAINERS_NATS_HOST}:${CITRUS_TESTCONTAINERS_NATS_SERVICE_PORT}" + + # Verify source received the message + - camel: + jbang: + verify: + integration: "nats-source-route" + logMessage: "${test.message}" diff --git a/tests/camel-kamelets-itest/src/test/resources/nats/nats-source-route.yaml b/tests/camel-kamelets-itest/src/test/resources/nats/nats-source-route.yaml new file mode 100644 index 000000000..531c6269c --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/nats/nats-source-route.yaml @@ -0,0 +1,26 @@ +# --------------------------------------------------------------------------- +# 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. +# --------------------------------------------------------------------------- + +- route: + from: + uri: "kamelet:nats-source" + parameters: + topic: "{{nats.topic}}" + servers: "{{nats.servers}}" + steps: + - to: + uri: "kamelet:log-sink"
