de.flapdoodle.embed.process.config.io.ProcessOutput Java Examples

The following examples show how to use de.flapdoodle.embed.process.config.io.ProcessOutput. 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: EmbeddedClient.java    From graviteeio-access-management with Apache License 2.0 6 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {

    final IMongodConfig mongodConfig = new MongodConfigBuilder()
            .version(Version.Main.PRODUCTION).build();

    IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder()
            .defaultsWithLogger(Command.MongoD, logger)
            .processOutput(ProcessOutput.getDefaultInstanceSilent())
            .build();

    MongodStarter runtime = MongodStarter.getInstance(runtimeConfig);

    MongodExecutable mongodExecutable = runtime.prepare(mongodConfig);
    mongod = mongodExecutable.start();

    // cluster configuration
    ClusterSettings clusterSettings = ClusterSettings.builder().hosts(Collections.singletonList(new ServerAddress(mongodConfig.net().getServerAddress().getHostName(), mongodConfig.net().getPort()))).build();
    // codec configuration
    CodecRegistry pojoCodecRegistry = fromRegistries(MongoClients.getDefaultCodecRegistry(),
            fromProviders(PojoCodecProvider.builder().automatic(true).build()));

    MongoClientSettings settings = MongoClientSettings.builder().clusterSettings(clusterSettings).codecRegistry(pojoCodecRegistry).writeConcern(WriteConcern.ACKNOWLEDGED).build();
    mongoClient = MongoClients.create(settings);
    mongoDatabase = mongoClient.getDatabase(databaseName);
}
 
Example #2
Source File: EmbeddedClient.java    From graviteeio-access-management with Apache License 2.0 6 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {
    final IMongodConfig mongodConfig = new MongodConfigBuilder()
            .version(Version.Main.PRODUCTION).build();

    IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder()
            .defaultsWithLogger(Command.MongoD, logger)
            .processOutput(ProcessOutput.getDefaultInstanceSilent())
            .build();

    MongodStarter runtime = MongodStarter.getInstance(runtimeConfig);

    MongodExecutable mongodExecutable = runtime.prepare(mongodConfig);
    mongod = mongodExecutable.start();

    // cluster configuration
    ClusterSettings clusterSettings = ClusterSettings.builder().hosts(Collections.singletonList(new ServerAddress(mongodConfig.net().getServerAddress().getHostName(), mongodConfig.net().getPort()))).build();
    // codec configuration
    CodecRegistry pojoCodecRegistry = fromRegistries(MongoClients.getDefaultCodecRegistry(),
            fromProviders(PojoCodecProvider.builder().automatic(true).build()));

    MongoClientSettings settings = MongoClientSettings.builder().clusterSettings(clusterSettings).codecRegistry(pojoCodecRegistry).writeConcern(WriteConcern.ACKNOWLEDGED).build();
    mongoClient = MongoClients.create(settings);
    mongoDatabase = mongoClient.getDatabase(databaseName);
}
 
Example #3
Source File: EmbeddedMongo.java    From spring-data-examples with Apache License 2.0 6 votes vote down vote up
ReplSet(IFeatureAwareVersion serverVersion, String replicaSetName, boolean silent, Integer... serverPorts) {

			this.serverVersion = serverVersion;
			this.replicaSetName = replicaSetName;
			this.serverPorts = defaultPortsIfRequired(serverPorts);
			this.configServerPorts = defaultPortsIfRequired(null);
			this.configServerReplicaSetName = DEFAULT_CONFIG_SERVER_REPLICA_SET_NAME;
			this.mongosPort = randomOrDefaultServerPort();

			if (silent) {
				outputFunction = it -> new ProcessOutput(Processors.silent(),
						Processors.namedConsole("[ " + it.commandName() + " error]"), Processors.console());
			} else {
				outputFunction = it -> ProcessOutput.getDefaultInstance(it.commandName());
			}
		}
 
Example #4
Source File: MongoDb4TestRule.java    From logging-log4j2 with Apache License 2.0 6 votes vote down vote up
private static MongodStarter getMongodStarter(final LoggingTarget loggingTarget) {
    if (loggingTarget == null) {
        return MongodStarter.getDefaultInstance();
    }
    switch (loggingTarget) {
    case NULL:
        final Logger logger = LoggerFactory.getLogger(MongoDb4TestRule.class.getName());
        final IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder()
        // @formatter:off
                .defaultsWithLogger(Command.MongoD, logger).processOutput(ProcessOutput.getDefaultInstanceSilent())
                .build();
        // @formatter:on

        return MongodStarter.getInstance(runtimeConfig);
    case CONSOLE:
        return MongodStarter.getDefaultInstance();
    default:
        throw new NotImplementedException(loggingTarget.toString());
    }
}
 
Example #5
Source File: MongoDb3TestRule.java    From logging-log4j2 with Apache License 2.0 6 votes vote down vote up
private static MongodStarter getMongodStarter(final LoggingTarget loggingTarget) {
    if (loggingTarget == null) {
        return MongodStarter.getDefaultInstance();
    }
    switch (loggingTarget) {
    case NULL:
        final Logger logger = LoggerFactory.getLogger(MongoDb3TestRule.class.getName());
        final IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder()
        // @formatter:off
            .defaultsWithLogger(Command.MongoD, logger)
            .processOutput(ProcessOutput.getDefaultInstanceSilent())
            .build();
        // @formatter:on

        return MongodStarter.getInstance(runtimeConfig);
    case CONSOLE:
        return MongodStarter.getDefaultInstance();
    default:
        throw new NotImplementedException(loggingTarget.toString());
    }
}
 
Example #6
Source File: EmbedMongoConfiguration.java    From syndesis with Apache License 2.0 5 votes vote down vote up
private static void startEmbeddedMongo() {
    final IStreamProcessor logDestination = new Slf4jStreamProcessor(LoggerFactory.getLogger("embeddeddmongo"), Slf4jLevel.INFO);
    final IStreamProcessor daemon = Processors.named("mongod", logDestination);
    final IStreamProcessor error = Processors.named("mongod-error", logDestination);
    final IStreamProcessor command = Processors.named("mongod-command", logDestination);
    final ProcessOutput processOutput = new ProcessOutput(daemon, error, command);
    final IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder()
        .defaults(Command.MongoD)
        .artifactStore(new ExtractedArtifactStoreBuilder()
            .defaults(Command.MongoD)
            .extractDir(new FixedPath(".extracted"))
            .download(new DownloadConfigBuilder()
                .defaultsForCommand(Command.MongoD)
                .artifactStorePath(new FixedPath(".cache"))
                .build())
            .build())
        .processOutput(processOutput)
        .build();

    try {
        final IMongodConfig mongodConfig = createEmbeddedMongoConfiguration();

        final MongodExecutable mongodExecutable = MongodStarter.getInstance(runtimeConfig)
            .prepare(mongodConfig);


        mongodExecutable.start();
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
 
Example #7
Source File: MongoDbResource.java    From ditto with Eclipse Public License 2.0 5 votes vote down vote up
private static MongodExecutable configureMongoDb(final String bindIp,
        final int mongoDbPort,
        final IProxyFactory proxyFactory,
        final Logger logger) throws IOException {

    final Command command = Command.MongoD;

    final ProcessOutput processOutput;
    if (logger != null) {
        processOutput = ProcessOutput.getInstance("mongod", logger);
    } else {
        processOutput = ProcessOutput.getDefaultInstanceSilent();
    }

    final MongodStarter mongodStarter = MongodStarter.getInstance(new RuntimeConfigBuilder()
            .defaults(command)
            .processOutput(processOutput)
            .artifactStore(new ExtractedArtifactStoreBuilder()
                    .defaults(command)
                    .download(new DownloadConfigBuilder()
                            .defaultsForCommand(command)
                            .proxyFactory(proxyFactory)
                            .progressListener(new StandardConsoleProgressListener())
                            .build()))
            .build());

    return mongodStarter.prepare(new MongodConfigBuilder()
            .net(new Net(bindIp, mongoDbPort, false))
            .version(Version.Main.V3_6)
            .cmdOptions(new MongoCmdOptionsBuilder()
                    .useStorageEngine("wiredTiger")
                    .useNoJournal(false)
                    .build())
            .build());
}
 
Example #8
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 #9
Source File: MongosSystemForTestFactory.java    From spring-data-examples with Apache License 2.0 5 votes vote down vote up
public MongosSystemForTestFactory(IMongosConfig config,
								  Map<String, List<IMongodConfig>> replicaSets,
								  List<IMongodConfig> configServers, String shardDatabase,
								  String shardCollection, String shardKey, Function<Command, ProcessOutput> outputFunction) {
	this.config = config;
	this.replicaSets = replicaSets;
	this.configServers = configServers;
	this.shardDatabase = shardDatabase;
	this.shardCollection = shardCollection;
	this.shardKey = shardKey;
	this.outputFunction = outputFunction;
}
 
Example #10
Source File: PgRule.java    From vertx-sql-client with Apache License 2.0 4 votes vote down vote up
@Override
public ProcessOutput getProcessOutput() {
  return config.getProcessOutput();
}