use of com.mongodb.internal.connection.TestConnectionPoolListener in project mongo-java-driver by mongodb.
the class ConnectionsSurvivePrimaryStepDownProseTest method setUp.
@Before
public void setUp() {
assumeTrue(isDiscoverableReplicaSet() && serverVersionAtLeast(4, 0));
connectionPoolListener = new TestConnectionPoolListener();
MongoClientSettings settings = MongoClientSettings.builder(getMongoClientSettings()).retryWrites(false).applyToConnectionPoolSettings(new Block<ConnectionPoolSettings.Builder>() {
@Override
public void apply(final ConnectionPoolSettings.Builder builder) {
builder.addConnectionPoolListener(connectionPoolListener);
}
}).build();
collectionHelper = new CollectionHelper<Document>(new DocumentCodec(), new MongoNamespace(getDefaultDatabaseName(), COLLECTION_NAME));
client = MongoClients.create(settings);
MongoDatabase database = client.getDatabase(getDefaultDatabaseName());
collection = client.getDatabase(getDefaultDatabaseName()).getCollection(COLLECTION_NAME);
collection.withWriteConcern(WriteConcern.MAJORITY).drop();
database.withWriteConcern(WriteConcern.MAJORITY).createCollection(COLLECTION_NAME);
}
Aggregations