This is an automated email from the ASF dual-hosted git repository. jamesnetherton pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/master by this push: new ab44739 Add MongoDB GridFS native support ab44739 is described below commit ab447399c172e2f77ef20c79b3dcabce21640b13 Author: James Netherton <jamesnether...@gmail.com> AuthorDate: Wed May 20 06:58:49 2020 +0100 Add MongoDB GridFS native support Fixes #932 --- .../pages/list-of-camel-quarkus-extensions.adoc | 4 +- .../gridfs/deployment/MongodbGridfsProcessor.java | 47 ------------ .../mongodb-gridfs/integration-test/pom.xml | 81 -------------------- .../mongodb/gridfs/it/MongodbGridfsResource.java | 51 ------------- extensions-jvm/pom.xml | 1 - .../mongodb/deployment/pom.xml | 16 ++-- .../deployment/SupportMongoDBProcessor.java | 9 +-- .../mongodb}/pom.xml | 9 +-- .../mongodb}/runtime/pom.xml | 14 ++-- .../main/resources/META-INF/quarkus-extension.yaml | 12 +-- extensions-support/pom.xml | 1 + .../mongodb-gridfs/deployment/pom.xml | 4 + .../gridfs/deployment/MongodbGridfsProcessor.java | 21 ++--- .../mongodb-gridfs/pom.xml | 1 - .../mongodb-gridfs/runtime/pom.xml | 4 + .../main/resources/META-INF/quarkus-extension.yaml | 2 - extensions/mongodb/deployment/pom.xml | 4 +- .../mongodb/deployment/MongoDbProcessor.java | 24 ------ extensions/mongodb/runtime/pom.xml | 8 +- extensions/pom.xml | 1 + integration-tests/mongodb/pom.xml | 6 +- .../mongodb/it/MongodbGridfsResource.java | 89 ++++++++++++++++++++++ .../component/mongodb/it/MongodbGridfsIT.java | 19 +---- .../component/mongodb/it/MongodbGridfsTest.java | 68 +++++++++++++++++ poms/bom-deployment/pom.xml | 5 ++ poms/bom/pom.xml | 5 ++ 26 files changed, 229 insertions(+), 277 deletions(-) diff --git a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc index caed8ff..354823a 100644 --- a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc +++ b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc @@ -430,8 +430,8 @@ Level | Since | Description Stable | 1.0.0-M1 | Perform operations on MongoDB documents and collections. | link:https://camel.apache.org/components/latest/mongodb-gridfs-component.html[MongoDB GridFS] (camel-quarkus-mongodb-gridfs) + -`mongodb-gridfs:connectionBean` | JVM + - Preview | 1.0.0-M6 | Interact with MongoDB GridFS. +`mongodb-gridfs:connectionBean` | Native + + Stable | 1.0.0-M6 | Interact with MongoDB GridFS. | xref:extensions/mustache.adoc[Mustache] (camel-quarkus-mustache) + `mustache:resourceUri` | Native + diff --git a/extensions-jvm/mongodb-gridfs/deployment/src/main/java/org/apache/camel/quarkus/component/mongodb/gridfs/deployment/MongodbGridfsProcessor.java b/extensions-jvm/mongodb-gridfs/deployment/src/main/java/org/apache/camel/quarkus/component/mongodb/gridfs/deployment/MongodbGridfsProcessor.java deleted file mode 100644 index c8fa728..0000000 --- a/extensions-jvm/mongodb-gridfs/deployment/src/main/java/org/apache/camel/quarkus/component/mongodb/gridfs/deployment/MongodbGridfsProcessor.java +++ /dev/null @@ -1,47 +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.mongodb.gridfs.deployment; - -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; - -class MongodbGridfsProcessor { - private static final Logger LOG = Logger.getLogger(MongodbGridfsProcessor.class); - - private static final String FEATURE = "camel-mongodb-gridfs"; - - @BuildStep - FeatureBuildItem feature() { - 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 - } - -} diff --git a/extensions-jvm/mongodb-gridfs/integration-test/pom.xml b/extensions-jvm/mongodb-gridfs/integration-test/pom.xml deleted file mode 100644 index ab8c2a6..0000000 --- a/extensions-jvm/mongodb-gridfs/integration-test/pom.xml +++ /dev/null @@ -1,81 +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.1.0-SNAPSHOT</version> - <relativePath>../../../poms/build-parent-it/pom.xml</relativePath> - </parent> - - <artifactId>camel-quarkus-mongodb-gridfs-integration-test</artifactId> - <name>Camel Quarkus :: MongoDB GridFS :: Integration Test</name> - <description>Integration tests for Camel Quarkus MongoDB GridFS extension</description> - - <properties> - <!-- mvnd, a.k.a. Maven Daemon: https://github.com/gnodet/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 rule whenever you change the dependencies of this module by running --> - <!-- mvn process-resources -Pformat from the root directory --> - <mvnd.builder.rule>camel-quarkus-mongodb-gridfs-deployment,camel-quarkus-support-policy-deployment</mvnd.builder.rule> - </properties> - - <dependencies> - <dependency> - <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-mongodb-gridfs</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> - - <build> - <plugins> - <plugin> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-maven-plugin</artifactId> - <executions> - <execution> - <goals> - <goal>build</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> -</project> diff --git a/extensions-jvm/mongodb-gridfs/integration-test/src/main/java/org/apache/camel/quarkus/component/mongodb/gridfs/it/MongodbGridfsResource.java b/extensions-jvm/mongodb-gridfs/integration-test/src/main/java/org/apache/camel/quarkus/component/mongodb/gridfs/it/MongodbGridfsResource.java deleted file mode 100644 index ebce1fa..0000000 --- a/extensions-jvm/mongodb-gridfs/integration-test/src/main/java/org/apache/camel/quarkus/component/mongodb/gridfs/it/MongodbGridfsResource.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.mongodb.gridfs.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("/mongodb-gridfs") -@ApplicationScoped -public class MongodbGridfsResource { - - private static final Logger LOG = Logger.getLogger(MongodbGridfsResource.class); - - private static final String COMPONENT_MONGODB_GRIDFS = "mongodb-gridfs"; - @Inject - CamelContext context; - - @Path("/load/component/mongodb-gridfs") - @GET - @Produces(MediaType.TEXT_PLAIN) - public Response loadComponentMongodbGridfs() throws Exception { - /* This is an autogenerated test */ - if (context.getComponent(COMPONENT_MONGODB_GRIDFS) != null) { - return Response.ok().build(); - } - LOG.warnf("Could not load [%s] from the Camel context", COMPONENT_MONGODB_GRIDFS); - return Response.status(500, COMPONENT_MONGODB_GRIDFS + " could not be loaded from the Camel context").build(); - } -} diff --git a/extensions-jvm/pom.xml b/extensions-jvm/pom.xml index 86ebd77..7c2b69d 100644 --- a/extensions-jvm/pom.xml +++ b/extensions-jvm/pom.xml @@ -55,7 +55,6 @@ <module>google-pubsub</module> <module>groovy</module> <module>grpc</module> - <module>mongodb-gridfs</module> <module>nitrite</module> <module>ognl</module> <module>openstack</module> diff --git a/extensions/mongodb/deployment/pom.xml b/extensions-support/mongodb/deployment/pom.xml similarity index 91% copy from extensions/mongodb/deployment/pom.xml copy to extensions-support/mongodb/deployment/pom.xml index 86b57f8..df15952 100644 --- a/extensions/mongodb/deployment/pom.xml +++ b/extensions-support/mongodb/deployment/pom.xml @@ -21,13 +21,13 @@ <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-mongodb-parent</artifactId> + <artifactId>camel-quarkus-support-mongodb-parent</artifactId> <version>1.1.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> - <artifactId>camel-quarkus-mongodb-deployment</artifactId> - <name>Camel Quarkus :: MongoDB :: Deployment</name> + <artifactId>camel-quarkus-support-mongodb-deployment</artifactId> + <name>Camel Quarkus :: Support :: MongoDB :: Deployment</name> <dependencyManagement> <dependencies> @@ -43,16 +43,16 @@ <dependencies> <dependency> - <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-core-deployment</artifactId> - </dependency> - <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-mongodb-client-deployment</artifactId> </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-mongodb</artifactId> + <artifactId>camel-quarkus-core-deployment</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-support-mongodb</artifactId> </dependency> </dependencies> diff --git a/extensions/mongodb/deployment/src/main/java/org/apache/camel/quarkus/component/mongodb/deployment/MongoDbProcessor.java b/extensions-support/mongodb/deployment/src/main/java/org/apache/camel/quarkus/support/mongodb/deployment/SupportMongoDBProcessor.java similarity index 90% copy from extensions/mongodb/deployment/src/main/java/org/apache/camel/quarkus/component/mongodb/deployment/MongoDbProcessor.java copy to extensions-support/mongodb/deployment/src/main/java/org/apache/camel/quarkus/support/mongodb/deployment/SupportMongoDBProcessor.java index a4a3e0a..3935138 100644 --- a/extensions/mongodb/deployment/src/main/java/org/apache/camel/quarkus/component/mongodb/deployment/MongoDbProcessor.java +++ b/extensions-support/mongodb/deployment/src/main/java/org/apache/camel/quarkus/support/mongodb/deployment/SupportMongoDBProcessor.java @@ -1,4 +1,3 @@ - /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -15,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.quarkus.component.mongodb.deployment; +package org.apache.camel.quarkus.support.mongodb.deployment; import java.util.List; @@ -26,9 +25,9 @@ import io.quarkus.mongodb.deployment.MongoClientBuildItem; import io.quarkus.mongodb.runtime.MongoClientRecorder; import org.apache.camel.quarkus.core.deployment.spi.CamelRuntimeBeanBuildItem; -class MongoDbProcessor { +class SupportMongoDBProcessor { - private static final String FEATURE = "camel-mongodb"; + private static final String FEATURE = "camel-support-mongodb"; @BuildStep FeatureBuildItem feature() { @@ -48,7 +47,7 @@ class MongoDbProcessor { new CamelRuntimeBeanBuildItem( "camelMongoClient", "com.mongodb.client.MongoClient", - mongoClients.get(0).getClient())); + mongoClient.getClient())); } } } diff --git a/extensions-jvm/mongodb-gridfs/pom.xml b/extensions-support/mongodb/pom.xml similarity index 82% copy from extensions-jvm/mongodb-gridfs/pom.xml copy to extensions-support/mongodb/pom.xml index 03d52e4..0471f7c 100644 --- a/extensions-jvm/mongodb-gridfs/pom.xml +++ b/extensions-support/mongodb/pom.xml @@ -21,18 +21,17 @@ <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-build-parent-it</artifactId> + <artifactId>camel-quarkus-build-parent</artifactId> <version>1.1.0-SNAPSHOT</version> - <relativePath>../../poms/build-parent-it/pom.xml</relativePath> + <relativePath>../../poms/build-parent/pom.xml</relativePath> </parent> - <artifactId>camel-quarkus-mongodb-gridfs-parent</artifactId> - <name>Camel Quarkus :: MongoDB GridFS</name> + <artifactId>camel-quarkus-support-mongodb-parent</artifactId> + <name>Camel Quarkus :: Support :: MongoDB</name> <packaging>pom</packaging> <modules> <module>deployment</module> <module>runtime</module> - <module>integration-test</module> </modules> </project> diff --git a/extensions-jvm/mongodb-gridfs/runtime/pom.xml b/extensions-support/mongodb/runtime/pom.xml similarity index 85% copy from extensions-jvm/mongodb-gridfs/runtime/pom.xml copy to extensions-support/mongodb/runtime/pom.xml index 1071460..1033bc7 100644 --- a/extensions-jvm/mongodb-gridfs/runtime/pom.xml +++ b/extensions-support/mongodb/runtime/pom.xml @@ -21,16 +21,18 @@ <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-mongodb-gridfs-parent</artifactId> + <artifactId>camel-quarkus-support-mongodb-parent</artifactId> <version>1.1.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> - <artifactId>camel-quarkus-mongodb-gridfs</artifactId> - <name>Camel Quarkus :: MongoDB GridFS :: Runtime</name> + <artifactId>camel-quarkus-support-mongodb</artifactId> + <name>Camel Quarkus :: Support :: MongoDB :: Runtime</name> + <description>Camel Quarkus Support MongoDB</description> <properties> - <firstVersion>1.0.0-M6</firstVersion> + <firstVersion>1.0.0-M8</firstVersion> + <quarkus.metadata.unlisted>true</quarkus.metadata.unlisted> </properties> <dependencyManagement> @@ -51,8 +53,8 @@ <artifactId>camel-quarkus-core</artifactId> </dependency> <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-mongodb-gridfs</artifactId> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-mongodb-client</artifactId> </dependency> </dependencies> diff --git a/extensions-jvm/mongodb-gridfs/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions-support/mongodb/runtime/src/main/resources/META-INF/quarkus-extension.yaml similarity index 71% copy from extensions-jvm/mongodb-gridfs/runtime/src/main/resources/META-INF/quarkus-extension.yaml copy to extensions-support/mongodb/runtime/src/main/resources/META-INF/quarkus-extension.yaml index 831eca8..7f01608 100644 --- a/extensions-jvm/mongodb-gridfs/runtime/src/main/resources/META-INF/quarkus-extension.yaml +++ b/extensions-support/mongodb/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -15,17 +15,11 @@ # limitations under the License. # -# This is a generated file. Do not edit directly! -# To re-generate, run the following command from the top level directory: -# -# mvn -N cq:update-quarkus-metadata -# --- -name: "Camel MongoDB GridFS" -description: "Interact with MongoDB GridFS" +name: "Camel Quarkus Support MongoDB" +description: "Camel Quarkus Support MongoDB" metadata: unlisted: true - guide: "https://camel.apache.org/components/latest/mongodb-gridfs-component.html" + guide: "https://quarkus.io/guides/camel" categories: - "integration" - status: "preview" diff --git a/extensions-support/pom.xml b/extensions-support/pom.xml index a6c176c..12dee0c 100644 --- a/extensions-support/pom.xml +++ b/extensions-support/pom.xml @@ -45,6 +45,7 @@ <module>jackson-dataformat-xml</module> <module>jetty</module> <module>mail</module> + <module>mongodb</module> <module>policy</module> <module>retrofit</module> <module>spring</module> diff --git a/extensions-jvm/mongodb-gridfs/deployment/pom.xml b/extensions/mongodb-gridfs/deployment/pom.xml similarity index 94% rename from extensions-jvm/mongodb-gridfs/deployment/pom.xml rename to extensions/mongodb-gridfs/deployment/pom.xml index 27aab34..69846cb 100644 --- a/extensions-jvm/mongodb-gridfs/deployment/pom.xml +++ b/extensions/mongodb-gridfs/deployment/pom.xml @@ -48,6 +48,10 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-support-mongodb-deployment</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-mongodb-gridfs</artifactId> </dependency> </dependencies> diff --git a/extensions-jvm/mongodb-gridfs/integration-test/src/test/java/org/apache/camel/quarkus/component/mongodb/gridfs/it/MongodbGridfsTest.java b/extensions/mongodb-gridfs/deployment/src/main/java/org/apache/camel/quarkus/component/mongodb/gridfs/deployment/MongodbGridfsProcessor.java similarity index 64% copy from extensions-jvm/mongodb-gridfs/integration-test/src/test/java/org/apache/camel/quarkus/component/mongodb/gridfs/it/MongodbGridfsTest.java copy to extensions/mongodb-gridfs/deployment/src/main/java/org/apache/camel/quarkus/component/mongodb/gridfs/deployment/MongodbGridfsProcessor.java index 3f88415..d748243 100644 --- a/extensions-jvm/mongodb-gridfs/integration-test/src/test/java/org/apache/camel/quarkus/component/mongodb/gridfs/it/MongodbGridfsTest.java +++ b/extensions/mongodb-gridfs/deployment/src/main/java/org/apache/camel/quarkus/component/mongodb/gridfs/deployment/MongodbGridfsProcessor.java @@ -14,21 +14,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.quarkus.component.mongodb.gridfs.it; +package org.apache.camel.quarkus.component.mongodb.gridfs.deployment; -import io.quarkus.test.junit.QuarkusTest; -import io.restassured.RestAssured; -import org.junit.jupiter.api.Test; +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.FeatureBuildItem; -@QuarkusTest -class MongodbGridfsTest { +class MongodbGridfsProcessor { + private static final String FEATURE = "camel-mongodb-gridfs"; - @Test - public void loadComponentMongodbGridfs() { - /* A simple autogenerated test */ - RestAssured.get("/mongodb-gridfs/load/component/mongodb-gridfs") - .then() - .statusCode(200); + @BuildStep + FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); } - } diff --git a/extensions-jvm/mongodb-gridfs/pom.xml b/extensions/mongodb-gridfs/pom.xml similarity index 97% rename from extensions-jvm/mongodb-gridfs/pom.xml rename to extensions/mongodb-gridfs/pom.xml index 03d52e4..1e09917 100644 --- a/extensions-jvm/mongodb-gridfs/pom.xml +++ b/extensions/mongodb-gridfs/pom.xml @@ -33,6 +33,5 @@ <modules> <module>deployment</module> <module>runtime</module> - <module>integration-test</module> </modules> </project> diff --git a/extensions-jvm/mongodb-gridfs/runtime/pom.xml b/extensions/mongodb-gridfs/runtime/pom.xml similarity index 94% rename from extensions-jvm/mongodb-gridfs/runtime/pom.xml rename to extensions/mongodb-gridfs/runtime/pom.xml index 1071460..44906b9 100644 --- a/extensions-jvm/mongodb-gridfs/runtime/pom.xml +++ b/extensions/mongodb-gridfs/runtime/pom.xml @@ -51,6 +51,10 @@ <artifactId>camel-quarkus-core</artifactId> </dependency> <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-support-mongodb</artifactId> + </dependency> + <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-mongodb-gridfs</artifactId> </dependency> diff --git a/extensions-jvm/mongodb-gridfs/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/mongodb-gridfs/runtime/src/main/resources/META-INF/quarkus-extension.yaml similarity index 96% rename from extensions-jvm/mongodb-gridfs/runtime/src/main/resources/META-INF/quarkus-extension.yaml rename to extensions/mongodb-gridfs/runtime/src/main/resources/META-INF/quarkus-extension.yaml index 831eca8..c517aee 100644 --- a/extensions-jvm/mongodb-gridfs/runtime/src/main/resources/META-INF/quarkus-extension.yaml +++ b/extensions/mongodb-gridfs/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -24,8 +24,6 @@ name: "Camel MongoDB GridFS" description: "Interact with MongoDB GridFS" metadata: - unlisted: true guide: "https://camel.apache.org/components/latest/mongodb-gridfs-component.html" categories: - "integration" - status: "preview" diff --git a/extensions/mongodb/deployment/pom.xml b/extensions/mongodb/deployment/pom.xml index 86b57f8..ebde5fc 100644 --- a/extensions/mongodb/deployment/pom.xml +++ b/extensions/mongodb/deployment/pom.xml @@ -47,8 +47,8 @@ <artifactId>camel-quarkus-core-deployment</artifactId> </dependency> <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-mongodb-client-deployment</artifactId> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-support-mongodb-deployment</artifactId> </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> diff --git a/extensions/mongodb/deployment/src/main/java/org/apache/camel/quarkus/component/mongodb/deployment/MongoDbProcessor.java b/extensions/mongodb/deployment/src/main/java/org/apache/camel/quarkus/component/mongodb/deployment/MongoDbProcessor.java index a4a3e0a..8b5e5c6 100644 --- a/extensions/mongodb/deployment/src/main/java/org/apache/camel/quarkus/component/mongodb/deployment/MongoDbProcessor.java +++ b/extensions/mongodb/deployment/src/main/java/org/apache/camel/quarkus/component/mongodb/deployment/MongoDbProcessor.java @@ -17,14 +17,8 @@ */ package org.apache.camel.quarkus.component.mongodb.deployment; -import java.util.List; - -import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.builditem.FeatureBuildItem; -import io.quarkus.mongodb.deployment.MongoClientBuildItem; -import io.quarkus.mongodb.runtime.MongoClientRecorder; -import org.apache.camel.quarkus.core.deployment.spi.CamelRuntimeBeanBuildItem; class MongoDbProcessor { @@ -34,22 +28,4 @@ class MongoDbProcessor { FeatureBuildItem feature() { return new FeatureBuildItem(FEATURE); } - - @BuildStep - void registerCamelMongoClientProducer( - List<MongoClientBuildItem> mongoClients, - BuildProducer<CamelRuntimeBeanBuildItem> runtimeBeans) { - - for (MongoClientBuildItem mongoClient : mongoClients) { - // If there is a default mongo client instance, then bind it to the camel registry - // with the default mongo client name used by the camel-mongodb component - if (MongoClientRecorder.DEFAULT_MONGOCLIENT_NAME.equals(mongoClient.getName())) { - runtimeBeans.produce( - new CamelRuntimeBeanBuildItem( - "camelMongoClient", - "com.mongodb.client.MongoClient", - mongoClients.get(0).getClient())); - } - } - } } diff --git a/extensions/mongodb/runtime/pom.xml b/extensions/mongodb/runtime/pom.xml index 2517e80..6ccf61f 100644 --- a/extensions/mongodb/runtime/pom.xml +++ b/extensions/mongodb/runtime/pom.xml @@ -51,12 +51,12 @@ <artifactId>camel-quarkus-core</artifactId> </dependency> <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-mongodb</artifactId> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-support-mongodb</artifactId> </dependency> <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-mongodb-client</artifactId> + <groupId>org.apache.camel</groupId> + <artifactId>camel-mongodb</artifactId> </dependency> <dependency> <groupId>org.mongodb</groupId> diff --git a/extensions/pom.xml b/extensions/pom.xml index e81fb31..e0d287e 100644 --- a/extensions/pom.xml +++ b/extensions/pom.xml @@ -108,6 +108,7 @@ <module>microprofile-health</module> <module>microprofile-metrics</module> <module>mongodb</module> + <module>mongodb-gridfs</module> <module>mustache</module> <module>netty</module> <module>netty-http</module> diff --git a/integration-tests/mongodb/pom.xml b/integration-tests/mongodb/pom.xml index a72d0f7..b4df08e 100644 --- a/integration-tests/mongodb/pom.xml +++ b/integration-tests/mongodb/pom.xml @@ -36,7 +36,7 @@ <!-- explicit dependencies of this module in the Maven sense, although they are required by the Quarkus Maven plugin. --> <!-- Please update rule whenever you change the dependencies of this module by running --> <!-- mvn process-resources -Pformat from the root directory --> - <mvnd.builder.rule>camel-quarkus-mongodb-deployment,camel-quarkus-support-policy-deployment</mvnd.builder.rule> + <mvnd.builder.rule>camel-quarkus-mongodb-deployment,camel-quarkus-mongodb-gridfs-deployment,camel-quarkus-support-policy-deployment</mvnd.builder.rule> </properties> <dependencies> @@ -45,6 +45,10 @@ <artifactId>camel-quarkus-mongodb</artifactId> </dependency> <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-mongodb-gridfs</artifactId> + </dependency> + <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-resteasy</artifactId> </dependency> diff --git a/integration-tests/mongodb/src/main/java/org/apache/camel/quarkus/component/mongodb/it/MongodbGridfsResource.java b/integration-tests/mongodb/src/main/java/org/apache/camel/quarkus/component/mongodb/it/MongodbGridfsResource.java new file mode 100644 index 0000000..00a06d5 --- /dev/null +++ b/integration-tests/mongodb/src/main/java/org/apache/camel/quarkus/component/mongodb/it/MongodbGridfsResource.java @@ -0,0 +1,89 @@ +/* + * 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.mongodb.it; + +import java.net.URI; +import java.util.HashMap; +import java.util.Map; + +import javax.inject.Inject; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import com.mongodb.MongoGridFSException; +import org.apache.camel.Exchange; +import org.apache.camel.ProducerTemplate; +import org.apache.camel.component.mongodb.gridfs.GridFsEndpoint; + +@Path("/mongodb-gridfs") +public class MongodbGridfsResource { + + @Inject + ProducerTemplate producerTemplate; + + @Path("/upload/{fileName}") + @POST + @Produces(MediaType.TEXT_PLAIN) + public Response uploadFile(@PathParam("fileName") String fileName, String content) throws Exception { + Map<String, Object> headers = new HashMap<>(); + headers.put(Exchange.FILE_NAME, fileName); + headers.put(Exchange.CONTENT_TYPE, "text/plain"); + + Exchange result = producerTemplate.request("mongodb-gridfs:camelMongoClient?database=test&operation=create", + exchange -> { + exchange.getMessage().setHeaders(headers); + exchange.getMessage().setBody(content); + }); + + return Response + .created(new URI("https://camel.apache.org/")) + .entity(result.getMessage().getHeader(GridFsEndpoint.GRIDFS_OBJECT_ID)) + .build(); + } + + @Path("/get/{fileName}") + @GET + @Produces(MediaType.TEXT_PLAIN) + public Response retrieveFile(@PathParam("fileName") String fileName) { + String result = null; + try { + result = producerTemplate.requestBodyAndHeader("mongodb-gridfs:camelMongoClient?database=test&operation=findOne", + null, + Exchange.FILE_NAME, fileName, String.class); + } catch (Exception e) { + if (e.getCause() instanceof MongoGridFSException) { + return Response.status(404).build(); + } + } + return Response.ok().entity(result).build(); + } + + @Path("/delete/{fileName}") + @DELETE + public Response deleteFile(@PathParam("fileName") String fileName) { + producerTemplate.requestBodyAndHeader("mongodb-gridfs:camelMongoClient?database=test&operation=remove", null, + Exchange.FILE_NAME, + fileName); + return Response.noContent().build(); + } +} diff --git a/extensions-jvm/mongodb-gridfs/integration-test/src/test/java/org/apache/camel/quarkus/component/mongodb/gridfs/it/MongodbGridfsTest.java b/integration-tests/mongodb/src/test/java/org/apache/camel/quarkus/component/mongodb/it/MongodbGridfsIT.java similarity index 64% rename from extensions-jvm/mongodb-gridfs/integration-test/src/test/java/org/apache/camel/quarkus/component/mongodb/gridfs/it/MongodbGridfsTest.java rename to integration-tests/mongodb/src/test/java/org/apache/camel/quarkus/component/mongodb/it/MongodbGridfsIT.java index 3f88415..1f69298 100644 --- a/extensions-jvm/mongodb-gridfs/integration-test/src/test/java/org/apache/camel/quarkus/component/mongodb/gridfs/it/MongodbGridfsTest.java +++ b/integration-tests/mongodb/src/test/java/org/apache/camel/quarkus/component/mongodb/it/MongodbGridfsIT.java @@ -14,21 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.quarkus.component.mongodb.gridfs.it; +package org.apache.camel.quarkus.component.mongodb.it; -import io.quarkus.test.junit.QuarkusTest; -import io.restassured.RestAssured; -import org.junit.jupiter.api.Test; - -@QuarkusTest -class MongodbGridfsTest { - - @Test - public void loadComponentMongodbGridfs() { - /* A simple autogenerated test */ - RestAssured.get("/mongodb-gridfs/load/component/mongodb-gridfs") - .then() - .statusCode(200); - } +import io.quarkus.test.junit.NativeImageTest; +@NativeImageTest +class MongodbGridfsIT extends MongodbGridfsTest { } diff --git a/integration-tests/mongodb/src/test/java/org/apache/camel/quarkus/component/mongodb/it/MongodbGridfsTest.java b/integration-tests/mongodb/src/test/java/org/apache/camel/quarkus/component/mongodb/it/MongodbGridfsTest.java new file mode 100644 index 0000000..4aef1e9 --- /dev/null +++ b/integration-tests/mongodb/src/test/java/org/apache/camel/quarkus/component/mongodb/it/MongodbGridfsTest.java @@ -0,0 +1,68 @@ +/* + * 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.mongodb.it; + +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; +import io.restassured.http.ContentType; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.Matchers.is; + +@QuarkusTest +@QuarkusTestResource(MongoDbTestResource.class) +class MongodbGridfsTest { + + @Test + public void testMongodbGridfsComponent() { + final String fileContent = "Hello Camel Quarkus MongoDB GridFS"; + + // Upload file + String objectId = RestAssured.given() + .contentType(ContentType.TEXT) + .body(fileContent) + .post("/mongodb-gridfs/upload/test.txt") + .then() + .statusCode(201) + .extract() + .body() + .asString(); + + Assertions.assertNotNull(objectId); + + // Retrieve file + RestAssured.given() + .get("/mongodb-gridfs/get/test.txt") + .then() + .statusCode(200) + .body(is(fileContent)); + + // Delete file + RestAssured.given() + .delete("/mongodb-gridfs/delete/test.txt") + .then() + .statusCode(204); + + // Verify file deletion + RestAssured.given() + .get("/mongodb-gridfs/get/test.txt") + .then() + .statusCode(404); + } +} diff --git a/poms/bom-deployment/pom.xml b/poms/bom-deployment/pom.xml index a26daa9..b9c50ca 100644 --- a/poms/bom-deployment/pom.xml +++ b/poms/bom-deployment/pom.xml @@ -799,6 +799,11 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-support-mongodb-deployment</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-support-policy-deployment</artifactId> <version>${camel-quarkus.version}</version> </dependency> diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml index 57c9cb3..dea1e5f 100644 --- a/poms/bom/pom.xml +++ b/poms/bom/pom.xml @@ -1833,6 +1833,11 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-support-mongodb</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-support-policy</artifactId> <version>${camel-quarkus.version}</version> </dependency>