protected void clearMongoDB(MongoDBRepositoryDescriptor descriptor) throws UnknownHostException { MongoClient mongoClient = MongoDBRepository.newMongoClient(descriptor); try { DBCollection coll = MongoDBRepository.getCollection(descriptor, mongoClient); coll.dropIndexes(); coll.remove(new BasicDBObject()); coll = MongoDBRepository.getCountersCollection(descriptor, mongoClient); coll.dropIndexes(); coll.remove(new BasicDBObject()); } finally { mongoClient.close(); } }