本文整理汇总了Java中de.flapdoodle.embed.process.config.io.ProcessOutput类的典型用法代码示例。如果您正苦于以下问题:Java ProcessOutput类的具体用法?Java ProcessOutput怎么用?Java ProcessOutput使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ProcessOutput类属于de.flapdoodle.embed.process.config.io包,在下文中一共展示了ProcessOutput类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runtimeConfig
import de.flapdoodle.embed.process.config.io.ProcessOutput; //导入依赖的package包/类
private IRuntimeConfig runtimeConfig()
{
FixedPath path = new FixedPath( "bin/" );
IStreamProcessor mongodOutput;
IStreamProcessor mongodError;
IStreamProcessor commandsOutput;
try
{
mongodOutput = Processors.named( "[mongod>]", new FileStreamProcessor( new File( logPath, "mongo.log" ) ) );
mongodError = new FileStreamProcessor( new File( logPath, "mongo-err.log" ) );
commandsOutput =
Processors.named( "[mongod>]", new FileStreamProcessor( new File( logPath, "mongo.log" ) ) );
}
catch ( FileNotFoundException e )
{
throw Throwables.propagate( e );
}
return new RuntimeConfigBuilder().defaults( Command.MongoD )
.processOutput( new ProcessOutput( mongodOutput, mongodError, commandsOutput ) )
.artifactStore( new ArtifactStoreBuilder().downloader( new Downloader() )
.executableNaming( new UserTempNaming() ).tempDir( path ).download(
new DownloadConfigBuilder().defaultsForCommand( Command.MongoD ).artifactStorePath( path ) ) )
.build();
}
示例2: setup
import de.flapdoodle.embed.process.config.io.ProcessOutput; //导入依赖的package包/类
@Before
public void setup() throws Exception {
IStreamProcessor stream = new NullProcessor();
MongodStarter runtime = MongodStarter.getInstance(new RuntimeConfigBuilder()
.defaults(Command.MongoD)
.processOutput(new ProcessOutput(stream, stream, stream))
.artifactStore(new ArtifactStoreBuilder()
.defaults(Command.MongoD)
.build())
.build());
this.mongodExecutable = runtime.prepare(new MongodConfigBuilder()
.version(Version.Main.PRODUCTION)
.net(new Net(PROCESS_PORT, Network.localhostIsIPv6()))
.build());
this.mongodProcess = mongodExecutable.start();
this.mongoClient = new MongoClient(PROCESS_ADDRESS, PROCESS_PORT);
Injector injector = Guice.createInjector(new SearchModule(), new HttpModule());
this.groundHogDB = new GroundhogDB(this.mongoClient, "myGitHubResearch");
this.searchGitHub = injector.getInstance(SearchGitHub.class);
}
示例3: getMongodStarter
import de.flapdoodle.embed.process.config.io.ProcessOutput; //导入依赖的package包/类
private static MongodStarter getMongodStarter(final LoggingTarget loggingTarget) {
if (loggingTarget == null) {
return MongodStarter.getDefaultInstance();
}
switch (loggingTarget) {
case NULL:
final Logger logger = LoggerFactory.getLogger(MongoDbTestRule.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());
}
}
示例4: start
import de.flapdoodle.embed.process.config.io.ProcessOutput; //导入依赖的package包/类
public synchronized void start() throws IOException {
if (process != null) {
throw new IllegalStateException();
}
Command command = Command.Postgres;
IDownloadConfig downloadConfig = new PostgresDownloadConfigBuilder()
.defaultsForCommand(command)
.artifactStorePath(new FixedPath(artifactStorePath))
.build();
ArtifactStoreBuilder artifactStoreBuilder = new PostgresArtifactStoreBuilder()
.defaults(command)
.download(downloadConfig);
LogWatchStreamProcessor logWatch = new LogWatchStreamProcessor("started",
new HashSet<>(singletonList("failed")),
new Slf4jStreamProcessor(getLogger("postgres"), Slf4jLevel.TRACE));
IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder()
.defaults(command)
.processOutput(new ProcessOutput(logWatch, logWatch, logWatch))
.artifactStore(artifactStoreBuilder)
.build();
PostgresStarter<PostgresExecutable, PostgresProcess> starter = new PostgresStarter<>(PostgresExecutable.class, runtimeConfig);
PostgresConfig config = new PostgresConfig(version,
new AbstractPostgresConfig.Net(host, port == 0 ? Network.getFreeServerPort() : port),
new AbstractPostgresConfig.Storage(dbName),
new AbstractPostgresConfig.Timeout(),
new AbstractPostgresConfig.Credentials(username, password));
process = starter.prepare(config).start();
jdbcUrl = "jdbc:postgresql://" + config.net().host() + ":" + config.net().port() + "/" + config.storage().dbName();
}
示例5: embeddedMongoRuntimeConfig
import de.flapdoodle.embed.process.config.io.ProcessOutput; //导入依赖的package包/类
@Bean
public IRuntimeConfig embeddedMongoRuntimeConfig() {
Logger logger = LoggerFactory
.getLogger(getClass().getPackage().getName() + ".EmbeddedMongo");
ProcessOutput processOutput = new ProcessOutput(
Processors.logTo(logger, Slf4jLevel.INFO),
Processors.logTo(logger, Slf4jLevel.ERROR), Processors.named(
"[console>]", Processors.logTo(logger, Slf4jLevel.DEBUG)));
return new RuntimeConfigBuilder().defaultsWithLogger(Command.MongoD, logger)
.processOutput(processOutput).artifactStore(getArtifactStore(logger))
.build();
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:13,代码来源:EmbeddedMongoAutoConfiguration.java
示例6: startMongo
import de.flapdoodle.embed.process.config.io.ProcessOutput; //导入依赖的package包/类
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);
}
}
示例7: embeddedMongoRuntimeConfig
import de.flapdoodle.embed.process.config.io.ProcessOutput; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean
@ConditionalOnClass(Logger.class)
public IRuntimeConfig embeddedMongoRuntimeConfig() {
Logger logger = LoggerFactory
.getLogger(getClass().getPackage().getName() + ".EmbeddedMongo");
ProcessOutput processOutput = new ProcessOutput(
Processors.logTo(logger, Slf4jLevel.INFO),
Processors.logTo(logger, Slf4jLevel.ERROR), Processors.named("[console>]",
Processors.logTo(logger, Slf4jLevel.DEBUG)));
return new RuntimeConfigBuilder().defaultsWithLogger(Command.MongoD, logger)
.processOutput(processOutput).artifactStore(getArtifactStore(logger))
.build();
}
示例8: defaults
import de.flapdoodle.embed.process.config.io.ProcessOutput; //导入依赖的package包/类
public RuntimeConfigBuilder defaults(
final MysqldConfig mysqldConfig,
final DownloadConfig downloadConfig) {
processOutput().setDefault(new ProcessOutput(log, log, log));
commandLinePostProcessor().setDefault(new ICommandLinePostProcessor.Noop());
artifactStore().setDefault(new SafeExtractedArtifactStoreBuilder().defaults(mysqldConfig, downloadConfig).build());
return this;
}
示例9: doStart
import de.flapdoodle.embed.process.config.io.ProcessOutput; //导入依赖的package包/类
private void doStart() throws Exception {
IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder()
.defaultsWithLogger(Command.MongoD, log)
.processOutput(ProcessOutput.getDefaultInstanceSilent())
.build();
runtime = MongodStarter.getInstance(runtimeConfig);
try {
log.info("Starting the mongo server without authentications");
startWithAuth();
log.info("Adding admin user");
addAdmin();
if (this.authMechanisms.equals("SCRAM-SHA-1")) {
setSCRAM_SHA_1Credentials();
}
if (this.authMechanisms.equals("MONGODB-CR")) {
setMongoDB_CRCredentials();
tearDownClass();
auth = true;
startWithAuth();
addAdmin();
}
// Store Mongo server "host:port" in Hadoop configuration
// so that MongoStore will be able to get it latter
conf.set(MongoStoreParameters.PROP_MONGO_SERVERS, "127.0.0.1:" + port);
conf.set(MongoStoreParameters.PROP_MONGO_DB, "admin");
conf.set(MongoStoreParameters.PROP_MONGO_AUTHENTICATION_TYPE, this.authMechanisms);
conf.set(MongoStoreParameters.PROP_MONGO_LOGIN, adminUsername);
conf.set(MongoStoreParameters.PROP_MONGO_SECRET, adminPassword);
} catch (Exception e) {
log.error("Error starting embedded Mongodb server... tearing down test driver.");
tearDownClass();
}
}
示例10: runScriptAndWait
import de.flapdoodle.embed.process.config.io.ProcessOutput; //导入依赖的package包/类
private void runScriptAndWait(String scriptText, String token, String[] failures, String dbName, String username, String password) throws IOException {
IStreamProcessor mongoOutput;
if (!isEmpty(token)) {
mongoOutput = new LogWatchStreamProcessor(
token,
(failures != null) ? new HashSet<>(asList(failures)) : Collections.emptySet(),
namedConsole("[mongo shell output]"));
} else {
mongoOutput = new NamedOutputStreamProcessor("[mongo shell output]", console());
}
IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder()
.defaults(Command.Mongo)
.processOutput(new ProcessOutput(
mongoOutput,
namedConsole("[mongo shell error]"),
console()))
.build();
MongoShellStarter starter = MongoShellStarter.getInstance(runtimeConfig);
final File scriptFile = writeTmpScriptFile(scriptText);
final MongoShellConfigBuilder builder = new MongoShellConfigBuilder();
if (!isEmpty(dbName)) {
builder.dbName(dbName);
}
if (!isEmpty(username)) {
builder.username(username);
}
if (!isEmpty(password)) {
builder.password(password);
}
starter.prepare(builder
.scriptName(scriptFile.getAbsolutePath())
.version(mongodConfig.version())
.net(mongodConfig.net())
.build()).start();
if (mongoOutput instanceof LogWatchStreamProcessor) {
((LogWatchStreamProcessor) mongoOutput).waitForResult(INIT_TIMEOUT_MS);
}
}
示例11: setUpClass
import de.flapdoodle.embed.process.config.io.ProcessOutput; //导入依赖的package包/类
/**
* Initiate the MongoDB server on the default port
*/
@Override
public void setUpClass() throws IOException {
IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder()
.defaultsWithLogger(Command.MongoD, log)
.processOutput(ProcessOutput.getDefaultInstanceSilent())
.build();
MongodStarter runtime = MongodStarter.getInstance(runtimeConfig);
int port = Network.getFreeServerPort();
IMongodConfig mongodConfig = new MongodConfigBuilder()
.version(version)
.net(new Net(port, Network.localhostIsIPv6())).build();
// Store Mongo server "host:port" in Hadoop configuration
// so that MongoStore will be able to get it latter
conf.set(MongoStoreParameters.PROP_MONGO_SERVERS, "127.0.0.1:" + port);
log.info("Starting embedded Mongodb server on {} port.", port);
try {
_mongodExe = runtime.prepare(mongodConfig);
_mongod = _mongodExe.start();
_mongo = new MongoClient("localhost", port);
} catch (Exception e) {
log.error("Error starting embedded Mongodb server... tearing down test driver.");
tearDownClass();
}
}
示例12: initialize
import de.flapdoodle.embed.process.config.io.ProcessOutput; //导入依赖的package包/类
private void initialize() {
if (db != null) {
return;
}
System.setProperty("mongodb.database", dbName);
System.setProperty("mongodb.host", mongoHostname);
System.setProperty("mongodb.port", String.valueOf(mongoPort));
try {
IStreamProcessor mongodOutput = Processors.named("[mongod>]",
new FileStreamProcessor(File.createTempFile("mongod", "log")));
IStreamProcessor mongodError = new FileStreamProcessor(File.createTempFile("mongod-error", "log"));
IStreamProcessor commandsOutput = Processors.namedConsole("[console>]");
IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder()
.defaults(Command.MongoD)
.processOutput(new ProcessOutput(mongodOutput, mongodError, commandsOutput))
.build();
MongodStarter runtime = MongodStarter.getInstance(runtimeConfig);
mongodExe = runtime.prepare(
new MongodConfigBuilder()
.version(de.flapdoodle.embed.mongo.distribution.Version.V2_6_8)
.net(new Net(mongoPort, Network.localhostIsIPv6()))
.build()
);
try {
mongod = mongodExe.start();
} catch (Throwable t) {
// try again, could be killed breakpoint in IDE
mongod = mongodExe.start();
}
if (MONGO_CREDENTIALS.isEmpty()) {
client = new MongoClient(mongoHostname + ":" + mongoPort);
} else {
client = new MongoClient(new ServerAddress(mongoHostname + ":" + mongoPort), MONGO_CREDENTIALS);
client.getDB("admin").command("{ user: \"siteUserAdmin\", pwd: \"password\", roles: [ { role: \"userAdminAnyDatabase\", db: \"admin\" } , { role: \"userAdminAnyDatabase\", db: \"" + dbName + "\" } ] }");
}
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
super.start();
if (mongodExe != null) {
mongodExe.stop();
}
db = null;
client = null;
mongod = null;
mongodExe = null;
}
});
db = client.getDB(dbName);
} catch (IOException e) {
throw new Error(e);
}
}