de.flapdoodle.embed.process.config.IRuntimeConfig Java Examples
The following examples show how to use
de.flapdoodle.embed.process.config.IRuntimeConfig.
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 |
@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: MongoDb3TestRule.java From logging-log4j2 with Apache License 2.0 | 6 votes |
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 #3
Source File: MongoDb4TestRule.java From logging-log4j2 with Apache License 2.0 | 6 votes |
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 #4
Source File: EmbeddedClient.java From graviteeio-access-management with Apache License 2.0 | 6 votes |
@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 #5
Source File: PostgresDatabase.java From MegaSparkDiff with Apache License 2.0 | 6 votes |
public static void startPostgres() throws IOException { IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder() .defaults(Command.Postgres) .build(); PostgresStarter<PostgresExecutable, PostgresProcess> runtime = PostgresStarter.getInstance(runtimeConfig); PostgresConfig config = new PostgresConfig( () -> "9.6.3-1", new Net(), new Storage("src/test/resources/sample"), new Timeout(), new Credentials("username", "password")); PostgresExecutable exec = runtime.prepare(config); process = exec.start(); properties.setProperty("user", config.credentials().username()); properties.setProperty("password", config.credentials().password()); url = java.lang.String.format("jdbc:postgresql://%s:%s/%s", config.net().host(), config.net().port(), config.storage().dbName()); }
Example #6
Source File: PgRule.java From vertx-sql-client with Apache License 2.0 | 6 votes |
private static IRuntimeConfig useDomainSocketRunTimeConfig(IRuntimeConfig config, File sock) throws Exception { return new RunTimeConfigBase(config) { @Override public ICommandLinePostProcessor getCommandLinePostProcessor() { ICommandLinePostProcessor commandLinePostProcessor = config.getCommandLinePostProcessor(); return (distribution, args) -> { List<String> result = commandLinePostProcessor.process(distribution, args); if (result.get(0).endsWith("postgres")) { result = new ArrayList<>(result); result.add("-k"); result.add(sock.getAbsolutePath()); } return result; }; } }; }
Example #7
Source File: Environment.java From dremio-oss with Apache License 2.0 | 5 votes |
private final IRuntimeConfig newRuntimeConfig(Command command, boolean daemonProcess) { final StaticArtifactStore artifactStore = StaticArtifactStore.forCommand(command); resources.add(artifactStore); return new RuntimeConfigBuilder() .defaultsWithLogger(command, LoggerFactory.getLogger(MongoDBResource.class)) .artifactStore(artifactStore) .daemonProcess(daemonProcess) .build(); }
Example #8
Source File: EmbeddedSupplier.java From ndbc with Apache License 2.0 | 5 votes |
@Override public final DataSource<PreparedStatement, Row> get() { log.info("Starting embedded postgres " + version + " on port " + config.port()); final EmbeddedPostgres postgres = new EmbeddedPostgres(version); final IRuntimeConfig cached = cachedRuntimeConfig( Paths.get(System.getProperty("user.home"), ".ndbc", "embedded_postgres")); final String password = config.password().orElseGet(() -> { throw new UnsupportedOperationException("Embedded postgres requires a password"); }); try { postgres.start(cached, config.host(), config.port(), config.database().orElse(EmbeddedPostgres.DEFAULT_DB_NAME), config.user(), password, DEFAULT_ADD_PARAMS); } catch (final IOException e) { throw new RuntimeException(e); } Runtime.getRuntime().addShutdownHook(new Thread(() -> postgres.stop())); log.info("postgres " + version + " started"); final DataSource<PreparedStatement, Row> underlying = DataSource.fromConfig(config.embedded(Optional.empty())); return new ProxyDataSource<PreparedStatement, Row>(underlying) { @Override public Config config() { return EmbeddedSupplier.this.config; } }; }
Example #9
Source File: MongoClientTestConfiguration.java From mongodb-aggregate-query-support with Apache License 2.0 | 5 votes |
public MongoClientTestConfiguration() throws IOException { Command command = Command.MongoD; IDownloadConfig downloadConfig = new Mongo42xDownloadConfigBuilder().defaultsForCommand(command) .progressListener(new Slf4jProgressListener(LOGGER)) .build(); IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder().defaults(command) .artifactStore(new ExtractedArtifactStoreBuilder() .defaults(command) .download(downloadConfig)) .build(); final MongodStarter runtime = MongodStarter.getInstance(runtimeConfig); mongodExecutable = runtime.prepare(newMongodConfig(MongoDbVersion.V4_2_4)); startMongodExecutable(); }
Example #10
Source File: ReactiveMongoClientTestConfiguration.java From mongodb-aggregate-query-support with Apache License 2.0 | 5 votes |
public ReactiveMongoClientTestConfiguration() throws IOException { Command command = Command.MongoD; IDownloadConfig downloadConfig = new Mongo42xDownloadConfigBuilder().defaultsForCommand(command) .progressListener(new Slf4jProgressListener(LOGGER)) .build(); IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder().defaults(command) .artifactStore(new ExtractedArtifactStoreBuilder() .defaults(command) .download(downloadConfig)) .build(); final MongodStarter runtime = MongodStarter.getInstance(runtimeConfig); mongodExecutable = runtime.prepare(newMongodConfig(MongoDbVersion.V4_2_4)); startMongodExecutable(); }
Example #11
Source File: NonReactiveMongoClientTestConfiguration.java From mongodb-aggregate-query-support with Apache License 2.0 | 5 votes |
public NonReactiveMongoClientTestConfiguration() throws IOException { Command command = Command.MongoD; IDownloadConfig downloadConfig = new Mongo42xDownloadConfigBuilder().defaultsForCommand(command) .progressListener(new Slf4jProgressListener(LOGGER)) .build(); IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder().defaults(command) .artifactStore(new ExtractedArtifactStoreBuilder() .defaults(command) .download(downloadConfig)) .build(); final MongodStarter runtime = MongodStarter.getInstance(runtimeConfig); mongodExecutable = runtime.prepare(newMongodConfig(MongoDbVersion.V4_2_4)); startMongodExecutable(); }
Example #12
Source File: MongodManager.java From jpa-unit with Apache License 2.0 | 5 votes |
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 #13
Source File: EmbedMongoConfiguration.java From syndesis with Apache License 2.0 | 5 votes |
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 #14
Source File: Environment.java From dremio-oss with Apache License 2.0 | 4 votes |
private final IRuntimeConfig newRuntimeConfig(Command command) { return newRuntimeConfig(command, true); }
Example #15
Source File: Environment.java From dremio-oss with Apache License 2.0 | 4 votes |
private final IRuntimeConfig newToolRuntimeConfig(Command command) { return newRuntimeConfig(command, false); }
Example #16
Source File: PgRule.java From vertx-sql-client with Apache License 2.0 | 4 votes |
private RunTimeConfigBase(IRuntimeConfig config) { this.config = config; }
Example #17
Source File: MongoJavaRDDFT.java From deep-spark with Apache License 2.0 | 4 votes |
@BeforeSuite public static void init() throws IOException { Command command = Command.MongoD; try { Files.forceDelete(new File(DB_FOLDER_NAME)); } catch (Exception e) { } new File(DB_FOLDER_NAME).mkdirs(); IMongodConfig mongodConfig = new MongodConfigBuilder() .version(Version.Main.PRODUCTION) .configServer(false) .replication(new Storage(DB_FOLDER_NAME, null, 0)) .net(new Net(PORT, Network.localhostIsIPv6())) .cmdOptions(new MongoCmdOptionsBuilder() .syncDelay(10) .useNoPrealloc(true) .useSmallFiles(true) .useNoJournal(true) .build()) .build(); IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder() .defaults(command) .artifactStore(new ArtifactStoreBuilder() .defaults(command) .download(new DownloadConfigBuilder() .defaultsForCommand(command) .downloadPath("https://s3-eu-west-1.amazonaws.com/stratio-mongodb-distribution/"))) .build(); MongodStarter runtime = MongodStarter.getInstance(runtimeConfig); mongodExecutable = null; mongodExecutable = runtime.prepare(mongodConfig); mongod = mongodExecutable.start(); }