use of com.antwerkz.bottlerocket.clusters.ReplicaSet in project morphia by mongodb.
the class TestBase method startMongo.
private void startMongo() {
String mongodb = System.getenv("MONGODB");
Builder builder = MongoClientSettings.builder();
try {
builder.uuidRepresentation(mapperOptions.getUuidRepresentation());
} catch (Exception ignored) {
// not a 4.0 driver
}
if (mongodb != null) {
File mongodbRoot = new File("target/mongo");
try {
FileUtils.deleteDirectory(mongodbRoot);
} catch (IOException e) {
throw new RuntimeException(e.getMessage(), e);
}
Version version = Version.valueOf(mongodb);
final MongoCluster cluster = version.lessThan(Version.valueOf("4.0.0")) ? new SingleNode(mongodbRoot, "morphia_test", version) : new ReplicaSet(mongodbRoot, "morphia_test", version);
cluster.configure(c -> {
c.systemLog(s -> {
s.setTraceAllExceptions(true);
s.setVerbosity(Verbosity.FIVE);
return null;
});
return null;
});
cluster.clean();
cluster.start();
mongoClient = cluster.getClient(builder);
} else {
mongoClient = MongoClients.create(builder.build());
}
}
Aggregations