This is an automated email from the ASF dual-hosted git repository. jamesnetherton pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/main by this push: new 0be98ea Use test grouping for MongoDB extensions 0be98ea is described below commit 0be98eab82645e86635b11a7c45b49ca533fc423 Author: James Netherton <jamesnether...@gmail.com> AuthorDate: Fri Sep 10 10:28:35 2021 +0100 Use test grouping for MongoDB extensions Fixes #3089 --- .../mongodb/mongodb-gridfs}/pom.xml | 31 ++---- .../mongodb/gridfs}/it/MongodbGridfsResource.java | 2 +- .../mongodb/gridfs}/it/MongodbGridfsIT.java | 2 +- .../mongodb/gridfs}/it/MongodbGridfsTest.java | 3 +- .../mongodb}/mongodb/pom.xml | 23 +---- .../component/mongodb/it/MongoDbResource.java | 3 - .../quarkus/component/mongodb/it/MongoDbRoute.java | 34 +++---- .../quarkus/component/mongodb/it/MongoDbIT.java | 0 .../quarkus/component/mongodb/it/MongoDbTest.java | 52 +++++------ .../mongodb}/pom.xml | 30 ++---- integration-tests-support/{ => mongodb}/pom.xml | 60 ++++++------ .../test/support/mongodb/MongoDbConstants.java | 15 ++- .../test/support/mongodb}/MongoDbTestResource.java | 28 +++--- .../src/main/resources/application.properties | 17 ++++ .../mongodb/src/main}/resources/initMongodb.txt | 0 integration-tests-support/pom.xml | 1 + .../{mongodb => mongodb-grouped}/pom.xml | 104 +++++++++++++++++---- integration-tests/pom.xml | 2 +- poms/bom-test/pom.xml | 5 + tooling/scripts/test-categories.yaml | 2 +- 20 files changed, 236 insertions(+), 178 deletions(-) diff --git a/integration-tests/mongodb/pom.xml b/integration-test-groups/mongodb/mongodb-gridfs/pom.xml similarity index 80% copy from integration-tests/mongodb/pom.xml copy to integration-test-groups/mongodb/mongodb-gridfs/pom.xml index 3c2570c..2e428cd 100644 --- a/integration-tests/mongodb/pom.xml +++ b/integration-test-groups/mongodb/mongodb-gridfs/pom.xml @@ -21,22 +21,23 @@ <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-integration-tests</artifactId> + <artifactId>camel-quarkus-integration-tests-mongodb</artifactId> <version>2.3.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> </parent> - <artifactId>camel-quarkus-integration-test-mongodb</artifactId> - <name>Camel Quarkus :: Integration Tests :: MongoDB</name> - <description>Integration tests for Camel Quarkus MongoDB extension</description> + <artifactId>camel-quarkus-integration-test-mongodb-gridfs</artifactId> + <name>Camel Quarkus :: Integration Tests :: MongoDB GridFS</name> + <description>Integration tests for Camel Quarkus MongoDB GridFS extension</description> <dependencies> <dependency> <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-mongodb</artifactId> + <artifactId>camel-quarkus-mongodb-gridfs</artifactId> </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-mongodb-gridfs</artifactId> + <artifactId>camel-quarkus-integration-tests-support-mongodb</artifactId> </dependency> <dependency> <groupId>io.quarkus</groupId> @@ -59,11 +60,6 @@ <scope>test</scope> </dependency> <dependency> - <groupId>org.testcontainers</groupId> - <artifactId>testcontainers</artifactId> - <scope>test</scope> - </dependency> - <dependency> <groupId>org.awaitility</groupId> <artifactId>awaitility</artifactId> <scope>test</scope> @@ -72,19 +68,6 @@ <!-- 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-mongodb-deployment</artifactId> - <version>${project.version}</version> - <type>pom</type> - <scope>test</scope> - <exclusions> - <exclusion> - <groupId>*</groupId> - <artifactId>*</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-mongodb-gridfs-deployment</artifactId> <version>${project.version}</version> <type>pom</type> diff --git a/integration-tests/mongodb/src/main/java/org/apache/camel/quarkus/component/mongodb/it/MongodbGridfsResource.java b/integration-test-groups/mongodb/mongodb-gridfs/src/main/java/org/apache/camel/quarkus/component/mongodb/gridfs/it/MongodbGridfsResource.java similarity index 98% rename from integration-tests/mongodb/src/main/java/org/apache/camel/quarkus/component/mongodb/it/MongodbGridfsResource.java rename to integration-test-groups/mongodb/mongodb-gridfs/src/main/java/org/apache/camel/quarkus/component/mongodb/gridfs/it/MongodbGridfsResource.java index 2156141..09491a9 100644 --- a/integration-tests/mongodb/src/main/java/org/apache/camel/quarkus/component/mongodb/it/MongodbGridfsResource.java +++ b/integration-test-groups/mongodb/mongodb-gridfs/src/main/java/org/apache/camel/quarkus/component/mongodb/gridfs/it/MongodbGridfsResource.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.quarkus.component.mongodb.it; +package org.apache.camel.quarkus.component.mongodb.gridfs.it; import java.net.URI; import java.util.HashMap; diff --git a/integration-tests/mongodb/src/test/java/org/apache/camel/quarkus/component/mongodb/it/MongodbGridfsIT.java b/integration-test-groups/mongodb/mongodb-gridfs/src/test/java/org/apache/camel/quarkus/component/mongodb/gridfs/it/MongodbGridfsIT.java similarity index 93% rename from integration-tests/mongodb/src/test/java/org/apache/camel/quarkus/component/mongodb/it/MongodbGridfsIT.java rename to integration-test-groups/mongodb/mongodb-gridfs/src/test/java/org/apache/camel/quarkus/component/mongodb/gridfs/it/MongodbGridfsIT.java index 1f69298..745b50d 100644 --- a/integration-tests/mongodb/src/test/java/org/apache/camel/quarkus/component/mongodb/it/MongodbGridfsIT.java +++ b/integration-test-groups/mongodb/mongodb-gridfs/src/test/java/org/apache/camel/quarkus/component/mongodb/gridfs/it/MongodbGridfsIT.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.quarkus.component.mongodb.it; +package org.apache.camel.quarkus.component.mongodb.gridfs.it; import io.quarkus.test.junit.NativeImageTest; diff --git a/integration-tests/mongodb/src/test/java/org/apache/camel/quarkus/component/mongodb/it/MongodbGridfsTest.java b/integration-test-groups/mongodb/mongodb-gridfs/src/test/java/org/apache/camel/quarkus/component/mongodb/gridfs/it/MongodbGridfsTest.java similarity index 95% rename from integration-tests/mongodb/src/test/java/org/apache/camel/quarkus/component/mongodb/it/MongodbGridfsTest.java rename to integration-test-groups/mongodb/mongodb-gridfs/src/test/java/org/apache/camel/quarkus/component/mongodb/gridfs/it/MongodbGridfsTest.java index 0f7bea9..566bc3f 100644 --- a/integration-tests/mongodb/src/test/java/org/apache/camel/quarkus/component/mongodb/it/MongodbGridfsTest.java +++ b/integration-test-groups/mongodb/mongodb-gridfs/src/test/java/org/apache/camel/quarkus/component/mongodb/gridfs/it/MongodbGridfsTest.java @@ -14,12 +14,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.quarkus.component.mongodb.it; +package org.apache.camel.quarkus.component.mongodb.gridfs.it; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; import io.restassured.RestAssured; import io.restassured.http.ContentType; +import org.apache.camel.quarkus.test.support.mongodb.MongoDbTestResource; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; diff --git a/integration-tests/mongodb/pom.xml b/integration-test-groups/mongodb/mongodb/pom.xml similarity index 84% copy from integration-tests/mongodb/pom.xml copy to integration-test-groups/mongodb/mongodb/pom.xml index 3c2570c..6279a30 100644 --- a/integration-tests/mongodb/pom.xml +++ b/integration-test-groups/mongodb/mongodb/pom.xml @@ -21,8 +21,9 @@ <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-integration-tests</artifactId> + <artifactId>camel-quarkus-integration-tests-mongodb</artifactId> <version>2.3.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> </parent> <artifactId>camel-quarkus-integration-test-mongodb</artifactId> @@ -36,7 +37,7 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-mongodb-gridfs</artifactId> + <artifactId>camel-quarkus-integration-tests-support-mongodb</artifactId> </dependency> <dependency> <groupId>io.quarkus</groupId> @@ -59,11 +60,6 @@ <scope>test</scope> </dependency> <dependency> - <groupId>org.testcontainers</groupId> - <artifactId>testcontainers</artifactId> - <scope>test</scope> - </dependency> - <dependency> <groupId>org.awaitility</groupId> <artifactId>awaitility</artifactId> <scope>test</scope> @@ -83,19 +79,6 @@ </exclusion> </exclusions> </dependency> - <dependency> - <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-mongodb-gridfs-deployment</artifactId> - <version>${project.version}</version> - <type>pom</type> - <scope>test</scope> - <exclusions> - <exclusion> - <groupId>*</groupId> - <artifactId>*</artifactId> - </exclusion> - </exclusions> - </dependency> </dependencies> diff --git a/integration-tests/mongodb/src/main/java/org/apache/camel/quarkus/component/mongodb/it/MongoDbResource.java b/integration-test-groups/mongodb/mongodb/src/main/java/org/apache/camel/quarkus/component/mongodb/it/MongoDbResource.java similarity index 98% rename from integration-tests/mongodb/src/main/java/org/apache/camel/quarkus/component/mongodb/it/MongoDbResource.java rename to integration-test-groups/mongodb/mongodb/src/main/java/org/apache/camel/quarkus/component/mongodb/it/MongoDbResource.java index 693922f..ff84dbe 100644 --- a/integration-tests/mongodb/src/main/java/org/apache/camel/quarkus/component/mongodb/it/MongoDbResource.java +++ b/integration-test-groups/mongodb/mongodb/src/main/java/org/apache/camel/quarkus/component/mongodb/it/MongoDbResource.java @@ -55,9 +55,6 @@ import static com.mongodb.client.model.Filters.eq; @ApplicationScoped public class MongoDbResource { - static final String DEFAULT_MONGO_CLIENT_NAME = "camelMongoClient"; - static final String NAMED_MONGO_CLIENT_NAME = "myMongoClient"; - @Inject ProducerTemplate producerTemplate; diff --git a/integration-tests/mongodb/src/main/java/org/apache/camel/quarkus/component/mongodb/it/MongoDbRoute.java b/integration-test-groups/mongodb/mongodb/src/main/java/org/apache/camel/quarkus/component/mongodb/it/MongoDbRoute.java similarity index 68% rename from integration-tests/mongodb/src/main/java/org/apache/camel/quarkus/component/mongodb/it/MongoDbRoute.java rename to integration-test-groups/mongodb/mongodb/src/main/java/org/apache/camel/quarkus/component/mongodb/it/MongoDbRoute.java index a834277..75ff31f 100644 --- a/integration-tests/mongodb/src/main/java/org/apache/camel/quarkus/component/mongodb/it/MongoDbRoute.java +++ b/integration-test-groups/mongodb/mongodb/src/main/java/org/apache/camel/quarkus/component/mongodb/it/MongoDbRoute.java @@ -27,46 +27,42 @@ import javax.inject.Inject; import javax.inject.Named; import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.quarkus.test.support.mongodb.MongoDbConstants; import org.bson.Document; @ApplicationScoped public class MongoDbRoute extends RouteBuilder { - public static final String COLLECTION_TAILING = "tailingCollection"; - public static final String COLLECTION_PERSISTENT_TAILING = "persistentTailingCollection"; - public static final String COLLECTION_STREAM_CHANGES = "streamChangesCollection"; - @Inject @Named("results") Map<String, List<Document>> results; @Override public void configure() { - from(String.format("mongodb:%s?database=test&collection=%s&tailTrackIncreasingField=increasing", - MongoDbResource.DEFAULT_MONGO_CLIENT_NAME, COLLECTION_TAILING)) + fromF("mongodb:%s?database=test&collection=%s&tailTrackIncreasingField=increasing", + MongoDbConstants.DEFAULT_MONGO_CLIENT_NAME, MongoDbConstants.COLLECTION_TAILING) .process(e -> { - final List<Document> list = results.get(COLLECTION_TAILING); + final List<Document> list = results.get(MongoDbConstants.COLLECTION_TAILING); synchronized (list) { list.add(e.getMessage().getBody(Document.class)); } }); - from(String.format( - "mongodb:%s?database=test&collection=%s&tailTrackIncreasingField=increasing&persistentTailTracking=true&persistentId=darwin", - MongoDbResource.DEFAULT_MONGO_CLIENT_NAME, COLLECTION_PERSISTENT_TAILING)) - .id(COLLECTION_PERSISTENT_TAILING) + fromF("mongodb:%s?database=test&collection=%s&tailTrackIncreasingField=increasing&persistentTailTracking=true&persistentId=darwin", + MongoDbConstants.DEFAULT_MONGO_CLIENT_NAME, MongoDbConstants.COLLECTION_PERSISTENT_TAILING) + .id(MongoDbConstants.COLLECTION_PERSISTENT_TAILING) .process(e -> { - final List<Document> list = results.get(COLLECTION_PERSISTENT_TAILING); + final List<Document> list = results.get(MongoDbConstants.COLLECTION_PERSISTENT_TAILING); synchronized (list) { list.add(e.getMessage().getBody(Document.class)); } }); - from(String.format("mongodb:%s?database=test&collection=%s&consumerType=changeStreams&streamFilter=%s", - MongoDbResource.DEFAULT_MONGO_CLIENT_NAME, COLLECTION_STREAM_CHANGES, - "{'$match':{'$or':[{'fullDocument.string': 'value2'}]}}")) + fromF("mongodb:%s?database=test&collection=%s&consumerType=changeStreams&streamFilter=%s", + MongoDbConstants.DEFAULT_MONGO_CLIENT_NAME, MongoDbConstants.COLLECTION_STREAM_CHANGES, + "{'$match':{'$or':[{'fullDocument.string': 'value2'}]}}") .process(e -> { - final List<Document> list = results.get(COLLECTION_STREAM_CHANGES); + final List<Document> list = results.get(MongoDbConstants.COLLECTION_STREAM_CHANGES); synchronized (list) { list.add(e.getMessage().getBody(Document.class)); } @@ -78,9 +74,9 @@ public class MongoDbRoute extends RouteBuilder { @Named("results") Map<String, List<Document>> results() { Map<String, List<Document>> result = new HashMap<>(); - result.put(COLLECTION_TAILING, new LinkedList<>()); - result.put(COLLECTION_PERSISTENT_TAILING, new LinkedList<>()); - result.put(COLLECTION_STREAM_CHANGES, new LinkedList<>()); + result.put(MongoDbConstants.COLLECTION_TAILING, new LinkedList<>()); + result.put(MongoDbConstants.COLLECTION_PERSISTENT_TAILING, new LinkedList<>()); + result.put(MongoDbConstants.COLLECTION_STREAM_CHANGES, new LinkedList<>()); return result; } } diff --git a/integration-tests/mongodb/src/test/java/org/apache/camel/quarkus/component/mongodb/it/MongoDbIT.java b/integration-test-groups/mongodb/mongodb/src/test/java/org/apache/camel/quarkus/component/mongodb/it/MongoDbIT.java similarity index 100% copy from integration-tests/mongodb/src/test/java/org/apache/camel/quarkus/component/mongodb/it/MongoDbIT.java copy to integration-test-groups/mongodb/mongodb/src/test/java/org/apache/camel/quarkus/component/mongodb/it/MongoDbIT.java diff --git a/integration-tests/mongodb/src/test/java/org/apache/camel/quarkus/component/mongodb/it/MongoDbTest.java b/integration-test-groups/mongodb/mongodb/src/test/java/org/apache/camel/quarkus/component/mongodb/it/MongoDbTest.java similarity index 81% rename from integration-tests/mongodb/src/test/java/org/apache/camel/quarkus/component/mongodb/it/MongoDbTest.java rename to integration-test-groups/mongodb/mongodb/src/test/java/org/apache/camel/quarkus/component/mongodb/it/MongoDbTest.java index b62dc17..38eebad 100644 --- a/integration-tests/mongodb/src/test/java/org/apache/camel/quarkus/component/mongodb/it/MongoDbTest.java +++ b/integration-test-groups/mongodb/mongodb/src/test/java/org/apache/camel/quarkus/component/mongodb/it/MongoDbTest.java @@ -31,6 +31,8 @@ import io.restassured.RestAssured; import io.restassured.http.ContentType; import io.restassured.path.json.JsonPath; import org.apache.camel.ServiceStatus; +import org.apache.camel.quarkus.test.support.mongodb.MongoDbConstants; +import org.apache.camel.quarkus.test.support.mongodb.MongoDbTestResource; import org.apache.camel.util.CollectionHelper; import org.bson.Document; import org.eclipse.microprofile.config.ConfigProvider; @@ -41,9 +43,6 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; -import static org.apache.camel.quarkus.component.mongodb.it.MongoDbRoute.COLLECTION_PERSISTENT_TAILING; -import static org.apache.camel.quarkus.component.mongodb.it.MongoDbRoute.COLLECTION_STREAM_CHANGES; -import static org.apache.camel.quarkus.component.mongodb.it.MongoDbRoute.COLLECTION_TAILING; import static org.awaitility.Awaitility.await; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.not; @@ -57,7 +56,6 @@ class MongoDbTest { private static final Logger LOG = Logger.getLogger(MongoDbTest.class); public static final String MSG = "Hello Camel Quarkus Mongo DB"; - public static final int CAP_NUMBER = 1000; private static String COLLECTION_OUTPUT_TYPE_DOCUMENT_LIST = "outputTypeDocumentList"; private static String COLLECTION_OUTPUT_TYPE_DOCUMENT = "outputTypeDocument"; @@ -85,7 +83,7 @@ class MongoDbTest { } @ParameterizedTest - @ValueSource(strings = { MongoDbResource.DEFAULT_MONGO_CLIENT_NAME, MongoDbResource.NAMED_MONGO_CLIENT_NAME }) + @ValueSource(strings = { MongoDbConstants.DEFAULT_MONGO_CLIENT_NAME, MongoDbConstants.NAMED_MONGO_CLIENT_NAME }) public void testMongoDbComponent(String namedClient) { // As we will create a route for each client, we use a different collection for each route String collectionName = String.format("%sCamelTest", namedClient); @@ -126,7 +124,7 @@ class MongoDbTest { RestAssured.given() .contentType(ContentType.JSON) .body("{message:\"" + MSG + "\"}") - .header("mongoClientName", MongoDbResource.DEFAULT_MONGO_CLIENT_NAME) + .header("mongoClientName", MongoDbConstants.DEFAULT_MONGO_CLIENT_NAME) .post("/mongodb/collection/dynamic/" + collectionName) .then() .statusCode(200) @@ -136,7 +134,7 @@ class MongoDbTest { RestAssured.given() .contentType(ContentType.JSON) .body("{message:\"" + MSG + "\"}") - .header("mongoClientName", MongoDbResource.DEFAULT_MONGO_CLIENT_NAME) + .header("mongoClientName", MongoDbConstants.DEFAULT_MONGO_CLIENT_NAME) .header("dynamicOperation", "count") .post("/mongodb/collection/dynamic/" + collectionName) .then() @@ -147,43 +145,45 @@ class MongoDbTest { @Test public void testTailingConsumer() throws Exception { - MongoCollection collection = db.getCollection(COLLECTION_TAILING, Document.class); + MongoCollection collection = db.getCollection(MongoDbConstants.COLLECTION_TAILING, Document.class); - for (int i = 1; i <= (10 * CAP_NUMBER); i++) { + for (int i = 1; i <= (10 * MongoDbConstants.CAP_NUMBER); i++) { collection.insertOne(new Document("increasing", i).append("string", "value" + i)); //verify continuously - if (i % CAP_NUMBER == 0) { - waitAndResetTailingResults(CAP_NUMBER, "value" + i, COLLECTION_TAILING); + if (i % MongoDbConstants.CAP_NUMBER == 0) { + waitAndResetTailingResults(MongoDbConstants.CAP_NUMBER, "value" + i, MongoDbConstants.COLLECTION_TAILING); } } } @Test public void testPersistentTailingConsumer() throws Exception { - MongoCollection collection = db.getCollection(COLLECTION_PERSISTENT_TAILING, Document.class); + MongoCollection collection = db.getCollection(MongoDbConstants.COLLECTION_PERSISTENT_TAILING, Document.class); - for (int i = 1; i <= (3 * CAP_NUMBER); i++) { + for (int i = 1; i <= (3 * MongoDbConstants.CAP_NUMBER); i++) { collection.insertOne(new Document("increasing", i).append("string", "value" + i)); //verify continuously - if (i % CAP_NUMBER == 0) { - waitAndResetTailingResults(CAP_NUMBER, "value" + i, COLLECTION_PERSISTENT_TAILING); + if (i % MongoDbConstants.CAP_NUMBER == 0) { + waitAndResetTailingResults(MongoDbConstants.CAP_NUMBER, "value" + i, + MongoDbConstants.COLLECTION_PERSISTENT_TAILING); } } //restart route - routeController(COLLECTION_PERSISTENT_TAILING, "stop", null); - routeController(COLLECTION_PERSISTENT_TAILING, "status", ServiceStatus.Stopped.name()); - routeController(COLLECTION_PERSISTENT_TAILING, "start", null); - routeController(COLLECTION_PERSISTENT_TAILING, "status", ServiceStatus.Started.name()); + routeController(MongoDbConstants.COLLECTION_PERSISTENT_TAILING, "stop", null); + routeController(MongoDbConstants.COLLECTION_PERSISTENT_TAILING, "status", ServiceStatus.Stopped.name()); + routeController(MongoDbConstants.COLLECTION_PERSISTENT_TAILING, "start", null); + routeController(MongoDbConstants.COLLECTION_PERSISTENT_TAILING, "status", ServiceStatus.Started.name()); - for (int i = (3 * CAP_NUMBER + 1); i <= (6 * CAP_NUMBER); i++) { + for (int i = (3 * MongoDbConstants.CAP_NUMBER + 1); i <= (6 * MongoDbConstants.CAP_NUMBER); i++) { collection.insertOne(new Document("increasing", i).append("string", "value" + i)); //verify continuously - if (i % CAP_NUMBER == 0) { - waitAndResetTailingResults(CAP_NUMBER, "value" + i, COLLECTION_PERSISTENT_TAILING); + if (i % MongoDbConstants.CAP_NUMBER == 0) { + waitAndResetTailingResults(MongoDbConstants.CAP_NUMBER, "value" + i, + MongoDbConstants.COLLECTION_PERSISTENT_TAILING); } } } @@ -208,13 +208,13 @@ class MongoDbTest { @Test public void testStreamConsumerWithFilter() throws Exception { - MongoCollection collection = db.getCollection(COLLECTION_STREAM_CHANGES, Document.class); + MongoCollection collection = db.getCollection(MongoDbConstants.COLLECTION_STREAM_CHANGES, Document.class); for (int i = 1; i <= 10; i++) { collection.insertOne(new Document("increasing", i).append("string", "value" + i)); } - waitAndResetTailingResults(1, "value2", COLLECTION_STREAM_CHANGES); + waitAndResetTailingResults(1, "value2", MongoDbConstants.COLLECTION_STREAM_CHANGES); } @Test @@ -248,7 +248,7 @@ class MongoDbTest { List results = RestAssured .given() - .header("mongoClientName", MongoDbResource.DEFAULT_MONGO_CLIENT_NAME) + .header("mongoClientName", MongoDbConstants.DEFAULT_MONGO_CLIENT_NAME) .get("/mongodb/collectionAsList/" + COLLECTION_OUTPUT_TYPE_DOCUMENT_LIST) .then() .contentType(ContentType.JSON) @@ -270,7 +270,7 @@ class MongoDbTest { RestAssured .given() - .header("mongoClientName", MongoDbResource.DEFAULT_MONGO_CLIENT_NAME) + .header("mongoClientName", MongoDbConstants.DEFAULT_MONGO_CLIENT_NAME) .get("/mongodb/searchByNameAsDocument/" + COLLECTION_OUTPUT_TYPE_DOCUMENT + "/Sheldon") .then() .contentType(ContentType.JSON) diff --git a/integration-tests-support/pom.xml b/integration-test-groups/mongodb/pom.xml similarity index 56% copy from integration-tests-support/pom.xml copy to integration-test-groups/mongodb/pom.xml index c0eee65..17e2c3b 100644 --- a/integration-tests-support/pom.xml +++ b/integration-test-groups/mongodb/pom.xml @@ -22,33 +22,23 @@ <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-build-parent</artifactId> + <artifactId>camel-quarkus-integration-test-groups</artifactId> <version>2.3.0-SNAPSHOT</version> - <relativePath>../poms/build-parent/pom.xml</relativePath> </parent> - <artifactId>camel-quarkus-integration-tests-support</artifactId> + <artifactId>camel-quarkus-integration-tests-mongodb</artifactId> <packaging>pom</packaging> - <name>Camel Quarkus :: Integration Tests :: Support :: Parent</name> - <description>Ancillary modules required by some integration tests. Hosted outside the integration-tests directory - so that we can keep a flat hierarchy in the integration-tests directory. - </description> + <name>Camel Quarkus :: MongoDB Integration Tests</name> + + <properties> + <quarkus.banner.enabled>false</quarkus.banner.enabled> + </properties> <modules> - <module>activemq</module> - <module>aws2</module> - <module>azure</module> - <module>custom-dataformat</module> - <module>custom-log-component</module> - <module>custom-routes-collector</module> - <module>custom-type-converter</module> - <module>custom-main-listener</module> - <module>kafka</module> - <module>process-executor-support</module> - <module>test-support</module> - <module>mock-backend</module> - <module>wiremock</module> + <!-- extensions a..z; do not remove this comment, it is important when sorting via mvn process-resources -Pformat --> + <module>mongodb</module> + <module>mongodb-gridfs</module> </modules> </project> diff --git a/integration-tests-support/pom.xml b/integration-tests-support/mongodb/pom.xml similarity index 51% copy from integration-tests-support/pom.xml copy to integration-tests-support/mongodb/pom.xml index c0eee65..61819ca 100644 --- a/integration-tests-support/pom.xml +++ b/integration-tests-support/mongodb/pom.xml @@ -18,37 +18,41 @@ --> <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</artifactId> + <artifactId>camel-quarkus-integration-tests-support</artifactId> <version>2.3.0-SNAPSHOT</version> - <relativePath>../poms/build-parent/pom.xml</relativePath> + <relativePath>../pom.xml</relativePath> </parent> + <modelVersion>4.0.0</modelVersion> - <artifactId>camel-quarkus-integration-tests-support</artifactId> - <packaging>pom</packaging> - - <name>Camel Quarkus :: Integration Tests :: Support :: Parent</name> - <description>Ancillary modules required by some integration tests. Hosted outside the integration-tests directory - so that we can keep a flat hierarchy in the integration-tests directory. - </description> - - <modules> - <module>activemq</module> - <module>aws2</module> - <module>azure</module> - <module>custom-dataformat</module> - <module>custom-log-component</module> - <module>custom-routes-collector</module> - <module>custom-type-converter</module> - <module>custom-main-listener</module> - <module>kafka</module> - <module>process-executor-support</module> - <module>test-support</module> - <module>mock-backend</module> - <module>wiremock</module> - </modules> - + <artifactId>camel-quarkus-integration-tests-support-mongodb</artifactId> + <name>Camel Quarkus :: Integration Tests :: Support :: MongoDB</name> + + <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> + + <dependencies> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-mongodb-client</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-integration-test-support</artifactId> + </dependency> + <dependency> + <groupId>org.testcontainers</groupId> + <artifactId>testcontainers</artifactId> + </dependency> + </dependencies> </project> diff --git a/integration-tests/mongodb/src/test/java/org/apache/camel/quarkus/component/mongodb/it/MongoDbIT.java b/integration-tests-support/mongodb/src/main/java/org/apache/camel/quarkus/test/support/mongodb/MongoDbConstants.java similarity index 56% rename from integration-tests/mongodb/src/test/java/org/apache/camel/quarkus/component/mongodb/it/MongoDbIT.java rename to integration-tests-support/mongodb/src/main/java/org/apache/camel/quarkus/test/support/mongodb/MongoDbConstants.java index 2a6e146..09b0bf3 100644 --- a/integration-tests/mongodb/src/test/java/org/apache/camel/quarkus/component/mongodb/it/MongoDbIT.java +++ b/integration-tests-support/mongodb/src/main/java/org/apache/camel/quarkus/test/support/mongodb/MongoDbConstants.java @@ -14,11 +14,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.quarkus.component.mongodb.it; +package org.apache.camel.quarkus.test.support.mongodb; -import io.quarkus.test.junit.NativeImageTest; +public final class MongoDbConstants { -@NativeImageTest -class MongoDbIT extends MongoDbTest { + public static final String DEFAULT_MONGO_CLIENT_NAME = "camelMongoClient"; + public static final String NAMED_MONGO_CLIENT_NAME = "myMongoClient"; + public static final String COLLECTION_TAILING = "tailingCollection"; + public static final String COLLECTION_PERSISTENT_TAILING = "persistentTailingCollection"; + public static final String COLLECTION_STREAM_CHANGES = "streamChangesCollection"; + public static final int CAP_NUMBER = 1000; + private MongoDbConstants() { + // Utility class + } } diff --git a/integration-tests/mongodb/src/test/java/org/apache/camel/quarkus/component/mongodb/it/MongoDbTestResource.java b/integration-tests-support/mongodb/src/main/java/org/apache/camel/quarkus/test/support/mongodb/MongoDbTestResource.java similarity index 81% rename from integration-tests/mongodb/src/test/java/org/apache/camel/quarkus/component/mongodb/it/MongoDbTestResource.java rename to integration-tests-support/mongodb/src/main/java/org/apache/camel/quarkus/test/support/mongodb/MongoDbTestResource.java index d010295..4d77725 100644 --- a/integration-tests/mongodb/src/test/java/org/apache/camel/quarkus/component/mongodb/it/MongoDbTestResource.java +++ b/integration-tests-support/mongodb/src/main/java/org/apache/camel/quarkus/test/support/mongodb/MongoDbTestResource.java @@ -15,9 +15,10 @@ * limitations under the License. */ -package org.apache.camel.quarkus.component.mongodb.it; +package org.apache.camel.quarkus.test.support.mongodb; import java.nio.charset.StandardCharsets; +import java.util.HashMap; import java.util.Map; import com.mongodb.client.MongoClient; @@ -25,7 +26,6 @@ import com.mongodb.client.MongoClients; import com.mongodb.client.MongoDatabase; import com.mongodb.client.model.CreateCollectionOptions; import io.quarkus.test.common.QuarkusTestResourceLifecycleManager; -import org.apache.camel.util.CollectionHelper; import org.apache.commons.io.IOUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -62,11 +62,13 @@ public class MongoDbTestResource implements QuarkusTestResourceLifecycleManager setUpDb(); - return CollectionHelper.mapOf( - "quarkus.mongodb.hosts", - container.getContainerIpAddress() + ":" + container.getMappedPort(MONGODB_PORT).toString(), - "quarkus.mongodb." + MongoDbResource.NAMED_MONGO_CLIENT_NAME + ".connection-string", - "mongodb://" + container.getContainerIpAddress() + ":" + container.getMappedPort(MONGODB_PORT).toString()); + String host = container.getContainerIpAddress() + ":" + container.getMappedPort(MONGODB_PORT).toString(); + + Map<String, String> config = new HashMap<>(); + config.put("quarkus.mongodb.hosts", host); + config.put("quarkus.mongodb." + MongoDbConstants.NAMED_MONGO_CLIENT_NAME + ".connection-string", + "mongodb://" + host); + return config; } catch (Exception e) { throw new RuntimeException(e); } @@ -81,11 +83,13 @@ public class MongoDbTestResource implements QuarkusTestResourceLifecycleManager mongoClient = MongoClients.create(mongoUrl); MongoDatabase db = mongoClient.getDatabase("test"); - db.createCollection(MongoDbRoute.COLLECTION_TAILING, - new CreateCollectionOptions().capped(true).sizeInBytes(1000000000).maxDocuments(MongoDbTest.CAP_NUMBER)); - db.createCollection(MongoDbRoute.COLLECTION_PERSISTENT_TAILING, - new CreateCollectionOptions().capped(true).sizeInBytes(1000000000).maxDocuments(MongoDbTest.CAP_NUMBER)); - db.createCollection(MongoDbRoute.COLLECTION_STREAM_CHANGES); + db.createCollection(MongoDbConstants.COLLECTION_TAILING, + new CreateCollectionOptions().capped(true).sizeInBytes(1000000000) + .maxDocuments(MongoDbConstants.CAP_NUMBER)); + db.createCollection(MongoDbConstants.COLLECTION_PERSISTENT_TAILING, + new CreateCollectionOptions().capped(true).sizeInBytes(1000000000) + .maxDocuments(MongoDbConstants.CAP_NUMBER)); + db.createCollection(MongoDbConstants.COLLECTION_STREAM_CHANGES); } finally { if (mongoClient != null) { diff --git a/integration-tests-support/mongodb/src/main/resources/application.properties b/integration-tests-support/mongodb/src/main/resources/application.properties new file mode 100644 index 0000000..22e4308 --- /dev/null +++ b/integration-tests-support/mongodb/src/main/resources/application.properties @@ -0,0 +1,17 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- +quarkus.mongodb.devservices.enabled=false diff --git a/integration-tests/mongodb/src/test/resources/initMongodb.txt b/integration-tests-support/mongodb/src/main/resources/initMongodb.txt similarity index 100% rename from integration-tests/mongodb/src/test/resources/initMongodb.txt rename to integration-tests-support/mongodb/src/main/resources/initMongodb.txt diff --git a/integration-tests-support/pom.xml b/integration-tests-support/pom.xml index c0eee65..d208307 100644 --- a/integration-tests-support/pom.xml +++ b/integration-tests-support/pom.xml @@ -45,6 +45,7 @@ <module>custom-type-converter</module> <module>custom-main-listener</module> <module>kafka</module> + <module>mongodb</module> <module>process-executor-support</module> <module>test-support</module> <module>mock-backend</module> diff --git a/integration-tests/mongodb/pom.xml b/integration-tests/mongodb-grouped/pom.xml similarity index 56% rename from integration-tests/mongodb/pom.xml rename to integration-tests/mongodb-grouped/pom.xml index 3c2570c..f6b8175 100644 --- a/integration-tests/mongodb/pom.xml +++ b/integration-tests/mongodb-grouped/pom.xml @@ -18,19 +18,44 @@ --> <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>2.3.0-SNAPSHOT</version> </parent> + <modelVersion>4.0.0</modelVersion> - <artifactId>camel-quarkus-integration-test-mongodb</artifactId> - <name>Camel Quarkus :: Integration Tests :: MongoDB</name> - <description>Integration tests for Camel Quarkus MongoDB extension</description> + <artifactId>camel-quarkus-integration-test-mongodb-grouped</artifactId> + <name>Camel Quarkus :: Integration Tests :: MongoDB Grouped</name> + <description>MongoDB tests from ../integration-test-groups/mongodb merged together</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> + + <!-- Regenerate the dependencies via `mvn process-resources -Pformat -N` from the source tree root directory --> <dependencies> <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-resteasy</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-resteasy-jackson</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-resteasy-jsonb</artifactId> + </dependency> + <dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-mongodb</artifactId> </dependency> @@ -39,15 +64,9 @@ <artifactId>camel-quarkus-mongodb-gridfs</artifactId> </dependency> <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-resteasy</artifactId> - </dependency> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-resteasy-jsonb</artifactId> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-integration-tests-support-mongodb</artifactId> </dependency> - - <!-- test dependencies --> <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-junit5</artifactId> @@ -59,11 +78,6 @@ <scope>test</scope> </dependency> <dependency> - <groupId>org.testcontainers</groupId> - <artifactId>testcontainers</artifactId> - <scope>test</scope> - </dependency> - <dependency> <groupId>org.awaitility</groupId> <artifactId>awaitility</artifactId> <scope>test</scope> @@ -96,8 +110,64 @@ </exclusion> </exclusions> </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <executions> + <execution> + <id>add-sources</id> + <phase>generate-sources</phase> + <goals> + <goal>add-source</goal> + </goals> + <configuration> + <sources> + <source>${basedir}/target/src/main/java</source> + </sources> + </configuration> + </execution> + <execution> + <id>add-test-sources</id> + <phase>generate-sources</phase> + <goals> + <goal>add-test-source</goal> + </goals> + <configuration> + <sources> + <source>${basedir}/target/src/test/java</source> + </sources> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.codehaus.gmaven</groupId> + <artifactId>groovy-maven-plugin</artifactId> + <executions> + <execution> + <id>group-sources</id> + <goals> + <goal>execute</goal> + </goals> + <phase>generate-sources</phase> + <configuration> + <source>file:///${maven.multiModuleProjectDirectory}/tooling/scripts/group-tests.groovy</source> + <properties> + <group-tests.source.dir>${maven.multiModuleProjectDirectory}/integration-test-groups/mongodb</group-tests.source.dir> + <group-tests.dest.module.dir>${project.basedir}</group-tests.dest.module.dir> + <group-tests.concat.rel.paths>src/main/resources/application.properties</group-tests.concat.rel.paths> + </properties> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> <profiles> <profile> diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index e8d185c..08a83df 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -145,7 +145,7 @@ <module>microprofile</module> <module>minio</module> <module>mllp</module> - <module>mongodb</module> + <module>mongodb-grouped</module> <module>msv</module> <module>mustache</module> <module>nagios</module> diff --git a/poms/bom-test/pom.xml b/poms/bom-test/pom.xml index 17e7065..64608e9 100644 --- a/poms/bom-test/pom.xml +++ b/poms/bom-test/pom.xml @@ -114,6 +114,11 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-integration-tests-support-mongodb</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-integration-wiremock-support</artifactId> <version>${camel-quarkus.version}</version> </dependency> diff --git a/tooling/scripts/test-categories.yaml b/tooling/scripts/test-categories.yaml index 8131dfe..65ffda9 100644 --- a/tooling/scripts/test-categories.yaml +++ b/tooling/scripts/test-categories.yaml @@ -73,7 +73,7 @@ group-04: - kudu - leveldb - minio - - mongodb + - mongodb-grouped - sjms-artemis-client group-05: - avro