public class EmbeddedMongoBuilder extends Object
MongodStarter and
MongodExecutable with Slf4j as a logger (instead of JUL), then
starts "embedded" MongoDB and exposes preconfigured instance of
MongoClient. Due to Slf4j you use any logging implementation you want.
To tweak logging levels use these classes as logger names:
EmbedMongo runs MongoDB as a managed process. It is not truly embedded
Mongo as there's no Java implementation of the MongoDB. EmbedMongo actually
downloads an original MongoDB binary for your platform and executes it.
The EmbedMongo process is stopped automatically when you close connection with
Mongo.
| Constructor and Description |
|---|
EmbeddedMongoBuilder() |
| Modifier and Type | Method and Description |
|---|---|
EmbeddedMongoBuilder |
bindIp(String bindIp)
An IPv4 or IPv6 address for the MongoDB instance to be bound to during
its execution.
|
com.mongodb.MongoClient |
build()
Builds
MongodStarter, then starts "embedded" MongoDB instance
and returns initialized MongoClient. |
EmbeddedMongoBuilder |
port(int port)
The port MongoDB should run on.
|
EmbeddedMongoBuilder |
version(String version)
The version of MongoDB to run e.g.
|
EmbeddedMongoBuilder |
version(de.flapdoodle.embed.mongo.distribution.Version version)
The version of MongoDB to run.
|
public com.mongodb.MongoClient build()
throws IOException
MongodStarter, then starts "embedded" MongoDB instance
and returns initialized MongoClient.
You should invoke Mongo.close() after job is done to close
the client and stop the MongoDB instance.
IOExceptionpublic EmbeddedMongoBuilder version(de.flapdoodle.embed.mongo.distribution.Version version)
PRODUCTION is used by default.
The value must not be null.public EmbeddedMongoBuilder version(String version)
PRODUCTION
is used by default. The value must not be empty.public EmbeddedMongoBuilder port(int port)
public EmbeddedMongoBuilder bindIp(String bindIp)
Copyright © 2013–2014. All rights reserved.