public static MongoContext create() {
    final String uri = System.getProperty("mongo");
    final Closer closer = Closer.create();
    if (uri != null) {
      // remote mongo server
      return new MongoContext(new MongoClient(new MongoClientURI(uri)), closer);
    }

    final MongoServer server = new MongoServer(new MemoryBackend());
    closer.register(new Closeable() {
      @Override
      public void close() throws IOException {
        server.shutdownNow();
      }
    });

    final MongoClient client = new MongoClient(new ServerAddress(server.bind()));
    final MongoContext context = new MongoContext(client, closer);
    return context;
  }
Drops all collections from a mongo database
mongo/test/org/immutables/mongo/fixture/MongoContext.java