diff --git a/tests/camel-kamelets-itest/pom.xml b/tests/camel-kamelets-itest/pom.xml index edf3884fc..912dbd9ff 100644 --- a/tests/camel-kamelets-itest/pom.xml +++ b/tests/camel-kamelets-itest/pom.xml @@ -103,6 +103,44 @@ camel-aws2-sns test + + org.apache.camel + camel-sql + test + + + org.springframework + spring-jdbc + + + + + org.postgresql + postgresql + ${version.org.postgresql.postgresql} + test + + + org.apache.camel + camel-mongodb + test + + + org.apache.camel + camel-spring-redis + test + + + org.springframework.data + spring-data-redis + + + + + org.apache.camel + camel-cassandraql + test + 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 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 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 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 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.disabled b/tests/camel-kamelets-itest/src/test/resources/cassandra/cassandra-sink-route.citrus.it.yaml.disabled new file mode 100644 index 000000000..ea0a2fef4 --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/cassandra/cassandra-sink-route.citrus.it.yaml.disabled @@ -0,0 +1,69 @@ +# --------------------------------------------------------------------------- +# 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: + logMessage: "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.disabled b/tests/camel-kamelets-itest/src/test/resources/cassandra/cassandra-source-route.citrus.it.yaml.disabled new file mode 100644 index 000000000..c97e2feb3 --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/cassandra/cassandra-source-route.citrus.it.yaml.disabled @@ -0,0 +1,69 @@ +# --------------------------------------------------------------------------- +# 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: + logMessage: "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..051e88d0c --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/mongo/insertDocument.groovy @@ -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. + */ + +import com.mongodb.client.MongoClients +import com.mongodb.client.MongoClient +import com.mongodb.client.model.CreateCollectionOptions +import org.bson.Document + +MongoClient mongoClient = MongoClients.create('mongodb://${CITRUS_TESTCONTAINERS_MONGODB_HOST}:${CITRUS_TESTCONTAINERS_MONGODB_PORT}') + +def db = mongoClient.getDatabase('testdb') + +db.createCollection('testcol', new CreateCollectionOptions().capped(true).sizeInBytes(1048576)) + +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..b52785ded --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/mongo/mongodb-sink-route.yaml @@ -0,0 +1,36 @@ +# --------------------------------------------------------------------------- +# 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"}' + - log: "${body}" + - 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..b96e16b07 --- /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_SERVICE_PORT} +postgresql.databaseName=${CITRUS_TESTCONTAINERS_POSTGRESQL_DB_NAME} +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..30eb4caaf --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/postgres/postgresql-sink-route.yaml @@ -0,0 +1,36 @@ +# --------------------------------------------------------------------------- +# 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"}' + - log: "${body}" + - 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.disabled b/tests/camel-kamelets-itest/src/test/resources/redis/redis-sink-route.citrus.it.yaml.disabled new file mode 100644 index 000000000..c38c59668 --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/redis/redis-sink-route.citrus.it.yaml.disabled @@ -0,0 +1,50 @@ +# --------------------------------------------------------------------------- +# 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: + logMessage: "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"