gnodet-bot commented on code in PR #27794: URL: https://github.com/apache/camel/pull/27794#discussion_r4277926851
########## components/camel-mongodb-gridfs/src/test/java/org/apache/camel/component/mongodb/gridfs/GridFsConsumerTimestampTest.java: ########## @@ -0,0 +1,297 @@ +/* + * 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.component.mongodb.gridfs; + +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.List; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +import com.mongodb.MongoClientSettings; +import com.mongodb.client.FindIterable; +import com.mongodb.client.MongoCollection; +import com.mongodb.client.MongoCursor; +import com.mongodb.client.MongoDatabase; +import com.mongodb.client.gridfs.GridFSBucket; +import com.mongodb.client.gridfs.GridFSDownloadStream; +import com.mongodb.client.gridfs.GridFSFindIterable; +import com.mongodb.client.gridfs.model.GridFSFile; +import com.mongodb.client.model.FindOneAndUpdateOptions; +import org.apache.camel.CamelContext; +import org.apache.camel.Processor; +import org.apache.camel.impl.DefaultCamelContext; +import org.bson.BsonArray; +import org.bson.BsonDocument; +import org.bson.BsonObjectId; +import org.bson.BsonValue; +import org.bson.Document; +import org.bson.conversions.Bson; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +/** + * The consumer with a timestamp query strategy against a fake bucket that answers the upload date query of each poll + * the way MongoDB does: a file that was routed must not be routed again by the following polls. With a file attribute, + * the fake files collection marks a file as the consumer asks, and the bucket no longer returns a marked file. + */ +class GridFsConsumerTimestampTest { Review Comment: 💡 **Minor:** Consider adding a class-level `@Timeout` annotation to prevent the entire test class from hanging indefinitely if something goes wrong before an `await()` call: ```suggestion @Timeout(60) class GridFsConsumerTimestampTest { ``` The `TIMEOUT_SECONDS = 20` guard covers individual `CountDownLatch.await()` calls, but a class-level timeout catches unexpected hangs earlier than the Surefire fork timeout. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
