public void start(final int port) {
        var starter = MongodStarter.getDefaultInstance();

        try {
            var mongodConfig = MongodConfig.builder()
                    .version(Version.Main.PRODUCTION)
                    .net(new Net(port, Network.localhostIsIPv6()))
                    .build();

            mongodExecutable = starter.prepare(mongodConfig);
            mongodExecutable.start();

            // populate
            val mongo = MongoClients.create(String.format("mongodb://localhost:%d", port));
            val db = mongo.getDatabase("users");
            db.createCollection("users");
            val collection = db.getCollection("users");
            val password = PASSWORD_ENCODER.encode(PASSWORD);
            Map<String, Object> properties1 = new HashMap<>();
            properties1.put(USERNAME, GOOD_USERNAME);
            properties1.put(PASSWORD, password);
            properties1.put(FIRSTNAME, FIRSTNAME_VALUE);
            collection.insertOne(new Document(properties1));
            Map<String, Object> properties2 = new HashMap<>();
            properties2.put(USERNAME, MULTIPLE_USERNAME);
            properties2.put(PASSWORD, password);
            collection.insertOne(new Document(properties2));
            Map<String, Object> properties3 = new HashMap<>();
            properties3.put(USERNAME, MULTIPLE_USERNAME);
            properties3.put(PASSWORD, password);
            collection.insertOne(new Document(properties3));

        } catch (final IOException e) {
            throw new RuntimeException(e);
        }
    }
Simulates a MongoDB server.

@author Jerome Leleu
@since 1.8.0
pac4j-mongo/src/test/java/org/pac4j/mongo/test/tools/MongoServer.java