|
24 | 24 | import com.mongodb.internal.connection.TestCommandListener; |
25 | 25 | import com.mongodb.internal.connection.TestConnectionPoolListener; |
26 | 26 | import com.mongodb.lang.Nullable; |
| 27 | +import org.bson.BsonBoolean; |
27 | 28 | import org.bson.BsonDocument; |
28 | 29 | import org.junit.jupiter.api.AfterEach; |
29 | 30 | import org.junit.jupiter.api.Assertions; |
|
45 | 46 | import static com.mongodb.assertions.Assertions.assertTrue; |
46 | 47 | import static java.util.Optional.ofNullable; |
47 | 48 | import static org.junit.jupiter.api.Assertions.assertEquals; |
| 49 | +import static org.junit.jupiter.api.Assertions.assertFalse; |
48 | 50 | import static org.junit.jupiter.api.Assumptions.assumeFalse; |
49 | 51 |
|
50 | 52 | /** |
@@ -333,6 +335,25 @@ void testEmptyStringsAreConsideredUnsetWhenAppendingMetadataIdenticalToInitialMe |
333 | 335 | } |
334 | 336 | } |
335 | 337 |
|
| 338 | + @DisplayName("Test 9: Handshake documents include backpressure: true") |
| 339 | + @Test |
| 340 | + void testHandshakeDocumentsIncludeBackpressureTrue() { |
| 341 | + try (MongoClient mongoClient = createMongoClient(null, getMongoClientSettings())) { |
| 342 | + commandListener.reset(); |
| 343 | + mongoClient.getDatabase("admin").runCommand(BsonDocument.parse("{ping: 1}")); |
| 344 | + |
| 345 | + List<CommandStartedEvent> handshakeEvents = commandListener.getCommandStartedEvents("isMaster"); |
| 346 | + assertFalse(handshakeEvents.isEmpty(), "Expected at least one handshake document to be captured"); |
| 347 | + for (CommandStartedEvent event : handshakeEvents) { |
| 348 | + BsonDocument helloCommand = event.getCommand(); |
| 349 | + assertTrue(helloCommand.containsKey("backpressure"), |
| 350 | + "Handshake document is missing 'backpressure' field"); |
| 351 | + assertEquals(BsonBoolean.TRUE, helloCommand.getBoolean("backpressure"), |
| 352 | + "Handshake document 'backpressure' field is not true"); |
| 353 | + } |
| 354 | + } |
| 355 | + } |
| 356 | + |
336 | 357 | public static Stream<Arguments> provideDriverInformation() { |
337 | 358 | return Stream.of( |
338 | 359 | Arguments.of(new DriverInformation("framework", "2.0", "Framework Platform")), |
|
0 commit comments