Package de.flapdoodle.embed.mongo

Examples of de.flapdoodle.embed.mongo.MongodExecutable


       
        if (this.proxyHost != null && this.proxyHost.length() > 0) {
            this.addProxySelector();
        }

        MongodExecutable executable;
        try {

            final ICommandLinePostProcessor commandLinePostProcessor;
            if (authEnabled) {
                commandLinePostProcessor = new ICommandLinePostProcessor() {
                    @Override
                    public List<String> process(final Distribution distribution, final List<String> args) {
                        args.remove("--noauth");
                        args.add("--auth");
                        return args;
                    }
                };
            } else {
                commandLinePostProcessor = new ICommandLinePostProcessor.Noop();
            }

            IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder()
                    .defaults(Command.MongoD)
                    .processOutput(getOutputConfig())
                    .artifactStore(getArtifactStore())
                    .commandLinePostProcessor(commandLinePostProcessor)
                    .build();

            if (randomPort) {
                port = PortUtils.allocateRandomPort();
            }
            savePortToProjectProperties();

            IMongodConfig config = new MongodConfigBuilder()
                    .version(getVersion()).net(new Net(bindIp, port, Network.localhostIsIPv6()))
                    .replication(new Storage(getDataDirectory(), null, 0))
                    .build();

            executable = MongodStarter.getInstance(runtimeConfig).prepare(config);
        } catch (UnknownHostException e) {
            throw new MojoExecutionException("Unable to determine if localhost is ipv6", e);
        } catch (DistributionException e) {
            throw new MojoExecutionException("Failed to download MongoDB distribution: " + e.withDistribution(), e);
        } catch (IOException e) {
            throw new MojoExecutionException("Unable to Config MongoDB: ", e);
        }

        try {
            MongodProcess mongod = executable.start();

            if (wait) {
                while (true) {
                    try {
                        TimeUnit.MINUTES.sleep(5);
View Full Code Here


        IMongodConfig mongodConfig = new MongodConfigBuilder()
            .version(Version.Main.V2_4)
            .net(new Net(PORT, Network.localhostIsIPv6()))
            .build();

        MongodExecutable mongodExecutable = starter.prepare(mongodConfig);
        mongod = mongodExecutable.start();
    } catch (IOException e) {
      throw new IllegalStateException(e);
    }
  }
View Full Code Here

  private DB db;

  @BeforeMethod
  public void setup() throws Exception {
      MongodStarter runtime = MongodStarter.getDefaultInstance();
      MongodExecutable mongodExe = runtime.prepare( new MongodConfig(Version.V2_3_0, 12345,
          Network.localhostIsIPv6()) );
      mongod = mongodExe.start();
      mongo = new Mongo("localhost", 12345);
      db = mongo.getDB(DATABASE_NAME);
  }
View Full Code Here

  public Statement apply(final Statement base, Description description) {
    return new Statement() {

      @Override
      public void evaluate() throws Throwable {
        MongodExecutable _mongodExe = runtime
            .prepare(new MongodConfigBuilder()
                .version(mongoVersion)
                .net(new Net(Integer.parseInt(mongoClientURI
                    .getURI().split(":")[2]), false))
                .build());
        MongodProcess _mongod = _mongodExe.start();
        MongoClient mongoClient = new MongoClient(mongoClientURI);

        base.evaluate();

        mongoClient.close();
        _mongod.stop();
        _mongodExe.stop();
      }
    };
  }
View Full Code Here

TOP

Related Classes of de.flapdoodle.embed.mongo.MongodExecutable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.