use of com.mongodb.internal.connection.TestCommandListener in project mongo-java-driver by mongodb.
the class CommandMonitoringTest method beforeClass.
@BeforeClass
public static void beforeClass() {
commandListener = new TestCommandListener();
mongoClient = MongoClients.create(getMongoClientSettingsBuilder().retryWrites(false).addCommandListener(commandListener).build());
}
use of com.mongodb.internal.connection.TestCommandListener in project mongo-java-driver by mongodb.
the class ReadConcernTest method setUp.
@Before
public void setUp() {
assumeTrue(canRunTests());
commandListener = new TestCommandListener();
mongoClient = MongoClients.create(getMongoClientSettingsBuilder().addCommandListener(commandListener).applyToSocketSettings(new Block<SocketSettings.Builder>() {
@Override
public void apply(final SocketSettings.Builder builder) {
builder.readTimeout(5, TimeUnit.SECONDS);
}
}).build());
}
use of com.mongodb.internal.connection.TestCommandListener in project mongo-java-driver by mongodb.
the class UnifiedTest method executeAssertLsidOnLastTwoCommands.
private OperationResult executeAssertLsidOnLastTwoCommands(final BsonDocument operation, final boolean same) {
TestCommandListener listener = entities.getClientCommandListener(operation.getDocument("arguments").getString("client").getValue());
List<CommandEvent> events = lastTwoCommandEvents(listener);
String eventsJson = listener.getCommandStartedEvents().stream().map(e -> ((CommandStartedEvent) e).getCommand().toJson()).collect(Collectors.joining(", "));
BsonDocument expected = ((CommandStartedEvent) events.get(0)).getCommand().getDocument("lsid");
BsonDocument actual = ((CommandStartedEvent) events.get(1)).getCommand().getDocument("lsid");
if (same) {
assertEquals(eventsJson, expected, actual);
} else {
assertNotEquals(eventsJson, expected, actual);
}
return OperationResult.NONE;
}
use of com.mongodb.internal.connection.TestCommandListener in project mongo-java-driver by mongodb.
the class BatchCursorFluxTest method setUp.
@BeforeEach
public void setUp() {
commandListener = new TestCommandListener(singletonList("commandStartedEvent"), asList("insert", "killCursors"));
MongoClientSettings mongoClientSettings = getMongoClientBuilderFromConnectionString().addCommandListener(commandListener).build();
client = MongoClients.create(mongoClientSettings);
collection = client.getDatabase(getDefaultDatabaseName()).getCollection(getClass().getName());
drop(collection.getNamespace());
}
use of com.mongodb.internal.connection.TestCommandListener in project mongo-java-driver by mongodb.
the class ReadConcernTest method setUp.
@Before
public void setUp() {
assumeTrue(canRunTests());
commandListener = new TestCommandListener();
mongoClient = MongoClients.create(getMongoClientBuilderFromConnectionString().addCommandListener(commandListener).build());
}
Aggregations