use of de.flapdoodle.embed.mongo.config.RuntimeConfigBuilder in project gora by apache.
the class GoraMongodbTestDriver method setUpClass.
/**
* Initiate the MongoDB server on the default port
*/
@Override
public void setUpClass() throws IOException {
IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder().defaultsWithLogger(Command.MongoD, log).processOutput(ProcessOutput.getDefaultInstanceSilent()).build();
MongodStarter runtime = MongodStarter.getInstance(runtimeConfig);
int port = Network.getFreeServerPort();
IMongodConfig mongodConfig = new MongodConfigBuilder().version(version).net(new Net(port, Network.localhostIsIPv6())).build();
// Store Mongo server "host:port" in Hadoop configuration
// so that MongoStore will be able to get it latter
conf.set(MongoStoreParameters.PROP_MONGO_SERVERS, "127.0.0.1:" + port);
log.info("Starting embedded Mongodb server on {} port.", port);
try {
_mongodExe = runtime.prepare(mongodConfig);
_mongod = _mongodExe.start();
_mongo = new MongoClient("localhost", port);
} catch (Exception e) {
log.error("Error starting embedded Mongodb server... tearing down test driver.");
tearDownClass();
}
}
Aggregations