This is an automated email from the ASF dual-hosted git repository.
jbonofre pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-karaf.git
The following commit(s) were added to refs/heads/main by this push:
new 23cd14c07 feat(#772): add camel-mongodb-gridfs integration test (#773)
23cd14c07 is described below
commit 23cd14c0742cfe839b90c0474a530ed6b882a2be
Author: François de Parscau <[email protected]>
AuthorDate: Tue Dec 1 11:03:50 2026 +0100
feat(#772): add camel-mongodb-gridfs integration test (#773)
* feat(#772): add camel-mongodb-gridfs integration test
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
* feat(#772): add camel-mongodb-gridfs integration test
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
---------
Co-authored-by: Claude Sonnet 5.5 <[email protected]>
---
tests/features/camel-mongodb-gridfs/pom.xml | 62 +++++++++++++++++++
.../test/CamelMongodbGridfsRouteSupplier.java | 65 ++++++++++++++++++++
.../karaf/camel/itest/CamelMongodbGridfsITest.java | 69 ++++++++++++++++++++++
tests/features/pom.xml | 1 +
4 files changed, 197 insertions(+)
diff --git a/tests/features/camel-mongodb-gridfs/pom.xml
b/tests/features/camel-mongodb-gridfs/pom.xml
new file mode 100644
index 000000000..01918b615
--- /dev/null
+++ b/tests/features/camel-mongodb-gridfs/pom.xml
@@ -0,0 +1,62 @@
+<?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.karaf</groupId>
+ <artifactId>camel-karaf-features-test</artifactId>
+ <version>4.22.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-mongodb-gridfs-test</artifactId>
+ <name>Apache Camel :: Karaf :: Tests :: Features :: MongoDB GridFS</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-mongodb-gridfs</artifactId>
+ <version>${camel-version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mongodb</groupId>
+ <artifactId>mongodb-driver-sync</artifactId>
+ <version>${mongo-java-driver-version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.testcontainers</groupId>
+ <artifactId>testcontainers</artifactId>
+ <version>${testcontainers-version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <directory>../../../src/main/resources</directory>
+ <filtering>false</filtering>
+ </resource>
+ </resources>
+ </build>
+
+</project>
diff --git
a/tests/features/camel-mongodb-gridfs/src/main/java/org/apache/karaf/camel/test/CamelMongodbGridfsRouteSupplier.java
b/tests/features/camel-mongodb-gridfs/src/main/java/org/apache/karaf/camel/test/CamelMongodbGridfsRouteSupplier.java
new file mode 100644
index 000000000..23ecaf47d
--- /dev/null
+++
b/tests/features/camel-mongodb-gridfs/src/main/java/org/apache/karaf/camel/test/CamelMongodbGridfsRouteSupplier.java
@@ -0,0 +1,65 @@
+/*
+ * 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.karaf.camel.test;
+
+import java.util.function.Function;
+
+import com.mongodb.client.MongoClient;
+import com.mongodb.client.MongoClients;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.model.RouteDefinition;
+import
org.apache.karaf.camel.itests.AbstractCamelSingleFeatureResultMockBasedRouteSupplier;
+import org.apache.karaf.camel.itests.CamelRouteSupplier;
+import org.osgi.service.component.annotations.Component;
+
+@Component(name = "karaf-camel-mongodb-gridfs-test", immediate = true, service
= CamelRouteSupplier.class)
+public class CamelMongodbGridfsRouteSupplier extends
AbstractCamelSingleFeatureResultMockBasedRouteSupplier {
+
+ public static final String FILE_NAME = "karaf-test.txt";
+ public static final String CONTENT = "Hello GridFS from Karaf";
+
+ private static final String URI =
"mongodb-gridfs:gridfsClient?database=karaf&bucket=karafbucket";
+
+ private MongoClient mongoClient;
+
+ @Override
+ public void configure(CamelContext camelContext) {
+ mongoClient =
MongoClients.create(System.getProperty("mongo.connection"));
+ camelContext.getRegistry().bind("gridfsClient", mongoClient);
+ }
+
+ @Override
+ protected void configureProducer(RouteBuilder builder, RouteDefinition
producerRoute) {
+ producerRoute.setHeader(Exchange.FILE_NAME,
builder.constant(FILE_NAME))
+ .to(URI + "&operation=create");
+ }
+
+ @Override
+ protected Function<RouteBuilder, RouteDefinition> consumerRoute() {
+ return builder -> builder.from(URI + "&delay=500")
+ .convertBodyTo(String.class);
+ }
+
+ @Override
+ public void cleanUp(CamelContext camelContext) {
+ if (mongoClient != null) {
+ mongoClient.close();
+ }
+ }
+}
diff --git
a/tests/features/camel-mongodb-gridfs/src/test/java/org/apache/karaf/camel/itest/CamelMongodbGridfsITest.java
b/tests/features/camel-mongodb-gridfs/src/test/java/org/apache/karaf/camel/itest/CamelMongodbGridfsITest.java
new file mode 100644
index 000000000..cb9d3ab59
--- /dev/null
+++
b/tests/features/camel-mongodb-gridfs/src/test/java/org/apache/karaf/camel/itest/CamelMongodbGridfsITest.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.karaf.camel.itest;
+
+import org.apache.camel.component.mock.MockEndpoint;
+import
org.apache.karaf.camel.itests.AbstractCamelSingleFeatureResultMockBasedRouteITest;
+import org.apache.karaf.camel.itests.CamelKarafTestHint;
+import org.apache.karaf.camel.itests.GenericContainerResource;
+import org.apache.karaf.camel.itests.PaxExamWithExternalResource;
+import org.apache.karaf.camel.test.CamelMongodbGridfsRouteSupplier;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.containers.wait.strategy.Wait;
+
+@CamelKarafTestHint(externalResourceProvider =
CamelMongodbGridfsITest.ExternalResourceProviders.class)
+@RunWith(PaxExamWithExternalResource.class)
+@ExamReactorStrategy(PerClass.class)
+public class CamelMongodbGridfsITest extends
AbstractCamelSingleFeatureResultMockBasedRouteITest {
+
+ private static final int MONGO_PORT = 27017;
+
+ @Override
+ public String getBodyToSend() {
+ return CamelMongodbGridfsRouteSupplier.CONTENT;
+ }
+
+ @Override
+ public void configureMock(MockEndpoint mock) {
+ mock.expectedBodiesReceived(CamelMongodbGridfsRouteSupplier.CONTENT);
+ }
+
+ @Test
+ public void testResultMock() throws Exception {
+ assertMockEndpointsSatisfied();
+ }
+
+ public static final class ExternalResourceProviders {
+ public static GenericContainerResource<MongoContainer>
createMongoContainer() {
+ MongoContainer container = new MongoContainer("mongo:8.3.17");
+ return new GenericContainerResource<>(container, resource ->
+ resource.setProperty("mongo.connection",
+
"mongodb://127.0.0.1:%d".formatted(container.getMappedPort(MONGO_PORT))));
+ }
+ }
+
+ public static class MongoContainer extends
GenericContainer<MongoContainer> {
+ public MongoContainer(final String image) {
+ super(image);
+ withExposedPorts(MONGO_PORT)
+ .waitingFor(Wait.forLogMessage(".*[Ww]aiting for
connections.*", 1));
+ }
+ }
+}
diff --git a/tests/features/pom.xml b/tests/features/pom.xml
index 3dfb92dda..c22854ce7 100644
--- a/tests/features/pom.xml
+++ b/tests/features/pom.xml
@@ -105,6 +105,7 @@
<module>camel-leveldb</module>
<module>camel-netty-http</module>
<module>camel-mail</module>
+ <module>camel-mongodb-gridfs</module>
<module>camel-olingo2</module>
<module>camel-opentelemetry2</module>
<module>camel-paho-mqtt5</module>