This is an automated email from the ASF dual-hosted git repository. jamesnetherton pushed a commit to branch camel-master in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/camel-master by this push: new a0e884c CassandraQL native support #1355 a0e884c is described below commit a0e884cd93d68f0aa7514b4ccc538e561cc99401 Author: JiriOndrusek <ondrusek.j...@gmail.com> AuthorDate: Tue Feb 9 09:25:08 2021 +0100 CassandraQL native support #1355 --- .../pages/reference/extensions/cassandraql.adoc | 8 +- .../ROOT/partials/reference/components/cql.adoc | 6 +- .../cassandraql/integration-test/pom.xml | 66 ---------- .../cassandraql/it/CassandraqlResource.java | 51 -------- extensions-jvm/pom.xml | 1 - .../cassandraql/deployment/pom.xml | 12 +- .../deployment/CassandraqlProcessor.java | 20 +-- {extensions-jvm => extensions}/cassandraql/pom.xml | 5 +- .../cassandraql/runtime/pom.xml | 29 ++--- .../main/resources/META-INF/quarkus-extension.yaml | 3 +- extensions/pom.xml | 1 + .../cassandraql}/pom.xml | 111 +++++++++-------- .../cassandraql/it/CassandraqlResource.java | 111 +++++++++++++++++ .../quarkus/component/cassandraql/it/Employee.java | 81 +++++++++++++ .../component/cassandraql/it/CassandraqlIT.java | 16 +-- .../component/cassandraql/it/CassandraqlTest.java | 135 +++++++++++++++++++++ .../cassandraql/it/CassandraqlTestResource.java | 86 +++++++++++++ integration-tests/pom.xml | 1 + pom.xml | 1 + poms/bom/pom.xml | 10 ++ tooling/scripts/test-categories.yaml | 1 + 21 files changed, 525 insertions(+), 230 deletions(-) diff --git a/docs/modules/ROOT/pages/reference/extensions/cassandraql.adoc b/docs/modules/ROOT/pages/reference/extensions/cassandraql.adoc index 5d6e24b..40d6c9b 100644 --- a/docs/modules/ROOT/pages/reference/extensions/cassandraql.adoc +++ b/docs/modules/ROOT/pages/reference/extensions/cassandraql.adoc @@ -3,15 +3,15 @@ = Cassandra CQL :page-aliases: extensions/cassandraql.adoc :cq-artifact-id: camel-quarkus-cassandraql -:cq-native-supported: false -:cq-status: Preview +:cq-native-supported: true +:cq-status: Stable :cq-description: Integrate with Cassandra 2.0 using the CQL3 API (not the Thrift API). Based on Cassandra Java Driver provided by DataStax. :cq-deprecated: false :cq-jvm-since: 1.0.0 -:cq-native-since: n/a +:cq-native-since: 1.7.0 [.badges] -[.badge-key]##JVM since##[.badge-supported]##1.0.0## [.badge-key]##Native##[.badge-unsupported]##unsupported## +[.badge-key]##JVM since##[.badge-supported]##1.0.0## [.badge-key]##Native since##[.badge-supported]##1.7.0## Integrate with Cassandra 2.0 using the CQL3 API (not the Thrift API). Based on Cassandra Java Driver provided by DataStax. diff --git a/docs/modules/ROOT/partials/reference/components/cql.adoc b/docs/modules/ROOT/partials/reference/components/cql.adoc index 131165e..c22cc9f 100644 --- a/docs/modules/ROOT/partials/reference/components/cql.adoc +++ b/docs/modules/ROOT/partials/reference/components/cql.adoc @@ -2,11 +2,11 @@ // This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page :cq-artifact-id: camel-quarkus-cassandraql :cq-artifact-id-base: cassandraql -:cq-native-supported: false -:cq-status: Preview +:cq-native-supported: true +:cq-status: Stable :cq-deprecated: false :cq-jvm-since: 1.0.0 -:cq-native-since: n/a +:cq-native-since: 1.7.0 :cq-camel-part-name: cql :cq-camel-part-title: Cassandra CQL :cq-camel-part-description: Integrate with Cassandra 2.0 using the CQL3 API (not the Thrift API). Based on Cassandra Java Driver provided by DataStax. diff --git a/extensions-jvm/cassandraql/integration-test/pom.xml b/extensions-jvm/cassandraql/integration-test/pom.xml deleted file mode 100644 index b195056..0000000 --- a/extensions-jvm/cassandraql/integration-test/pom.xml +++ /dev/null @@ -1,66 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-build-parent-it</artifactId> - <version>1.7.0-SNAPSHOT</version> - <relativePath>../../../poms/build-parent-it/pom.xml</relativePath> - </parent> - - <artifactId>camel-quarkus-cassandraql-integration-test</artifactId> - <name>Camel Quarkus :: Cassandra CQL :: Integration Test</name> - <description>Integration tests for Camel Quarkus Cassandra CQL extension</description> - - <dependencies> - <dependency> - <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-cassandraql</artifactId> - <exclusions> - <exclusion> - <groupId>org.codehaus.groovy</groupId> - <artifactId>groovy</artifactId> - </exclusion> - <exclusion> - <groupId>org.codehaus.groovy</groupId> - <artifactId>groovy-json</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-resteasy</artifactId> - </dependency> - - <!-- test dependencies --> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-junit5</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>io.rest-assured</groupId> - <artifactId>rest-assured</artifactId> - <scope>test</scope> - </dependency> - </dependencies> - -</project> diff --git a/extensions-jvm/cassandraql/integration-test/src/main/java/org/apache/camel/quarkus/component/cassandraql/it/CassandraqlResource.java b/extensions-jvm/cassandraql/integration-test/src/main/java/org/apache/camel/quarkus/component/cassandraql/it/CassandraqlResource.java deleted file mode 100644 index 4c25230..0000000 --- a/extensions-jvm/cassandraql/integration-test/src/main/java/org/apache/camel/quarkus/component/cassandraql/it/CassandraqlResource.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.quarkus.component.cassandraql.it; - -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import org.apache.camel.CamelContext; -import org.jboss.logging.Logger; - -@Path("/cassandraql") -@ApplicationScoped -public class CassandraqlResource { - - private static final Logger LOG = Logger.getLogger(CassandraqlResource.class); - - private static final String COMPONENT_CQL = "cql"; - @Inject - CamelContext context; - - @Path("/load/component/cql") - @GET - @Produces(MediaType.TEXT_PLAIN) - public Response loadComponentCql() throws Exception { - /* This is an autogenerated test */ - if (context.getComponent(COMPONENT_CQL) != null) { - return Response.ok().build(); - } - LOG.warnf("Could not load [%s] from the Camel context", COMPONENT_CQL); - return Response.status(500, COMPONENT_CQL + " could not be loaded from the Camel context").build(); - } -} diff --git a/extensions-jvm/pom.xml b/extensions-jvm/pom.xml index 6bdb869..374e604 100644 --- a/extensions-jvm/pom.xml +++ b/extensions-jvm/pom.xml @@ -47,7 +47,6 @@ <module>beanio</module> <module>beanstalk</module> <module>bonita</module> - <module>cassandraql</module> <module>cbor</module> <module>chatscript</module> <module>chunk</module> diff --git a/extensions-jvm/cassandraql/deployment/pom.xml b/extensions/cassandraql/deployment/pom.xml similarity index 80% rename from extensions-jvm/cassandraql/deployment/pom.xml rename to extensions/cassandraql/deployment/pom.xml index b4cbab5..a594911 100644 --- a/extensions-jvm/cassandraql/deployment/pom.xml +++ b/extensions/cassandraql/deployment/pom.xml @@ -17,7 +17,9 @@ limitations under the License. --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.apache.camel.quarkus</groupId> @@ -38,6 +40,14 @@ <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-cassandraql</artifactId> </dependency> + <dependency> + <groupId>com.datastax.oss.quarkus</groupId> + <artifactId>cassandra-quarkus-client-deployment</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-jsonp-deployment</artifactId> + </dependency> </dependencies> <build> diff --git a/extensions-jvm/cassandraql/deployment/src/main/java/org/apache/camel/quarkus/component/cassandraql/deployment/CassandraqlProcessor.java b/extensions/cassandraql/deployment/src/main/java/org/apache/camel/quarkus/component/cassandraql/deployment/CassandraqlProcessor.java similarity index 62% rename from extensions-jvm/cassandraql/deployment/src/main/java/org/apache/camel/quarkus/component/cassandraql/deployment/CassandraqlProcessor.java rename to extensions/cassandraql/deployment/src/main/java/org/apache/camel/quarkus/component/cassandraql/deployment/CassandraqlProcessor.java index 8a85d68..7a410d1 100644 --- a/extensions-jvm/cassandraql/deployment/src/main/java/org/apache/camel/quarkus/component/cassandraql/deployment/CassandraqlProcessor.java +++ b/extensions/cassandraql/deployment/src/main/java/org/apache/camel/quarkus/component/cassandraql/deployment/CassandraqlProcessor.java @@ -16,16 +16,12 @@ */ package org.apache.camel.quarkus.component.cassandraql.deployment; +import com.datastax.oss.driver.internal.core.metrics.DropwizardMetricsFactory; import io.quarkus.deployment.annotations.BuildStep; -import io.quarkus.deployment.annotations.ExecutionTime; -import io.quarkus.deployment.annotations.Record; import io.quarkus.deployment.builditem.FeatureBuildItem; -import io.quarkus.deployment.pkg.steps.NativeBuild; -import org.apache.camel.quarkus.core.JvmOnlyRecorder; -import org.jboss.logging.Logger; +import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; class CassandraqlProcessor { - private static final Logger LOG = Logger.getLogger(CassandraqlProcessor.class); private static final String FEATURE = "camel-cassandraql"; @@ -34,14 +30,8 @@ class CassandraqlProcessor { return new FeatureBuildItem(FEATURE); } - /** - * Remove this once this extension starts supporting the native mode. - */ - @BuildStep(onlyIf = NativeBuild.class) - @Record(value = ExecutionTime.RUNTIME_INIT) - void warnJvmInNative(JvmOnlyRecorder recorder) { - JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time - recorder.warnJvmInNative(FEATURE); // warn at runtime + @BuildStep + ReflectiveClassBuildItem registerForReflection() { + return new ReflectiveClassBuildItem(false, false, DropwizardMetricsFactory.class); } - } diff --git a/extensions-jvm/cassandraql/pom.xml b/extensions/cassandraql/pom.xml similarity index 84% rename from extensions-jvm/cassandraql/pom.xml rename to extensions/cassandraql/pom.xml index eb1eb83..517f016 100644 --- a/extensions-jvm/cassandraql/pom.xml +++ b/extensions/cassandraql/pom.xml @@ -17,7 +17,9 @@ limitations under the License. --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.apache.camel.quarkus</groupId> @@ -33,6 +35,5 @@ <modules> <module>deployment</module> <module>runtime</module> - <module>integration-test</module> </modules> </project> diff --git a/extensions-jvm/cassandraql/runtime/pom.xml b/extensions/cassandraql/runtime/pom.xml similarity index 79% copy from extensions-jvm/cassandraql/runtime/pom.xml copy to extensions/cassandraql/runtime/pom.xml index 8302eed..b32d5d6 100644 --- a/extensions-jvm/cassandraql/runtime/pom.xml +++ b/extensions/cassandraql/runtime/pom.xml @@ -17,7 +17,9 @@ limitations under the License. --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.apache.camel.quarkus</groupId> @@ -28,9 +30,11 @@ <artifactId>camel-quarkus-cassandraql</artifactId> <name>Camel Quarkus :: Cassandra CQL :: Runtime</name> + <description>Integrate with Cassandra 2.0 using the CQL3 API (not the Thrift API). Based on Cassandra Java Driver provided by DataStax.</description> <properties> <camel.quarkus.jvmSince>1.0.0</camel.quarkus.jvmSince> + <camel.quarkus.nativeSince>1.7.0</camel.quarkus.nativeSince> </properties> <dependencyManagement> @@ -53,28 +57,10 @@ <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-cassandraql</artifactId> - <exclusions> - <exclusion> - <groupId>org.ow2.asm</groupId> - <artifactId>asm-util</artifactId> - </exclusion> - <exclusion> - <groupId>org.codehaus.groovy</groupId> - <artifactId>groovy</artifactId> - </exclusion> - <exclusion> - <groupId>org.codehaus.groovy</groupId> - <artifactId>groovy-json</artifactId> - </exclusion> - </exclusions> </dependency> <dependency> - <groupId>org.codehaus.groovy</groupId> - <artifactId>groovy</artifactId> - </dependency> - <dependency> - <groupId>org.codehaus.groovy</groupId> - <artifactId>groovy-json</artifactId> + <groupId>com.datastax.oss.quarkus</groupId> + <artifactId>cassandra-quarkus-client</artifactId> </dependency> </dependencies> @@ -100,6 +86,7 @@ </plugins> </build> + <profiles> <profile> <id>full</id> diff --git a/extensions-jvm/cassandraql/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/cassandraql/runtime/src/main/resources/META-INF/quarkus-extension.yaml similarity index 97% rename from extensions-jvm/cassandraql/runtime/src/main/resources/META-INF/quarkus-extension.yaml rename to extensions/cassandraql/runtime/src/main/resources/META-INF/quarkus-extension.yaml index 5f5467a..44ccf61 100644 --- a/extensions-jvm/cassandraql/runtime/src/main/resources/META-INF/quarkus-extension.yaml +++ b/extensions/cassandraql/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -24,9 +24,8 @@ name: "Camel Cassandra CQL" description: "Integrate with Cassandra 2.0 using the CQL3 API (not the Thrift API). Based on Cassandra Java Driver provided by DataStax" metadata: - unlisted: true guide: "https://camel.apache.org/camel-quarkus/latest/reference/extensions/cassandraql.html" categories: - "integration" status: - - "preview" + - "stable" diff --git a/extensions/pom.xml b/extensions/pom.xml index 4aae82a..8ea8822 100644 --- a/extensions/pom.xml +++ b/extensions/pom.xml @@ -85,6 +85,7 @@ <module>braintree</module> <module>browse</module> <module>caffeine</module> + <module>cassandraql</module> <module>componentdsl</module> <module>consul</module> <module>controlbus</module> diff --git a/extensions-jvm/cassandraql/runtime/pom.xml b/integration-tests/cassandraql/pom.xml similarity index 50% rename from extensions-jvm/cassandraql/runtime/pom.xml rename to integration-tests/cassandraql/pom.xml index 8302eed..0f56448 100644 --- a/extensions-jvm/cassandraql/runtime/pom.xml +++ b/integration-tests/cassandraql/pom.xml @@ -17,27 +17,26 @@ limitations under the License. --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-cassandraql-parent</artifactId> + <artifactId>camel-quarkus-integration-tests</artifactId> <version>1.7.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> - <artifactId>camel-quarkus-cassandraql</artifactId> - <name>Camel Quarkus :: Cassandra CQL :: Runtime</name> - - <properties> - <camel.quarkus.jvmSince>1.0.0</camel.quarkus.jvmSince> - </properties> + <artifactId>camel-quarkus-integration-test-cassandraql</artifactId> + <name>Camel Quarkus :: Integration Tests :: Cassandra CQL</name> + <description>Integration tests for Camel Quarkus Cassandra CQL extension</description> <dependencyManagement> <dependencies> <dependency> <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-bom</artifactId> + <artifactId>camel-quarkus-bom-test</artifactId> <version>${project.version}</version> <type>pom</type> <scope>import</scope> @@ -48,17 +47,9 @@ <dependencies> <dependency> <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-core</artifactId> - </dependency> - <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-cassandraql</artifactId> + <artifactId>camel-quarkus-cassandraql</artifactId> <exclusions> <exclusion> - <groupId>org.ow2.asm</groupId> - <artifactId>asm-util</artifactId> - </exclusion> - <exclusion> <groupId>org.codehaus.groovy</groupId> <artifactId>groovy</artifactId> </exclusion> @@ -69,57 +60,74 @@ </exclusions> </dependency> <dependency> - <groupId>org.codehaus.groovy</groupId> - <artifactId>groovy</artifactId> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-resteasy</artifactId> </dependency> <dependency> - <groupId>org.codehaus.groovy</groupId> - <artifactId>groovy-json</artifactId> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-resteasy-jackson</artifactId> </dependency> - </dependencies> - <build> - <plugins> - <plugin> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-bootstrap-maven-plugin</artifactId> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - <configuration> - <annotationProcessorPaths> - <path> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-extension-processor</artifactId> - <version>${quarkus.version}</version> - </path> - </annotationProcessorPaths> - </configuration> - </plugin> - </plugins> - </build> + <!-- test dependencies --> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-junit5</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>io.rest-assured</groupId> + <artifactId>rest-assured</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-integration-testcontainers-support</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.testcontainers</groupId> + <artifactId>cassandra</artifactId> + <scope>test</scope> + </dependency> + + <!-- The following dependencies guarantee that this module is built after them. You can update them by running `mvn process-resources -Pformat -N` from the source tree root directory --> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-cassandraql-deployment</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>*</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> + </dependencies> <profiles> <profile> - <id>full</id> + <id>native</id> <activation> <property> - <name>!quickly</name> + <name>native</name> </property> </activation> + <properties> + <quarkus.package.type>native</quarkus.package.type> + </properties> <build> <plugins> <plugin> - <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-maven-plugin</artifactId> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-failsafe-plugin</artifactId> <executions> <execution> - <id>update-extension-doc-page</id> <goals> - <goal>update-extension-doc-page</goal> + <goal>integration-test</goal> + <goal>verify</goal> </goals> - <phase>process-classes</phase> </execution> </executions> </plugin> @@ -127,4 +135,5 @@ </build> </profile> </profiles> + </project> diff --git a/integration-tests/cassandraql/src/main/java/org/apache/camel/quarkus/component/cassandraql/it/CassandraqlResource.java b/integration-tests/cassandraql/src/main/java/org/apache/camel/quarkus/component/cassandraql/it/CassandraqlResource.java new file mode 100644 index 0000000..88bfd1c --- /dev/null +++ b/integration-tests/cassandraql/src/main/java/org/apache/camel/quarkus/component/cassandraql/it/CassandraqlResource.java @@ -0,0 +1,111 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.cassandraql.it; + +import java.util.List; +import java.util.stream.Collectors; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +import com.datastax.oss.driver.internal.core.cql.DefaultRow; +import org.apache.camel.ConsumerTemplate; +import org.apache.camel.Exchange; +import org.apache.camel.FluentProducerTemplate; + +@Path("/cassandraql") +@ApplicationScoped +public class CassandraqlResource { + public static final String DB_URL_PARAMETER = CassandraqlResource.class.getSimpleName() + "_db_url"; + public static final String KEYSPACE = "test"; + public static final String EMPTY_LIST = "EMPTY"; + + @Inject + FluentProducerTemplate producerTemplate; + + @Inject + ConsumerTemplate consumerTemplate; + + @Path("/insertEmployee") + @POST + @Consumes(MediaType.APPLICATION_JSON) + public void insertEmployee(Employee object) { + producerTemplate.toF(createUrl("INSERT INTO employee(id, name, address) VALUES (?, ?, ?)")) + .withBody(object.getValue()) + .request(); + } + + @Path("/getEmployee") + @POST + @Consumes(MediaType.TEXT_PLAIN) + @Produces(MediaType.TEXT_PLAIN) + public String getEmployee(String id) throws Exception { + final Exchange exchange = consumerTemplate + .receive(createUrl(String.format("SELECT * FROM employee WHERE id = %s", id))); + return convertBodyToString(exchange.getIn().getBody()); + } + + @Path("/getAllEmployees") + @GET + @Produces(MediaType.TEXT_PLAIN) + public String getAllEmployees() throws Exception { + final Exchange exchange = consumerTemplate.receive(createUrl("SELECT id, name, address FROM employee")); + return convertBodyToString(exchange.getIn().getBody()); + } + + @Path("/updateEmployee") + @POST + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.TEXT_PLAIN) + public boolean updateEmployee(Employee employee) throws Exception { + final Exchange exchange = consumerTemplate + .receive(createUrl(String.format("UPDATE employee SET name = '%s', address = '%s' WHERE id = %s", + employee.getName(), employee.getAddress(), employee.getId()))); + return exchange != null; + } + + @Path("/deleteEmployeeById") + @POST + @Consumes(MediaType.TEXT_PLAIN) + public void deleteEmplyeeById(String id) throws Exception { + consumerTemplate.receive(createUrl(String.format("DELETE FROM employee WHERE id = %s", id))); + } + + private String createUrl(String cql) { + String url = System.getProperty(DB_URL_PARAMETER); + return String.format("cql://%s/%s?cql=%s", url, KEYSPACE, cql); + } + + private String convertBodyToString(Object body) { + if (body instanceof List) { + if (((List) body).isEmpty()) { + return EMPTY_LIST; + } else { + return ((List<DefaultRow>) body).stream() + .map(r -> r.getFormattedContents()) + .collect(Collectors.joining(";")); + } + } + return ""; + } +} diff --git a/integration-tests/cassandraql/src/main/java/org/apache/camel/quarkus/component/cassandraql/it/Employee.java b/integration-tests/cassandraql/src/main/java/org/apache/camel/quarkus/component/cassandraql/it/Employee.java new file mode 100644 index 0000000..d4be893 --- /dev/null +++ b/integration-tests/cassandraql/src/main/java/org/apache/camel/quarkus/component/cassandraql/it/Employee.java @@ -0,0 +1,81 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.cassandraql.it; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.List; + +public class Employee implements Serializable, Cloneable { + + private int id; + + private String name; + + private String address; + + public Employee() { + } + + public Employee(int empId, String name, String address) { + this.id = empId; + this.name = name; + this.address = address; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + @Override + public String toString() { + return "Employee{" + + "empId=" + id + + ", name='" + name + '\'' + + ", address='" + address + '\'' + + '}'; + } + + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + List getValue() { + return Arrays.asList(id, name, address); + } + +} diff --git a/extensions-jvm/cassandraql/integration-test/src/test/java/org/apache/camel/quarkus/component/cassandraql/it/CassandraqlTest.java b/integration-tests/cassandraql/src/test/java/org/apache/camel/quarkus/component/cassandraql/it/CassandraqlIT.java similarity index 70% rename from extensions-jvm/cassandraql/integration-test/src/test/java/org/apache/camel/quarkus/component/cassandraql/it/CassandraqlTest.java rename to integration-tests/cassandraql/src/test/java/org/apache/camel/quarkus/component/cassandraql/it/CassandraqlIT.java index 28fafdd..5aa165d 100644 --- a/extensions-jvm/cassandraql/integration-test/src/test/java/org/apache/camel/quarkus/component/cassandraql/it/CassandraqlTest.java +++ b/integration-tests/cassandraql/src/test/java/org/apache/camel/quarkus/component/cassandraql/it/CassandraqlIT.java @@ -16,19 +16,9 @@ */ package org.apache.camel.quarkus.component.cassandraql.it; -import io.quarkus.test.junit.QuarkusTest; -import io.restassured.RestAssured; -import org.junit.jupiter.api.Test; +import io.quarkus.test.junit.NativeImageTest; -@QuarkusTest -class CassandraqlTest { - - @Test - public void loadComponentCql() { - /* A simple autogenerated test */ - RestAssured.get("/cassandraql/load/component/cql") - .then() - .statusCode(200); - } +@NativeImageTest +class CassandraqlIT extends CassandraqlTest { } diff --git a/integration-tests/cassandraql/src/test/java/org/apache/camel/quarkus/component/cassandraql/it/CassandraqlTest.java b/integration-tests/cassandraql/src/test/java/org/apache/camel/quarkus/component/cassandraql/it/CassandraqlTest.java new file mode 100644 index 0000000..39f6a50 --- /dev/null +++ b/integration-tests/cassandraql/src/test/java/org/apache/camel/quarkus/component/cassandraql/it/CassandraqlTest.java @@ -0,0 +1,135 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.cassandraql.it; + +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; +import io.restassured.http.ContentType; +import org.hamcrest.Matcher; +import org.junit.jupiter.api.MethodOrderer; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestMethodOrder; + +import static org.hamcrest.Matchers.allOf; +import static org.hamcrest.Matchers.both; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.not; + +@QuarkusTest +@QuarkusTestResource(CassandraqlTestResource.class) +@TestMethodOrder(MethodOrderer.OrderAnnotation.class) +class CassandraqlTest { + + private Employee sheldon = new Employee(1, "Sheldon", "Alpha Centauri"); + private Employee leonard = new Employee(2, "Leonard", "Earth"); + private Employee irma = new Employee(3, "Irma", "Jupiter"); + + @Test + @Order(1) + public void testInsert() { + insertEmployee(sheldon); + assertEmployee(sheldon.getId(), containsString(sheldon.getName())); + + insertEmployee(leonard); + assertEmployee(leonard.getId(), containsString(leonard.getName())); + + assertEmployee(irma.getId(), equalTo(CassandraqlResource.EMPTY_LIST)); + + insertEmployee(irma); + assertEmployee(irma.getId(), containsString(irma.getName())); + } + + @Test + @Order(2) + public void testUpdate() throws CloneNotSupportedException { + Employee updatedSheldon = (Employee) sheldon.clone(); + updatedSheldon.setAddress("Earth 2.0"); + + assertEmployee(sheldon.getId(), both(containsString(sheldon.getAddress())) + .and(not(containsString(updatedSheldon.getAddress())))); + updateEmployee(updatedSheldon); + assertEmployee(sheldon.getId(), both(containsString(updatedSheldon.getAddress())) + .and(not(containsString(sheldon.getAddress())))); + } + + @Test + @Order(3) + public void testDelete() { + assertAllEmployees(allOf( + containsString(sheldon.getName()), + containsString(leonard.getName()), + containsString(irma.getName()))); + deleteEmployee(sheldon.getId()); + deleteEmployee(leonard.getId()); + assertAllEmployees(allOf( + not(containsString(sheldon.getName())), + not(containsString(leonard.getName())), + containsString(irma.getName()))); + deleteEmployee(irma.getId()); + assertAllEmployees(equalTo(CassandraqlResource.EMPTY_LIST)); + } + + private void assertEmployee(int id, Matcher matcher) { + RestAssured.given() + .contentType(ContentType.TEXT) + .body(id) + .post("/cassandraql/getEmployee") + .then() + .statusCode(200) + .body(matcher); + } + + private void assertAllEmployees(Matcher matcher) { + RestAssured + .get("/cassandraql/getAllEmployees") + .then() + .statusCode(200) + .body(matcher); + } + + private void insertEmployee(Employee employee) { + RestAssured.given() + .contentType(ContentType.JSON) + .body(employee) + .post("/cassandraql/insertEmployee") + .then() + .statusCode(204); + } + + private void updateEmployee(Employee employee) { + RestAssured.given() + .contentType(ContentType.JSON) + .body(employee) + .post("/cassandraql/updateEmployee") + .then() + .statusCode(200) + .body(equalTo(String.valueOf(true))); + } + + private void deleteEmployee(int id) { + RestAssured.given() + .contentType(ContentType.TEXT) + .body(id) + .post("/cassandraql/deleteEmployeeById") + .then() + .statusCode(204); + } + +} diff --git a/integration-tests/cassandraql/src/test/java/org/apache/camel/quarkus/component/cassandraql/it/CassandraqlTestResource.java b/integration-tests/cassandraql/src/test/java/org/apache/camel/quarkus/component/cassandraql/it/CassandraqlTestResource.java new file mode 100644 index 0000000..af2f5ce --- /dev/null +++ b/integration-tests/cassandraql/src/test/java/org/apache/camel/quarkus/component/cassandraql/it/CassandraqlTestResource.java @@ -0,0 +1,86 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.camel.quarkus.component.cassandraql.it; + +import java.util.Map; + +import com.datastax.driver.core.Cluster; +import com.datastax.driver.core.Session; +import org.apache.camel.quarkus.testcontainers.ContainerResourceLifecycleManager; +import org.apache.camel.util.CollectionHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testcontainers.containers.CassandraContainer; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.utility.TestcontainersConfiguration; + +public class CassandraqlTestResource implements ContainerResourceLifecycleManager { + private static final Logger LOGGER = LoggerFactory.getLogger(CassandraqlTestResource.class); + private static final int PORT = 9042; + private static final String DOCKER_IMAGE_NAME = "cassandra:3.11.2"; + + protected GenericContainer container; + + @Override + public Map<String, String> start() { + LOGGER.info(TestcontainersConfiguration.getInstance().toString()); + try { + container = new CassandraContainer(DOCKER_IMAGE_NAME) + .withExposedPorts(PORT); + + container.start(); + + initDB((CassandraContainer) container); + + return CollectionHelper.mapOf( + CassandraqlResource.DB_URL_PARAMETER, + container.getContainerIpAddress() + ":" + container.getMappedPort(PORT)); + + } catch (Exception e) { + LOGGER.error("Container does not start", e); + throw new RuntimeException(e); + } + } + + private void initDB(CassandraContainer cc) { + Cluster cluster = cc.getCluster(); + + try (Session session = cluster.connect()) { + + session.execute("CREATE KEYSPACE IF NOT EXISTS " + CassandraqlResource.KEYSPACE + " WITH replication = \n" + + "{'class':'SimpleStrategy','replication_factor':'1'};"); + + session.execute("CREATE TABLE " + CassandraqlResource.KEYSPACE + ".employee(\n" + + " id int PRIMARY KEY,\n" + + " name text,\n" + + " address text\n" + + " );"); + } + } + + @Override + public void stop() { + try { + if (container != null) { + container.stop(); + } + } catch (Exception e) { + // ignored + } + } +} diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index be1b53c..e3fa132 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -79,6 +79,7 @@ <module>box</module> <module>braintree</module> <module>caffeine</module> + <module>cassandraql</module> <module>compression</module> <module>consul</module> <module>couchdb</module> diff --git a/pom.xml b/pom.xml index 8e01a8b..2179083 100644 --- a/pom.xml +++ b/pom.xml @@ -58,6 +58,7 @@ <camel.docs.components.xref>${camel.major.minor}.x@components</camel.docs.components.xref><!-- the version in Camel's docs/components/antora.yml --> <camel.docs.branch>camel-${camel.major.minor}.x</camel.docs.branch><!-- The stable branch on which our Antora docs depends --> + <cassandra-quarkus.version>1.0.0</cassandra-quarkus.version> <commons-beanutils.version>${commons-beanutils-version}</commons-beanutils.version><!-- keep in sync with Camel --> <commons-cli.version>1.4</commons-cli.version><!-- keep in sync with Quarkus, via quarkus-bootstrap-core --> <commons-collections.version>3.2.2</commons-collections.version><!-- used by hbase, should be pretty stable as commons-collections are not developed actively anymore --> diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml index 5ae6e99..04536cd 100644 --- a/poms/bom/pom.xml +++ b/poms/bom/pom.xml @@ -5530,6 +5530,16 @@ <version>${azure-storage-queue-java-sdk12-version}</version> </dependency> <dependency> + <groupId>com.datastax.oss.quarkus</groupId> + <artifactId>cassandra-quarkus-client</artifactId> + <version>${cassandra-quarkus.version}</version> + </dependency> + <dependency> + <groupId>com.datastax.oss.quarkus</groupId> + <artifactId>cassandra-quarkus-client-deployment</artifactId> + <version>${cassandra-quarkus.version}</version> + </dependency> + <dependency> <groupId>com.fasterxml.woodstox</groupId> <artifactId>woodstox-core</artifactId> <version>${woodstox-core.version}</version> diff --git a/tooling/scripts/test-categories.yaml b/tooling/scripts/test-categories.yaml index 7d9ef9a..261d5da 100644 --- a/tooling/scripts/test-categories.yaml +++ b/tooling/scripts/test-categories.yaml @@ -54,6 +54,7 @@ core-main-validation: - validator database: - arangodb + - cassandraql - couchdb - debezium - influxdb