This is an automated email from the ASF dual-hosted git repository. oscerd pushed a commit to branch chore/tier2-database-citrus-tests in repository https://gitbox.apache.org/repos/asf/camel-kamelets.git
commit 370d6ffb0bf65d34e7ef7ad861c6e6209b6d743c Author: Andrea Cosentino <[email protected]> AuthorDate: Fri Jul 10 11:09:04 2026 +0200 chore: Add Citrus integration tests for database kamelets Add container-based Citrus integration tests for 7 database kamelets using Testcontainers: - postgresql-source/sink (native Citrus postgresql: DSL with initScript) - mongodb-source/sink (native Citrus mongodb: DSL) - redis-sink (generic container: DSL with redis:7) - cassandra-source/sink (generic container: DSL with cassandra:4.1) All tests use Camel route YAML format per issue #2873. Each database gets its own IT class (PostgresIT, MongoIT, RedisIT, CassandraIT). Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Signed-off-by: Andrea Cosentino <[email protected]> --- tests/camel-kamelets-itest/pom.xml | 20 +++++++ .../src/test/java/CassandraIT.java | 33 ++++++++++ .../src/test/java/MongoIT.java | 33 ++++++++++ .../src/test/java/PostgresIT.java | 33 ++++++++++ .../src/test/java/RedisIT.java | 33 ++++++++++ .../cassandra/cassandra-sink-route.citrus.it.yaml | 70 ++++++++++++++++++++++ .../resources/cassandra/cassandra-sink-route.yaml | 34 +++++++++++ .../cassandra-source-route.citrus.it.yaml | 70 ++++++++++++++++++++++ .../cassandra/cassandra-source-route.yaml | 29 +++++++++ .../test/resources/cassandra/setupKeyspace.groovy | 29 +++++++++ .../test/resources/mongo/application.properties | 22 +++++++ .../src/test/resources/mongo/insertDocument.groovy | 27 +++++++++ .../mongo/mongodb-sink-route.citrus.it.yaml | 40 +++++++++++++ .../test/resources/mongo/mongodb-sink-route.yaml | 35 +++++++++++ .../mongo/mongodb-source-route.citrus.it.yaml | 45 ++++++++++++++ .../test/resources/mongo/mongodb-source-route.yaml | 30 ++++++++++ .../test/resources/postgres/application.properties | 22 +++++++ .../src/test/resources/postgres/init.sql | 2 + .../postgres/postgresql-sink-route.citrus.it.yaml | 45 ++++++++++++++ .../resources/postgres/postgresql-sink-route.yaml | 35 +++++++++++ .../postgresql-source-route.citrus.it.yaml | 45 ++++++++++++++ .../postgres/postgresql-source-route.yaml | 31 ++++++++++ .../redis/redis-sink-route.citrus.it.yaml | 51 ++++++++++++++++ .../src/test/resources/redis/redis-sink-route.yaml | 35 +++++++++++ 24 files changed, 849 insertions(+) diff --git a/tests/camel-kamelets-itest/pom.xml b/tests/camel-kamelets-itest/pom.xml index edf3884fc..4d5f2e7c9 100644 --- a/tests/camel-kamelets-itest/pom.xml +++ b/tests/camel-kamelets-itest/pom.xml @@ -103,6 +103,26 @@ <artifactId>camel-aws2-sns</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-sql</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-mongodb</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-spring-redis</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-cassandraql</artifactId> + <scope>test</scope> + </dependency> <!-- Citrus --> <dependency> diff --git a/tests/camel-kamelets-itest/src/test/java/CassandraIT.java b/tests/camel-kamelets-itest/src/test/java/CassandraIT.java new file mode 100644 index 000000000..d2a526ca0 --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/java/CassandraIT.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 CassandraIT { + + @CitrusTestFactory + public Stream<DynamicTest> cassandra() { + return CitrusTestFactorySupport.factory(TestLoader.YAML).packageScan("cassandra"); + } +} diff --git a/tests/camel-kamelets-itest/src/test/java/MongoIT.java b/tests/camel-kamelets-itest/src/test/java/MongoIT.java new file mode 100644 index 000000000..10ab25894 --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/java/MongoIT.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 MongoIT { + + @CitrusTestFactory + public Stream<DynamicTest> mongo() { + return CitrusTestFactorySupport.factory(TestLoader.YAML).packageScan("mongo"); + } +} diff --git a/tests/camel-kamelets-itest/src/test/java/PostgresIT.java b/tests/camel-kamelets-itest/src/test/java/PostgresIT.java new file mode 100644 index 000000000..2b8f63e76 --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/java/PostgresIT.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 PostgresIT { + + @CitrusTestFactory + public Stream<DynamicTest> postgres() { + return CitrusTestFactorySupport.factory(TestLoader.YAML).packageScan("postgres"); + } +} diff --git a/tests/camel-kamelets-itest/src/test/java/RedisIT.java b/tests/camel-kamelets-itest/src/test/java/RedisIT.java new file mode 100644 index 000000000..8653a1faa --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/java/RedisIT.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 RedisIT { + + @CitrusTestFactory + public Stream<DynamicTest> redis() { + return CitrusTestFactorySupport.factory(TestLoader.YAML).packageScan("redis"); + } +} diff --git a/tests/camel-kamelets-itest/src/test/resources/cassandra/cassandra-sink-route.citrus.it.yaml b/tests/camel-kamelets-itest/src/test/resources/cassandra/cassandra-sink-route.citrus.it.yaml new file mode 100644 index 000000000..4313a58aa --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/cassandra/cassandra-sink-route.citrus.it.yaml @@ -0,0 +1,70 @@ +# --------------------------------------------------------------------------- +# 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: cassandra-sink-route-test +actions: + # Create Cassandra infrastructure + - testcontainers: + start: + container: + name: "cassandra" + image: "cassandra:4.1" + exposedPorts: + - 9042 + startUpTimeout: 120 + env: + - name: "CASSANDRA_SNITCH" + value: "GossipingPropertyFileSnitch" + - name: "JVM_OPTS" + value: "-Dcassandra.skip_wait_for_gossip_to_settle=0 -Dcassandra.initial_token=0" + - name: "HEAP_NEWSIZE" + value: "128M" + - name: "MAX_HEAP_SIZE" + value: "1024M" + - name: "CASSANDRA_ENDPOINT_SNITCH" + value: "GossipingPropertyFileSnitch" + - name: "CASSANDRA_DC" + value: "datacenter1" + waitFor: + log: + message: "Startup complete" + + # Setup keyspace and table + - groovy: + script: + file: "cassandra/setupKeyspace.groovy" + + # Create Camel JBang integration (sink) + - camel: + jbang: + run: + waitForRunningState: false + integration: + file: "cassandra/cassandra-sink-route.yaml" + systemProperties: + properties: + - name: "cassandra.host" + value: "${CITRUS_TESTCONTAINERS_CASSANDRA_HOST}" + - name: "cassandra.port" + value: "${CITRUS_TESTCONTAINERS_CASSANDRA_SERVICE_PORT}" + + # Verify Cassandra sink executed + - camel: + jbang: + verify: + integration: "cassandra-sink-route" + logMessage: "from-cassandra-sink" diff --git a/tests/camel-kamelets-itest/src/test/resources/cassandra/cassandra-sink-route.yaml b/tests/camel-kamelets-itest/src/test/resources/cassandra/cassandra-sink-route.yaml new file mode 100644 index 000000000..9350850e5 --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/cassandra/cassandra-sink-route.yaml @@ -0,0 +1,34 @@ +# --------------------------------------------------------------------------- +# 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: '[{"id": 42, "name": "sink-test", "value": "from-cassandra-sink"}]' + - to: + uri: "kamelet:cassandra-sink" + parameters: + connectionHost: "{{cassandra.host}}" + connectionPort: "{{cassandra.port}}" + keyspace: "test_ks" + query: "INSERT INTO test_data (id, name, value) VALUES (?, ?, ?)" + consistencyLevel: "ONE" diff --git a/tests/camel-kamelets-itest/src/test/resources/cassandra/cassandra-source-route.citrus.it.yaml b/tests/camel-kamelets-itest/src/test/resources/cassandra/cassandra-source-route.citrus.it.yaml new file mode 100644 index 000000000..86515460c --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/cassandra/cassandra-source-route.citrus.it.yaml @@ -0,0 +1,70 @@ +# --------------------------------------------------------------------------- +# 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: cassandra-source-route-test +actions: + # Create Cassandra infrastructure + - testcontainers: + start: + container: + name: "cassandra" + image: "cassandra:4.1" + exposedPorts: + - 9042 + startUpTimeout: 120 + env: + - name: "CASSANDRA_SNITCH" + value: "GossipingPropertyFileSnitch" + - name: "JVM_OPTS" + value: "-Dcassandra.skip_wait_for_gossip_to_settle=0 -Dcassandra.initial_token=0" + - name: "HEAP_NEWSIZE" + value: "128M" + - name: "MAX_HEAP_SIZE" + value: "1024M" + - name: "CASSANDRA_ENDPOINT_SNITCH" + value: "GossipingPropertyFileSnitch" + - name: "CASSANDRA_DC" + value: "datacenter1" + waitFor: + log: + message: "Startup complete" + + # Setup keyspace and table + - groovy: + script: + file: "cassandra/setupKeyspace.groovy" + + # Create Camel JBang integration (source) + - camel: + jbang: + run: + waitForRunningState: false + integration: + file: "cassandra/cassandra-source-route.yaml" + systemProperties: + properties: + - name: "cassandra.host" + value: "${CITRUS_TESTCONTAINERS_CASSANDRA_HOST}" + - name: "cassandra.port" + value: "${CITRUS_TESTCONTAINERS_CASSANDRA_SERVICE_PORT}" + + # Verify Cassandra source + - camel: + jbang: + verify: + integration: "cassandra-source-route" + logMessage: "hello-cassandra" diff --git a/tests/camel-kamelets-itest/src/test/resources/cassandra/cassandra-source-route.yaml b/tests/camel-kamelets-itest/src/test/resources/cassandra/cassandra-source-route.yaml new file mode 100644 index 000000000..df06a8617 --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/cassandra/cassandra-source-route.yaml @@ -0,0 +1,29 @@ +# --------------------------------------------------------------------------- +# 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:cassandra-source" + parameters: + connectionHost: "{{cassandra.host}}" + connectionPort: "{{cassandra.port}}" + keyspace: "test_ks" + query: "SELECT * FROM test_data" + consistencyLevel: "ONE" + steps: + - to: + uri: "kamelet:log-sink" diff --git a/tests/camel-kamelets-itest/src/test/resources/cassandra/setupKeyspace.groovy b/tests/camel-kamelets-itest/src/test/resources/cassandra/setupKeyspace.groovy new file mode 100644 index 000000000..6176b3289 --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/cassandra/setupKeyspace.groovy @@ -0,0 +1,29 @@ +/* + * 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 com.datastax.oss.driver.api.core.CqlSession + +def session = CqlSession.builder() + .addContactPoint(new InetSocketAddress('${CITRUS_TESTCONTAINERS_CASSANDRA_HOST}', Integer.parseInt('${CITRUS_TESTCONTAINERS_CASSANDRA_SERVICE_PORT}'))) + .withLocalDatacenter('datacenter1') + .build() + +session.execute("CREATE KEYSPACE IF NOT EXISTS test_ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1}") +session.execute("CREATE TABLE IF NOT EXISTS test_ks.test_data (id int PRIMARY KEY, name text, value text)") +session.execute("INSERT INTO test_ks.test_data (id, name, value) VALUES (1, 'test-entry', 'hello-cassandra')") + +session.close() diff --git a/tests/camel-kamelets-itest/src/test/resources/mongo/application.properties b/tests/camel-kamelets-itest/src/test/resources/mongo/application.properties new file mode 100644 index 000000000..9d29f2968 --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/mongo/application.properties @@ -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. +# + +mongodb.hosts=${CITRUS_TESTCONTAINERS_MONGODB_HOST}:${CITRUS_TESTCONTAINERS_MONGODB_PORT} +mongodb.database=testdb +mongodb.collection=testcol +mongodb.ssl=false +mongodb.sslValidationEnabled=false diff --git a/tests/camel-kamelets-itest/src/test/resources/mongo/insertDocument.groovy b/tests/camel-kamelets-itest/src/test/resources/mongo/insertDocument.groovy new file mode 100644 index 000000000..04f662b3f --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/mongo/insertDocument.groovy @@ -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. + */ + +import com.mongodb.client.MongoClients +import com.mongodb.client.MongoClient +import org.bson.Document + +MongoClient mongoClient = MongoClients.create('mongodb://${CITRUS_TESTCONTAINERS_MONGODB_HOST}:${CITRUS_TESTCONTAINERS_MONGODB_PORT}') + +def db = mongoClient.getDatabase('testdb') +def col = db.getCollection('testcol') + +col.insertOne(new Document('name', 'source-test').append('value', 'hello-from-mongo')) diff --git a/tests/camel-kamelets-itest/src/test/resources/mongo/mongodb-sink-route.citrus.it.yaml b/tests/camel-kamelets-itest/src/test/resources/mongo/mongodb-sink-route.citrus.it.yaml new file mode 100644 index 000000000..616c9bc41 --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/mongo/mongodb-sink-route.citrus.it.yaml @@ -0,0 +1,40 @@ +# --------------------------------------------------------------------------- +# 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: mongodb-sink-route-test +actions: + # Create MongoDB infrastructure + - testcontainers: + start: + mongodb: {} + + # Create Camel JBang integration (sink) + - camel: + jbang: + run: + waitForRunningState: false + integration: + file: "mongo/mongodb-sink-route.yaml" + systemProperties: + file: "mongo/application.properties" + + # Verify MongoDB sink executed + - camel: + jbang: + verify: + integration: "mongodb-sink-route" + logMessage: "hello-mongodb" diff --git a/tests/camel-kamelets-itest/src/test/resources/mongo/mongodb-sink-route.yaml b/tests/camel-kamelets-itest/src/test/resources/mongo/mongodb-sink-route.yaml new file mode 100644 index 000000000..129b3cafc --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/mongo/mongodb-sink-route.yaml @@ -0,0 +1,35 @@ +# --------------------------------------------------------------------------- +# 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: '{"name": "mongo-test", "value": "hello-mongodb"}' + - to: + uri: "kamelet:mongodb-sink" + parameters: + hosts: "{{mongodb.hosts}}" + collection: "{{mongodb.collection}}" + database: "{{mongodb.database}}" + ssl: "{{mongodb.ssl}}" + sslValidationEnabled: "{{mongodb.sslValidationEnabled}}" + createCollection: true diff --git a/tests/camel-kamelets-itest/src/test/resources/mongo/mongodb-source-route.citrus.it.yaml b/tests/camel-kamelets-itest/src/test/resources/mongo/mongodb-source-route.citrus.it.yaml new file mode 100644 index 000000000..3e7fed3af --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/mongo/mongodb-source-route.citrus.it.yaml @@ -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. +# --------------------------------------------------------------------------- + +name: mongodb-source-route-test +actions: + # Create MongoDB infrastructure + - testcontainers: + start: + mongodb: {} + + # Insert test document + - groovy: + script: + file: "mongo/insertDocument.groovy" + + # Create Camel JBang integration (source) + - camel: + jbang: + run: + waitForRunningState: false + integration: + file: "mongo/mongodb-source-route.yaml" + systemProperties: + file: "mongo/application.properties" + + # Verify MongoDB source picked up the document + - camel: + jbang: + verify: + integration: "mongodb-source-route" + logMessage: "hello-from-mongo" diff --git a/tests/camel-kamelets-itest/src/test/resources/mongo/mongodb-source-route.yaml b/tests/camel-kamelets-itest/src/test/resources/mongo/mongodb-source-route.yaml new file mode 100644 index 000000000..9ab1d865a --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/mongo/mongodb-source-route.yaml @@ -0,0 +1,30 @@ +# --------------------------------------------------------------------------- +# 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:mongodb-source" + parameters: + hosts: "{{mongodb.hosts}}" + collection: "{{mongodb.collection}}" + database: "{{mongodb.database}}" + ssl: "{{mongodb.ssl}}" + sslValidationEnabled: "{{mongodb.sslValidationEnabled}}" + persistentTailTracking: false + steps: + - to: + uri: "kamelet:log-sink" diff --git a/tests/camel-kamelets-itest/src/test/resources/postgres/application.properties b/tests/camel-kamelets-itest/src/test/resources/postgres/application.properties new file mode 100644 index 000000000..a252d0f7a --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/postgres/application.properties @@ -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. +# + +postgresql.serverName=${CITRUS_TESTCONTAINERS_POSTGRESQL_HOST} +postgresql.serverPort=${CITRUS_TESTCONTAINERS_POSTGRESQL_PORT} +postgresql.databaseName=${CITRUS_TESTCONTAINERS_POSTGRESQL_DATABASE} +postgresql.username=${CITRUS_TESTCONTAINERS_POSTGRESQL_USERNAME} +postgresql.password=${CITRUS_TESTCONTAINERS_POSTGRESQL_PASSWORD} diff --git a/tests/camel-kamelets-itest/src/test/resources/postgres/init.sql b/tests/camel-kamelets-itest/src/test/resources/postgres/init.sql new file mode 100644 index 000000000..bb0bd75bc --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/postgres/init.sql @@ -0,0 +1,2 @@ +CREATE TABLE IF NOT EXISTS test_data (id SERIAL PRIMARY KEY, name VARCHAR(100), value VARCHAR(100)); +INSERT INTO test_data (name, value) VALUES ('test-entry', 'hello-postgres'); diff --git a/tests/camel-kamelets-itest/src/test/resources/postgres/postgresql-sink-route.citrus.it.yaml b/tests/camel-kamelets-itest/src/test/resources/postgres/postgresql-sink-route.citrus.it.yaml new file mode 100644 index 000000000..2e849b44e --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/postgres/postgresql-sink-route.citrus.it.yaml @@ -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. +# --------------------------------------------------------------------------- + +name: postgresql-sink-route-test +actions: + # Create PostgreSQL infrastructure + - testcontainers: + start: + postgresql: + database: "testdb" + username: "test" + password: "test" + initScript: + file: "postgres/init.sql" + + # Create Camel JBang integration (sink) + - camel: + jbang: + run: + waitForRunningState: false + integration: + file: "postgres/postgresql-sink-route.yaml" + systemProperties: + file: "postgres/application.properties" + + # Verify PostgreSQL sink executed + - camel: + jbang: + verify: + integration: "postgresql-sink-route" + logMessage: "from-sink" diff --git a/tests/camel-kamelets-itest/src/test/resources/postgres/postgresql-sink-route.yaml b/tests/camel-kamelets-itest/src/test/resources/postgres/postgresql-sink-route.yaml new file mode 100644 index 000000000..df4ec1120 --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/postgres/postgresql-sink-route.yaml @@ -0,0 +1,35 @@ +# --------------------------------------------------------------------------- +# 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: '{"id": 99, "name": "sink-test", "value": "from-sink"}' + - to: + uri: "kamelet:postgresql-sink" + parameters: + serverName: "{{postgresql.serverName}}" + serverPort: "{{postgresql.serverPort}}" + databaseName: "{{postgresql.databaseName}}" + username: "{{postgresql.username}}" + password: "{{postgresql.password}}" + query: "INSERT INTO test_data (id, name, value) VALUES (:#id, :#name, :#value)" diff --git a/tests/camel-kamelets-itest/src/test/resources/postgres/postgresql-source-route.citrus.it.yaml b/tests/camel-kamelets-itest/src/test/resources/postgres/postgresql-source-route.citrus.it.yaml new file mode 100644 index 000000000..dfeebc429 --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/postgres/postgresql-source-route.citrus.it.yaml @@ -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. +# --------------------------------------------------------------------------- + +name: postgresql-source-route-test +actions: + # Create PostgreSQL infrastructure + - testcontainers: + start: + postgresql: + database: "testdb" + username: "test" + password: "test" + initScript: + file: "postgres/init.sql" + + # Create Camel JBang integration + - camel: + jbang: + run: + waitForRunningState: false + integration: + file: "postgres/postgresql-source-route.yaml" + systemProperties: + file: "postgres/application.properties" + + # Verify PostgreSQL source + - camel: + jbang: + verify: + integration: "postgresql-source-route" + logMessage: "hello-postgres" diff --git a/tests/camel-kamelets-itest/src/test/resources/postgres/postgresql-source-route.yaml b/tests/camel-kamelets-itest/src/test/resources/postgres/postgresql-source-route.yaml new file mode 100644 index 000000000..6d6801088 --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/postgres/postgresql-source-route.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. +# --------------------------------------------------------------------------- + +- route: + from: + uri: "kamelet:postgresql-source" + parameters: + serverName: "{{postgresql.serverName}}" + serverPort: "{{postgresql.serverPort}}" + databaseName: "{{postgresql.databaseName}}" + username: "{{postgresql.username}}" + password: "{{postgresql.password}}" + query: "SELECT * FROM test_data" + delay: 1000 + steps: + - to: + uri: "kamelet:log-sink" diff --git a/tests/camel-kamelets-itest/src/test/resources/redis/redis-sink-route.citrus.it.yaml b/tests/camel-kamelets-itest/src/test/resources/redis/redis-sink-route.citrus.it.yaml new file mode 100644 index 000000000..a47efb7c7 --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/redis/redis-sink-route.citrus.it.yaml @@ -0,0 +1,51 @@ +# --------------------------------------------------------------------------- +# 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: redis-sink-route-test +actions: + # Create Redis infrastructure + - testcontainers: + start: + container: + name: "redis" + image: "redis:7" + exposedPorts: + - 6379 + waitFor: + log: + message: "Ready to accept connections" + + # Create Camel JBang integration (sink) + - camel: + jbang: + run: + waitForRunningState: false + integration: + file: "redis/redis-sink-route.yaml" + systemProperties: + properties: + - name: "redis.host" + value: "${CITRUS_TESTCONTAINERS_REDIS_HOST}" + - name: "redis.port" + value: "${CITRUS_TESTCONTAINERS_REDIS_SERVICE_PORT}" + + # Verify Redis sink executed + - camel: + jbang: + verify: + integration: "redis-sink-route" + logMessage: "hello-redis" diff --git a/tests/camel-kamelets-itest/src/test/resources/redis/redis-sink-route.yaml b/tests/camel-kamelets-itest/src/test/resources/redis/redis-sink-route.yaml new file mode 100644 index 000000000..fc3a312dc --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/redis/redis-sink-route.yaml @@ -0,0 +1,35 @@ +# --------------------------------------------------------------------------- +# 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: "hello-redis" + - setHeader: + name: CamelRedis.Key + constant: "test-key" + - to: + uri: "kamelet:redis-sink" + parameters: + redisHost: "{{redis.host}}" + redisPort: "{{redis.port}}" + command: "SET"
