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
commit 992a671788b7858de8ea917f9941cf373b3c5d79 Author: James Netherton <jamesnether...@gmail.com> AuthorDate: Fri Dec 4 12:08:28 2020 +0000 BigQuery native support Fixes #2014 --- .../reference/extensions/google-bigquery.adoc | 19 +++- .../reference/components/google-bigquery-sql.adoc | 6 +- .../reference/components/google-bigquery.adoc | 6 +- .../google-bigquery/integration-test/pom.xml | 66 ------------- .../google/bigquery/it/GoogleBigqueryResource.java | 64 ------------- extensions-jvm/pom.xml | 1 - .../google-bigquery/deployment/pom.xml | 4 + .../deployment/GoogleBigqueryProcessor.java | 26 +++-- .../google-bigquery/pom.xml | 1 - .../google-bigquery/runtime/pom.xml | 6 +- .../runtime/src/main/doc/usage.adoc | 7 ++ .../GoogleBigQueryConnectionFactoryProducer.java | 38 ++++---- .../main/resources/META-INF/quarkus-extension.yaml | 3 +- extensions/pom.xml | 1 + integration-tests/google-bigquery/README.adoc | 16 ++++ .../{jsonb => google-bigquery}/pom.xml | 64 ++----------- .../google/bigquery/it/GoogleBigqueryResource.java | 105 +++++++++++++++++++++ .../src/main/resources/application.properties | 19 ++++ .../google/bigquery/it/GoogleBigqueryIT.java | 26 +---- .../google/bigquery/it/GoogleBigqueryTest.java | 75 +++++++++++++++ integration-tests/jsonb/pom.xml | 13 +++ integration-tests/pom.xml | 1 + pom.xml | 2 +- poms/bom/pom.xml | 20 ++++ tooling/scripts/test-categories.yaml | 1 + 25 files changed, 333 insertions(+), 257 deletions(-) diff --git a/docs/modules/ROOT/pages/reference/extensions/google-bigquery.adoc b/docs/modules/ROOT/pages/reference/extensions/google-bigquery.adoc index ef9f559..1814f64 100644 --- a/docs/modules/ROOT/pages/reference/extensions/google-bigquery.adoc +++ b/docs/modules/ROOT/pages/reference/extensions/google-bigquery.adoc @@ -3,15 +3,15 @@ = Google BigQuery :page-aliases: extensions/google-bigquery.adoc :cq-artifact-id: camel-quarkus-google-bigquery -:cq-native-supported: false -:cq-status: Preview +:cq-native-supported: true +:cq-status: Stable :cq-description: Access Google Cloud BigQuery service using SQL queries or Google Client Services API :cq-deprecated: false :cq-jvm-since: 1.0.0 -:cq-native-since: 1.0.0 +:cq-native-since: 1.5.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.5.0## Access Google Cloud BigQuery service using SQL queries or Google Client Services API @@ -33,3 +33,14 @@ Please refer to the above links for usage and configuration details. ---- Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications. + +== Usage + +This extension leverages the Quarkiverse Google Cloud Services extension. The https://github.com/quarkiverse/quarkiverse-google-cloud-services[documentation] describes +how to configure authentication for Google cloud services. + +For convenience, a `GoogleBigQueryConnectionFactory` for use by the `google-bigquery` & `google-bigquery-sql` component is automatically configured. + +If you want to read SQL scripts from the classpath with `google-bigquery-sql` in native mode, then you will need to ensure that they are added to the native image via +the `quarkus.camel.native.resources.include-patterns` configuration property. + diff --git a/docs/modules/ROOT/partials/reference/components/google-bigquery-sql.adoc b/docs/modules/ROOT/partials/reference/components/google-bigquery-sql.adoc index c20fa09..8330f83 100644 --- a/docs/modules/ROOT/partials/reference/components/google-bigquery-sql.adoc +++ b/docs/modules/ROOT/partials/reference/components/google-bigquery-sql.adoc @@ -2,11 +2,11 @@ // This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page :cq-artifact-id: camel-quarkus-google-bigquery :cq-artifact-id-base: google-bigquery -: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: 1.0.0 +:cq-native-since: 1.5.0 :cq-camel-part-name: google-bigquery-sql :cq-camel-part-title: Google BigQuery Standard SQL :cq-camel-part-description: Access Google Cloud BigQuery service using SQL queries. diff --git a/docs/modules/ROOT/partials/reference/components/google-bigquery.adoc b/docs/modules/ROOT/partials/reference/components/google-bigquery.adoc index 7692d15..fd0ebca 100644 --- a/docs/modules/ROOT/partials/reference/components/google-bigquery.adoc +++ b/docs/modules/ROOT/partials/reference/components/google-bigquery.adoc @@ -2,11 +2,11 @@ // This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page :cq-artifact-id: camel-quarkus-google-bigquery :cq-artifact-id-base: google-bigquery -: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: 1.0.0 +:cq-native-since: 1.5.0 :cq-camel-part-name: google-bigquery :cq-camel-part-title: Google BigQuery :cq-camel-part-description: Google BigQuery data warehouse for analytics. diff --git a/extensions-jvm/google-bigquery/integration-test/pom.xml b/extensions-jvm/google-bigquery/integration-test/pom.xml deleted file mode 100644 index d3e97bc..0000000 --- a/extensions-jvm/google-bigquery/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.5.0-SNAPSHOT</version> - <relativePath>../../../poms/build-parent-it/pom.xml</relativePath> - </parent> - - <artifactId>camel-quarkus-google-bigquery-integration-test</artifactId> - <name>Camel Quarkus :: Google BigQuery :: Integration Test</name> - <description>Integration tests for Camel Quarkus Google BigQuery extension</description> - - <properties> - <!-- mvnd, a.k.a. Maven Daemon: https://github.com/mvndaemon/mvnd --> - <!-- The following rule tells mvnd to build the listed deployment modules before this module. --> - <!-- This is important because mvnd builds modules in parallel by default. The deployment modules are not --> - <!-- explicit dependencies of this module in the Maven sense, although they are required by the Quarkus Maven plugin. --> - <!-- Please update the rule whenever you change the dependencies of this module by running --> - <!-- mvn process-resources -Pformat from the root directory --> - <mvnd.builder.rule>camel-quarkus-google-bigquery-deployment</mvnd.builder.rule> - </properties> - - <dependencies> - <dependency> - <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-google-bigquery</artifactId> - </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/google-bigquery/integration-test/src/main/java/org/apache/camel/quarkus/component/google/bigquery/it/GoogleBigqueryResource.java b/extensions-jvm/google-bigquery/integration-test/src/main/java/org/apache/camel/quarkus/component/google/bigquery/it/GoogleBigqueryResource.java deleted file mode 100644 index 8782cfa..0000000 --- a/extensions-jvm/google-bigquery/integration-test/src/main/java/org/apache/camel/quarkus/component/google/bigquery/it/GoogleBigqueryResource.java +++ /dev/null @@ -1,64 +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.google.bigquery.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("/google-bigquery") -@ApplicationScoped -public class GoogleBigqueryResource { - - private static final Logger LOG = Logger.getLogger(GoogleBigqueryResource.class); - - private static final String COMPONENT_GOOGLE_BIGQUERY = "google-bigquery"; - private static final String COMPONENT_GOOGLE_BIGQUERY_SQL = "google-bigquery-sql"; - @Inject - CamelContext context; - - @Path("/load/component/google-bigquery") - @GET - @Produces(MediaType.TEXT_PLAIN) - public Response loadComponentGoogleBigquery() throws Exception { - /* This is an autogenerated test */ - if (context.getComponent(COMPONENT_GOOGLE_BIGQUERY) != null) { - return Response.ok().build(); - } - LOG.warnf("Could not load [%s] from the Camel context", COMPONENT_GOOGLE_BIGQUERY); - return Response.status(500, COMPONENT_GOOGLE_BIGQUERY + " could not be loaded from the Camel context").build(); - } - - @Path("/load/component/google-bigquery-sql") - @GET - @Produces(MediaType.TEXT_PLAIN) - public Response loadComponentGoogleBigquerySql() throws Exception { - /* This is an autogenerated test */ - if (context.getComponent(COMPONENT_GOOGLE_BIGQUERY_SQL) != null) { - return Response.ok().build(); - } - LOG.warnf("Could not load [%s] from the Camel context", COMPONENT_GOOGLE_BIGQUERY_SQL); - return Response.status(500, COMPONENT_GOOGLE_BIGQUERY_SQL + " could not be loaded from the Camel context").build(); - } -} diff --git a/extensions-jvm/pom.xml b/extensions-jvm/pom.xml index 24750af..b792206 100644 --- a/extensions-jvm/pom.xml +++ b/extensions-jvm/pom.xml @@ -71,7 +71,6 @@ <module>flink</module> <module>freemarker</module> <module>ganglia</module> - <module>google-bigquery</module> <module>groovy</module> <module>guava-eventbus</module> <module>hazelcast</module> diff --git a/extensions-jvm/google-bigquery/deployment/pom.xml b/extensions/google-bigquery/deployment/pom.xml similarity index 93% rename from extensions-jvm/google-bigquery/deployment/pom.xml rename to extensions/google-bigquery/deployment/pom.xml index c847479..a1b3b8e 100644 --- a/extensions-jvm/google-bigquery/deployment/pom.xml +++ b/extensions/google-bigquery/deployment/pom.xml @@ -31,6 +31,10 @@ <dependencies> <dependency> + <groupId>io.quarkiverse.googlecloudservices</groupId> + <artifactId>quarkus-google-cloud-bigquery-deployment</artifactId> + </dependency> + <dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-core-deployment</artifactId> </dependency> diff --git a/extensions-jvm/google-bigquery/deployment/src/main/java/org/apache/camel/quarkus/component/google/bigquery/deployment/GoogleBigqueryProcessor.java b/extensions/google-bigquery/deployment/src/main/java/org/apache/camel/quarkus/component/google/bigquery/deployment/GoogleBigqueryProcessor.java similarity index 62% rename from extensions-jvm/google-bigquery/deployment/src/main/java/org/apache/camel/quarkus/component/google/bigquery/deployment/GoogleBigqueryProcessor.java rename to extensions/google-bigquery/deployment/src/main/java/org/apache/camel/quarkus/component/google/bigquery/deployment/GoogleBigqueryProcessor.java index dda4b60..98bfdb5 100644 --- a/extensions-jvm/google-bigquery/deployment/src/main/java/org/apache/camel/quarkus/component/google/bigquery/deployment/GoogleBigqueryProcessor.java +++ b/extensions/google-bigquery/deployment/src/main/java/org/apache/camel/quarkus/component/google/bigquery/deployment/GoogleBigqueryProcessor.java @@ -16,17 +16,14 @@ */ package org.apache.camel.quarkus.component.google.bigquery.deployment; +import io.quarkus.arc.deployment.AdditionalBeanBuildItem; +import io.quarkus.arc.deployment.UnremovableBeanBuildItem; 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 org.apache.camel.component.google.bigquery.GoogleBigQueryConnectionFactory; +import org.apache.camel.quarkus.component.google.bigquery.GoogleBigQueryConnectionFactoryProducer; class GoogleBigqueryProcessor { - private static final Logger LOG = Logger.getLogger(GoogleBigqueryProcessor.class); - private static final String FEATURE = "camel-google-bigquery"; @BuildStep @@ -34,14 +31,13 @@ class GoogleBigqueryProcessor { 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 + UnremovableBeanBuildItem unremovableBeans() { + return UnremovableBeanBuildItem.beanTypes(GoogleBigQueryConnectionFactory.class); } + @BuildStep + public AdditionalBeanBuildItem connectionFactoryProducerBean() { + return new AdditionalBeanBuildItem(GoogleBigQueryConnectionFactoryProducer.class); + } } diff --git a/extensions-jvm/google-bigquery/pom.xml b/extensions/google-bigquery/pom.xml similarity index 97% rename from extensions-jvm/google-bigquery/pom.xml rename to extensions/google-bigquery/pom.xml index 43738d1..f5f9a80 100644 --- a/extensions-jvm/google-bigquery/pom.xml +++ b/extensions/google-bigquery/pom.xml @@ -33,6 +33,5 @@ <modules> <module>deployment</module> <module>runtime</module> - <module>integration-test</module> </modules> </project> diff --git a/extensions-jvm/google-bigquery/runtime/pom.xml b/extensions/google-bigquery/runtime/pom.xml similarity index 94% rename from extensions-jvm/google-bigquery/runtime/pom.xml rename to extensions/google-bigquery/runtime/pom.xml index 242eae4..bf5989e 100644 --- a/extensions-jvm/google-bigquery/runtime/pom.xml +++ b/extensions/google-bigquery/runtime/pom.xml @@ -32,7 +32,7 @@ <properties> <camel.quarkus.jvmSince>1.0.0</camel.quarkus.jvmSince> - <camel.quarkus.nativeSince>1.0.0</camel.quarkus.nativeSince> + <camel.quarkus.nativeSince>1.5.0</camel.quarkus.nativeSince> </properties> <dependencyManagement> @@ -49,6 +49,10 @@ <dependencies> <dependency> + <groupId>io.quarkiverse.googlecloudservices</groupId> + <artifactId>quarkus-google-cloud-bigquery</artifactId> + </dependency> + <dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-core</artifactId> </dependency> diff --git a/extensions/google-bigquery/runtime/src/main/doc/usage.adoc b/extensions/google-bigquery/runtime/src/main/doc/usage.adoc new file mode 100644 index 0000000..7bced01 --- /dev/null +++ b/extensions/google-bigquery/runtime/src/main/doc/usage.adoc @@ -0,0 +1,7 @@ +This extension leverages the Quarkiverse Google Cloud Services extension. The https://github.com/quarkiverse/quarkiverse-google-cloud-services[documentation] describes +how to configure authentication for Google cloud services. + +For convenience, a `GoogleBigQueryConnectionFactory` for use by the `google-bigquery` & `google-bigquery-sql` component is automatically configured. + +If you want to read SQL scripts from the classpath with `google-bigquery-sql` in native mode, then you will need to ensure that they are added to the native image via +the `quarkus.camel.native.resources.include-patterns` configuration property. diff --git a/extensions-jvm/google-bigquery/integration-test/src/test/java/org/apache/camel/quarkus/component/google/bigquery/it/GoogleBigqueryTest.java b/extensions/google-bigquery/runtime/src/main/java/org/apache/camel/quarkus/component/google/bigquery/GoogleBigQueryConnectionFactoryProducer.java similarity index 54% copy from extensions-jvm/google-bigquery/integration-test/src/test/java/org/apache/camel/quarkus/component/google/bigquery/it/GoogleBigqueryTest.java copy to extensions/google-bigquery/runtime/src/main/java/org/apache/camel/quarkus/component/google/bigquery/GoogleBigQueryConnectionFactoryProducer.java index ecbcd3b..887b9e6 100644 --- a/extensions-jvm/google-bigquery/integration-test/src/test/java/org/apache/camel/quarkus/component/google/bigquery/it/GoogleBigqueryTest.java +++ b/extensions/google-bigquery/runtime/src/main/java/org/apache/camel/quarkus/component/google/bigquery/GoogleBigQueryConnectionFactoryProducer.java @@ -14,29 +14,27 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.quarkus.component.google.bigquery.it; +package org.apache.camel.quarkus.component.google.bigquery; -import io.quarkus.test.junit.QuarkusTest; -import io.restassured.RestAssured; -import org.junit.jupiter.api.Test; +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.inject.Default; +import javax.enterprise.inject.Produces; +import javax.inject.Inject; +import javax.inject.Singleton; -@QuarkusTest -class GoogleBigqueryTest { +import com.google.cloud.bigquery.BigQuery; +import org.apache.camel.component.google.bigquery.GoogleBigQueryConnectionFactory; - @Test - public void loadComponentGoogleBigquery() { - /* A simple autogenerated test */ - RestAssured.get("/google-bigquery/load/component/google-bigquery") - .then() - .statusCode(200); - } +@ApplicationScoped +public class GoogleBigQueryConnectionFactoryProducer { - @Test - public void loadComponentGoogleBigquerySql() { - /* A simple autogenerated test */ - RestAssured.get("/google-bigquery/load/component/google-bigquery-sql") - .then() - .statusCode(200); - } + @Inject + BigQuery bigQuery; + @Produces + @Default + @Singleton + public GoogleBigQueryConnectionFactory googleBigQueryConnectionFactory() { + return new GoogleBigQueryConnectionFactory(bigQuery); + } } diff --git a/extensions-jvm/google-bigquery/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/google-bigquery/runtime/src/main/resources/META-INF/quarkus-extension.yaml similarity index 97% rename from extensions-jvm/google-bigquery/runtime/src/main/resources/META-INF/quarkus-extension.yaml rename to extensions/google-bigquery/runtime/src/main/resources/META-INF/quarkus-extension.yaml index 0497407..d8b5e56 100644 --- a/extensions-jvm/google-bigquery/runtime/src/main/resources/META-INF/quarkus-extension.yaml +++ b/extensions/google-bigquery/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -24,9 +24,8 @@ name: "Camel Google BigQuery" description: "Access Google Cloud BigQuery service using SQL queries or Google Client Services API" metadata: - unlisted: true guide: "https://camel.apache.org/camel-quarkus/latest/reference/extensions/google-bigquery.html" categories: - "integration" status: - - "preview" + - "stable" diff --git a/extensions/pom.xml b/extensions/pom.xml index 9beeb7c..d7d5aea 100644 --- a/extensions/pom.xml +++ b/extensions/pom.xml @@ -109,6 +109,7 @@ <module>geocoder</module> <module>git</module> <module>github</module> + <module>google-bigquery</module> <module>google-calendar</module> <module>google-drive</module> <module>google-mail</module> diff --git a/integration-tests/google-bigquery/README.adoc b/integration-tests/google-bigquery/README.adoc new file mode 100644 index 0000000..d210160 --- /dev/null +++ b/integration-tests/google-bigquery/README.adoc @@ -0,0 +1,16 @@ +== Camel Quarkus Google BigQuery Integration Tests + +To run Camel Google BigQuery integration tests, you need a valid https://cloud.google.com/[Google Cloud Platform] (GCP) account. Note that the GCP free tier & sandbox +mode does not provide the required capabilities (streaming inserts & queries) that enable the tests to run successfully. + +The simplest means of setting up authentication is via a https://cloud.google.com/docs/authentication/getting-started[service account]. Use the GCP UI to export +a JSON representation of your credentials. + +You should now set the following environment variable: + +[source,shell] +---- +export GOOGLE_APPLICATION_CREDENTIALS=/path/to/credentials.json +---- + +You should also modify `application.properties` so that `quarkus.google.cloud.project-id` is correct for your GCP project. diff --git a/integration-tests/jsonb/pom.xml b/integration-tests/google-bigquery/pom.xml similarity index 60% copy from integration-tests/jsonb/pom.xml copy to integration-tests/google-bigquery/pom.xml index 1623b03..6cb792f 100644 --- a/integration-tests/jsonb/pom.xml +++ b/integration-tests/google-bigquery/pom.xml @@ -17,49 +17,34 @@ 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-integration-tests</artifactId> <version>1.5.0-SNAPSHOT</version> - <relativePath>../pom.xml</relativePath> </parent> - <artifactId>camel-quarkus-integration-test-jsonb</artifactId> - <name>Camel Quarkus :: Integration Tests :: JSON JSON-B</name> - <description>Integration tests for Camel Quarkus JSON JSON-B extension</description> - - <dependencyManagement> - <dependencies> - <dependency> - <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-bom-test</artifactId> - <version>${project.version}</version> - <type>pom</type> - <scope>import</scope> - </dependency> - </dependencies> - </dependencyManagement> + <artifactId>camel-quarkus-integration-test-google-bigquery</artifactId> + <name>Camel Quarkus :: Integration Tests :: Google BigQuery</name> + <description>Integration tests for Camel Quarkus Google BigQuery extension</description> <dependencies> <dependency> <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-jsonb</artifactId> + <artifactId>camel-quarkus-google-bigquery</artifactId> </dependency> <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-resteasy</artifactId> </dependency> <dependency> - <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-direct</artifactId> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-jsonb</artifactId> </dependency> <dependency> <groupId>io.quarkus</groupId> - <artifactId>quarkus-resteasy-jackson</artifactId> + <artifactId>quarkus-resteasy-jsonb</artifactId> </dependency> <!-- test dependencies --> @@ -77,22 +62,7 @@ <!-- 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-direct-deployment</artifactId> - <version>${project.version}</version> - <type>pom</type> - <scope>test</scope> - <exclusions> - <exclusion> - <groupId>*</groupId> - <artifactId>*</artifactId> - </exclusion> - </exclusions> - </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-jsonb-deployment</artifactId> + <artifactId>camel-quarkus-google-bigquery-deployment</artifactId> <version>${project.version}</version> <type>pom</type> <scope>test</scope> @@ -105,22 +75,6 @@ </dependency> </dependencies> - <build> - <plugins> - <plugin> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-maven-plugin</artifactId> - <executions> - <execution> - <goals> - <goal>build</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - <profiles> <profile> <id>native</id> diff --git a/integration-tests/google-bigquery/src/main/java/org/apache/camel/quarkus/component/google/bigquery/it/GoogleBigqueryResource.java b/integration-tests/google-bigquery/src/main/java/org/apache/camel/quarkus/component/google/bigquery/it/GoogleBigqueryResource.java new file mode 100644 index 0000000..8bf7af2 --- /dev/null +++ b/integration-tests/google-bigquery/src/main/java/org/apache/camel/quarkus/component/google/bigquery/it/GoogleBigqueryResource.java @@ -0,0 +1,105 @@ +/* + * 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.google.bigquery.it; + +import java.io.IOException; +import java.net.URI; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.util.Map; + +import javax.inject.Inject; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +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 javax.ws.rs.core.Response; + +import com.google.cloud.bigquery.BigQuery; +import org.apache.camel.ProducerTemplate; + +@Path("/google-bigquery") +public class GoogleBigqueryResource { + + public static final String DATASET_ID = "cq_testing"; + public static final String TABLE_NAME = "camel_quarkus_basic"; + + @Inject + BigQuery bigQuery; + + @Inject + ProducerTemplate producerTemplate; + + String tableId = DATASET_ID + "." + TABLE_NAME; + + @Path("/table") + @POST + public Response createTable() { + String sql = "CREATE TABLE `" + tableId + "` (id NUMERIC, col1 STRING, col2 STRING)"; + producerTemplate.requestBody("google-bigquery-sql:" + getProjectId() + ":" + sql, null, + Long.class); + return Response.created(URI.create("https://camel.apache.org")).build(); + } + + @POST + @Consumes(MediaType.APPLICATION_JSON) + public Response insertRow(Map<String, String> tableData) { + producerTemplate.requestBody("google-bigquery:" + getProjectId() + ":" + DATASET_ID + ":" + TABLE_NAME, tableData); + return Response.created(URI.create("https://camel.apache.org")).build(); + } + + @GET + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public Response getRow() { + String sql = "SELECT * FROM `" + tableId + "`"; + Long rowCount = producerTemplate.requestBody("google-bigquery-sql:" + getProjectId() + ":" + sql, null, Long.class); + return Response.ok(rowCount).build(); + } + + @Path("/file") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public Response getRowUsingQueryResource() throws IOException { + String sql = "SELECT * FROM `" + tableId + "`"; + java.nio.file.Path path = Files.createTempDirectory("bigquery"); + java.nio.file.Path sqlFile = Files.createTempFile(path, "bigquery", ".sql"); + Files.write(sqlFile, sql.getBytes(StandardCharsets.UTF_8)); + + Long rowCount = producerTemplate.requestBody( + "google-bigquery-sql:" + getProjectId() + ":file:" + sqlFile.toAbsolutePath().toString(), + null, Long.class); + return Response.ok(rowCount).build(); + } + + @Path("/table") + @DELETE + @Produces(MediaType.TEXT_PLAIN) + public Response dropTable() { + String sql = "DROP TABLE `" + tableId + "`"; + producerTemplate.requestBody("google-bigquery-sql:" + getProjectId() + ":" + sql, null, Long.class); + return Response.ok().build(); + } + + private String getProjectId() { + return bigQuery.getOptions().getProjectId(); + } +} diff --git a/integration-tests/google-bigquery/src/main/resources/application.properties b/integration-tests/google-bigquery/src/main/resources/application.properties new file mode 100644 index 0000000..dae8729 --- /dev/null +++ b/integration-tests/google-bigquery/src/main/resources/application.properties @@ -0,0 +1,19 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# Set this to the project id for your GCP BigQuery project +quarkus.google.cloud.project-id=your-gcp-project-id-here diff --git a/extensions-jvm/google-bigquery/integration-test/src/test/java/org/apache/camel/quarkus/component/google/bigquery/it/GoogleBigqueryTest.java b/integration-tests/google-bigquery/src/test/java/org/apache/camel/quarkus/component/google/bigquery/it/GoogleBigqueryIT.java similarity index 57% rename from extensions-jvm/google-bigquery/integration-test/src/test/java/org/apache/camel/quarkus/component/google/bigquery/it/GoogleBigqueryTest.java rename to integration-tests/google-bigquery/src/test/java/org/apache/camel/quarkus/component/google/bigquery/it/GoogleBigqueryIT.java index ecbcd3b..2ebc51b 100644 --- a/extensions-jvm/google-bigquery/integration-test/src/test/java/org/apache/camel/quarkus/component/google/bigquery/it/GoogleBigqueryTest.java +++ b/integration-tests/google-bigquery/src/test/java/org/apache/camel/quarkus/component/google/bigquery/it/GoogleBigqueryIT.java @@ -16,27 +16,11 @@ */ package org.apache.camel.quarkus.component.google.bigquery.it; -import io.quarkus.test.junit.QuarkusTest; -import io.restassured.RestAssured; -import org.junit.jupiter.api.Test; +import io.quarkus.test.junit.NativeImageTest; +import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; -@QuarkusTest -class GoogleBigqueryTest { - - @Test - public void loadComponentGoogleBigquery() { - /* A simple autogenerated test */ - RestAssured.get("/google-bigquery/load/component/google-bigquery") - .then() - .statusCode(200); - } - - @Test - public void loadComponentGoogleBigquerySql() { - /* A simple autogenerated test */ - RestAssured.get("/google-bigquery/load/component/google-bigquery-sql") - .then() - .statusCode(200); - } +@NativeImageTest +@EnabledIfEnvironmentVariable(named = "GOOGLE_APPLICATION_CREDENTIALS", matches = ".+") +class GoogleBigqueryIT extends GoogleBigqueryTest { } diff --git a/integration-tests/google-bigquery/src/test/java/org/apache/camel/quarkus/component/google/bigquery/it/GoogleBigqueryTest.java b/integration-tests/google-bigquery/src/test/java/org/apache/camel/quarkus/component/google/bigquery/it/GoogleBigqueryTest.java new file mode 100644 index 0000000..2a71fc5 --- /dev/null +++ b/integration-tests/google-bigquery/src/test/java/org/apache/camel/quarkus/component/google/bigquery/it/GoogleBigqueryTest.java @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.google.bigquery.it; + +import java.util.HashMap; +import java.util.Map; + +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; +import io.restassured.http.ContentType; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; + +import static org.hamcrest.Matchers.is; + +@QuarkusTest +@EnabledIfEnvironmentVariable(named = "GOOGLE_APPLICATION_CREDENTIALS", matches = ".+") +class GoogleBigqueryTest { + + @Test + public void googleBigQueryCrudOperations() { + try { + // Create table + RestAssured.post("/google-bigquery/table") + .then() + .statusCode(201); + + // Insert rows + for (int i = 1; i <= 3; i++) { + Map<String, String> object = new HashMap<>(); + object.put("id", String.valueOf(i)); + object.put("col1", String.valueOf(i + 1)); + object.put("col2", String.valueOf(i + 2)); + + RestAssured.given() + .contentType(ContentType.JSON) + .body(object) + .post("/google-bigquery") + .then() + .statusCode(201); + } + + // Verify rows exits + RestAssured.get("/google-bigquery") + .then() + .statusCode(200) + .body(is("3")); + + // Verify rows exits using a query resource from the filesystem + RestAssured.get("/google-bigquery/file") + .then() + .statusCode(200) + .body(is("3")); + } finally { + // Delete table + RestAssured.delete("/google-bigquery/table") + .then() + .statusCode(200); + } + } +} diff --git a/integration-tests/jsonb/pom.xml b/integration-tests/jsonb/pom.xml index 1623b03..1ebdb77 100644 --- a/integration-tests/jsonb/pom.xml +++ b/integration-tests/jsonb/pom.xml @@ -103,6 +103,19 @@ </exclusion> </exclusions> </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-jsonb-deployment</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>*</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> </dependencies> <build> diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index a37f22f..aa71a23 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -99,6 +99,7 @@ <module>git</module> <module>github</module> <module>google</module> + <module>google-bigquery</module> <module>google-pubsub</module> <module>graphql</module> <module>grok</module> diff --git a/pom.xml b/pom.xml index a67ae8e..7960186 100644 --- a/pom.xml +++ b/pom.xml @@ -86,7 +86,7 @@ <okio.version>${squareup-okio-version}</okio.version><!-- keep in sync with okhttp --> <optaplanner.version>7.46.0.Final</optaplanner.version> <quarkus.version>1.10.2.Final</quarkus.version> - <quarkus-google-cloud.version>0.2.0</quarkus-google-cloud.version> + <quarkus-google-cloud.version>0.3.0</quarkus-google-cloud.version> <quarkus-qpid-jms.version>0.21.0</quarkus-qpid-jms.version> <protobuf.version>${protobuf-version}</protobuf.version> <retrofit.version>2.5.0</retrofit.version> diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml index 3f93063..af065af 100644 --- a/poms/bom/pom.xml +++ b/poms/bom/pom.xml @@ -886,6 +886,16 @@ <groupId>org.apache.camel</groupId> <artifactId>camel-google-bigquery</artifactId> <version>${camel.version}</version> + <exclusions> + <exclusion> + <groupId>com.google.cloud</groupId> + <artifactId>google-cloud-bigquery</artifactId> + </exclusion> + <exclusion> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + </exclusion> + </exclusions> </dependency> <dependency> <groupId>org.apache.camel</groupId> @@ -5529,6 +5539,16 @@ </dependency> <dependency> <groupId>io.quarkiverse.googlecloudservices</groupId> + <artifactId>quarkus-google-cloud-bigquery</artifactId> + <version>${quarkus-google-cloud.version}</version> + </dependency> + <dependency> + <groupId>io.quarkiverse.googlecloudservices</groupId> + <artifactId>quarkus-google-cloud-bigquery-deployment</artifactId> + <version>${quarkus-google-cloud.version}</version> + </dependency> + <dependency> + <groupId>io.quarkiverse.googlecloudservices</groupId> <artifactId>quarkus-google-cloud-pubsub</artifactId> <version>${quarkus-google-cloud.version}</version> </dependency> diff --git a/tooling/scripts/test-categories.yaml b/tooling/scripts/test-categories.yaml index ad5c6fa..5bfee14 100644 --- a/tooling/scripts/test-categories.yaml +++ b/tooling/scripts/test-categories.yaml @@ -30,6 +30,7 @@ cloud: - azure - consul - elasticsearch-rest + - google-bigquery - google-pubsub - grpc - protobuf