de.flapdoodle.embed.mongo.MongodProcess Java Examples

The following examples show how to use de.flapdoodle.embed.mongo.MongodProcess. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DevelopmentConfig.java    From entref-spring-boot with MIT License 5 votes vote down vote up
/**
 * Attempts to start a mongo instance, using embedMongo
 * @param bind the net info to bind to
 * @return the instance
 * @throws IOException indicates a failure
 */
private MongodExecutable setupMongoEmbed(Net bind) throws IOException {
    MongodStarter starter;
    starter = MongodStarter.getDefaultInstance();

    IMongodConfig mongodConfig = new MongodConfigBuilder()
            .version(Version.Main.DEVELOPMENT)
            .net(bind)
            .build();

    MongodExecutable mongodExecutable = starter.prepare(mongodConfig);
    MongodProcess mongod = mongodExecutable.start();
    return mongodExecutable;
}
 
Example #2
Source File: MongoDbResource.java    From ditto with Eclipse Public License 2.0 5 votes vote down vote up
private static MongodProcess tryToStartMongoDb(final MongodExecutable mongodExecutable) {
    try {
        return mongodExecutable.start();
    } catch (final IOException e) {
        throw new IllegalStateException("Failed to start MongoDB!", e);
    }
}
 
Example #3
Source File: MongoDataSourceTest.java    From vertx-service-discovery with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void beforeClass() throws Exception {
  MongodStarter runtime = MongodStarter.getDefaultInstance();
  mongodExe = runtime.prepare(
    new MongodConfigBuilder().version(Version.V3_3_1)
      .net(new Net(12345, Network.localhostIsIPv6()))
      .build());
  MongodProcess process = mongodExe.start();
  await().until(() -> process != null);
}
 
Example #4
Source File: PolyglotUsageTest.java    From vertx-service-discovery with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void beforeClass() throws Exception {
  MongodStarter runtime = MongodStarter.getDefaultInstance();
  mongodExe = runtime.prepare(
    new MongodConfigBuilder().version(Version.V3_3_1)
      .net(new Net(12345, Network.localhostIsIPv6()))
      .build());
  MongodProcess process = mongodExe.start();
  await().until(() -> process != null);
}
 
Example #5
Source File: MongodManager.java    From jpa-unit with Apache License 2.0 5 votes vote down vote up
private void startMongo(final List<IMongodConfig> mongodConfigList) throws IOException {
    // @formatter:off
    final ProcessOutput processOutput = new ProcessOutput(
            logTo(LOGGER, Slf4jLevel.INFO),
            logTo(LOGGER, Slf4jLevel.ERROR),
            named("[console>]", logTo(LOGGER, Slf4jLevel.DEBUG)));

    final IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder()
            .defaultsWithLogger(Command.MongoD,LOGGER)
            .processOutput(processOutput)
            .artifactStore(new ExtractedArtifactStoreBuilder()
                .defaults(Command.MongoD)
                .download(new DownloadConfigBuilder()
                    .defaultsForCommand(Command.MongoD)
                    .progressListener(new Slf4jProgressListener(LOGGER))
                    .build()))
            .build();
    // @formatter:on
    final MongodStarter starter = MongodStarter.getInstance(runtimeConfig);

    for (final IMongodConfig mongodConfig : mongodConfigList) {
        final MongodExecutable mongodExecutable = starter.prepare(mongodConfig);
        final MongodProcess mongod = mongodExecutable.start();

        mongoProcesses.put(mongod, mongodExecutable);
    }
}
 
Example #6
Source File: MongosSystemForTestFactory.java    From spring-data-examples with Apache License 2.0 5 votes vote down vote up
private void initializeConfigServer(IMongodConfig config) throws Exception {
	if (!config.isConfigServer()) {
		throw new Exception(
				"Mongo configuration is not a defined for a config server.");
	}
	MongodStarter starter = MongodStarter.getDefaultInstance();
	MongodExecutable mongodExe = starter.prepare(config);
	MongodProcess process = mongodExe.start();
	mongodProcessList.add(process);
}
 
Example #7
Source File: MongoDb4TestRule.java    From logging-log4j2 with Apache License 2.0 4 votes vote down vote up
public MongodProcess getMongodProcess() {
    return mongodProcess;
}
 
Example #8
Source File: MongoDb3TestRule.java    From logging-log4j2 with Apache License 2.0 4 votes vote down vote up
public MongodProcess getMongodProcess() {
    return mongodProcess;
}