@Override
public Repository[] setUpCluster(int n) throws Exception {
Repository[] cluster = new Repository[n];
stores = new MongoNodeStore[cluster.length];
for (int i = 0; i < cluster.length; i++) {
MongoConnection mongo =
new MongoConnection(host, port, dbName);
stores[i] = new MongoMK.Builder().
setMongoDB(mongo.getDB()).
memoryCacheSize(cacheSize).
setClusterId(i).setLogging(false).getNodeStore();
Oak oak = new Oak(stores[i]);
cluster[i] = new Jcr(oak).createRepository();
}
return cluster;
}
@Override
public void tearDownCluster() {
for (MongoNodeStore store : stores) {
store.dispose();
}
if (dropDBAfterTest) {
try {
MongoConnection mongo =
new MongoConnection(host, port, dbName);
mongo.getDB().dropDatabase();
mongo.close();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}