lundi 9 novembre 2015

How can I run flapdoodle MongodStarter with --auth option

I recently configured my mongoDB to use --auth while starting the process.

Now I need to change the accessing Javacode and the tests. For the tests I am using flapdoodle tools like MongodStarter.

There are some example codes at http://ift.tt/1lhU04G

But I still need help to build the correct code to start the MongodStarter with the --auth option. For example I could do this

MongodStarter runtime = MongodStarter.getDefaultInstance();
    IMongoCmdOptions cmdOptions = new MongoCmdOptionsBuilder.MongoCmdOptions(null, null, true, false, false, false, false, true, true)
    def mongodConfig = new MongodConfigBuilder.ImmutableMongodConfig(Version.V3_0_4, new Net(27017, Network.localhostIsIPv6()),new Timeout(), cmdOptions, "CT.pid", new Storage(), false, null, new HashMap())
    mongodExe = runtime.prepare(mongodConfig);
    mongod = mongodExe.start();
    mongo = new Mongo("localhost", 27017);

But in the .MongoCmdOptions()-method there are a lot of parameters, which I don't care about and don't know suitable values. Only the 8th is the one, that I want to use. It is the --auth param. Filling the others with some values, I get exceptions.

A similar problem I have with MongodConfigBuilder.ImmutableMongodConfig(). I put some fantasy values to it, because there are a lot.

Can you give me a working example configuration I can test with? I crafted for some days now, but still didn't find a good combination of configuration types and values. I could imagine, that there is a simpler way, but I could not find an example.

Aucun commentaire:

Enregistrer un commentaire