本文整理匯總了Java中de.flapdoodle.embed.mongo.MongodExecutable類的典型用法代碼示例。如果您正苦於以下問題:Java MongodExecutable類的具體用法?Java MongodExecutable怎麽用?Java MongodExecutable使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
MongodExecutable類屬於de.flapdoodle.embed.mongo包,在下文中一共展示了MongodExecutable類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: startMangoDb
import de.flapdoodle.embed.mongo.MongodExecutable; //導入依賴的package包/類
private void startMangoDb() throws InterruptedException {
startInNewThread(() -> {
try {
MongodStarter starter = MongodStarter.getDefaultInstance();
IMongodConfig mongodConfig = new MongodConfigBuilder()
.version(Version.Main.PRODUCTION)
.net(new Net(12345, Network.localhostIsIPv6()))
.pidFile(new File("target/process.pid").getAbsolutePath())
.replication(new Storage(new File("target/tmp/mongodb/").getAbsolutePath(), null, 0))
.build();
logger.debug("Would download MongoDB if not yet downloaded.");
MongodExecutable mongodExecutable = starter.prepare(mongodConfig);
logger.debug("Done with downloading MongoDB exec.");
mongodExecutable.start();
MongoClientURI uri = new MongoClientURI("mongodb://localhost:12345/eventStreamAnalytics");
MongoClient client = new MongoClient(uri);
MongoDatabase mongoDatabase = client.getDatabase(uri.getDatabase());
mongoDatabase.createCollection("events");
} catch (Exception ex) {
logger.error("Failed to start MongoDB", ex);
throw new RuntimeException(ex);
}
}, "MangoDB").join();
logger.debug("Successfully Started MongoDB.");
}
示例2: before
import de.flapdoodle.embed.mongo.MongodExecutable; //導入依賴的package包/類
@Before
public void before() throws Exception {
MongodStarter starter = MongodStarter.getDefaultInstance();
IMongodConfig mongodConfig = new MongodConfigBuilder()
.version(Version.Main.PRODUCTION)
.net(new Net(27017, Network.localhostIsIPv6()))
.build();
MongodExecutable mongodExecutable = null;
mongodExecutable = starter.prepare(mongodConfig);
mongod = mongodExecutable.start();
ApplicationContext context = new ClassPathXmlApplicationContext("spring/mongodb-data-store-adapter-test-context.xml");
BeanFactory factory = context;
adapter = (DataStoreAdapter) factory.getBean("adapter");
}
示例3: embeddedMongoServer
import de.flapdoodle.embed.mongo.MongodExecutable; //導入依賴的package包/類
/**
* Creates {@link MongodExecutable} for use in integration tests.
* @param port the port for embedded Mongo to bind to
* @return the {@link MongodExecutable} instance
* @throws IOException in case of I/O errors
*/
static MongodExecutable embeddedMongoServer(int port) throws IOException {
IMongodConfig mongodConfig = new MongodConfigBuilder()
.version(Version.Main.PRODUCTION)
.net(new Net(port, Network.localhostIsIPv6()))
.build();
MongodStarter mongodStarter = MongodStarter.getDefaultInstance();
return mongodStarter.prepare(mongodConfig);
}
示例4: embeddedMongoServer
import de.flapdoodle.embed.mongo.MongodExecutable; //導入依賴的package包/類
@Bean(initMethod = "start", destroyMethod = "stop")
@ConditionalOnMissingBean
public MongodExecutable embeddedMongoServer(IMongodConfig mongodConfig)
throws IOException {
if (getPort() == 0) {
publishPortInfo(mongodConfig.net().getPort());
}
MongodStarter mongodStarter = getMongodStarter(this.runtimeConfig);
return mongodStarter.prepare(mongodConfig);
}
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:11,代碼來源:EmbeddedMongoAutoConfiguration.java
示例5: startMongo
import de.flapdoodle.embed.mongo.MongodExecutable; //導入依賴的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);
}
}
示例6: initialize
import de.flapdoodle.embed.mongo.MongodExecutable; //導入依賴的package包/類
@BeforeClass
public static void initialize() throws IOException {
MongodStarter starter = MongodStarter.getDefaultInstance();
IMongodConfig mongodConfig = new MongodConfigBuilder()
.version(Version.Main.PRODUCTION)
.net(new Net(MONGO_PORT, Network.localhostIsIPv6()))
.build();
MongodExecutable mongodExecutable = starter.prepare(mongodConfig);
MONGO = mongodExecutable.start();
}
示例7: configureMongo
import de.flapdoodle.embed.mongo.MongodExecutable; //導入依賴的package包/類
@BeforeClass
public static void configureMongo() throws Exception {
port = Network.getFreeServerPort();
IMongodConfig config = new MongodConfigBuilder()
.version(Version.Main.V3_2)
.net(new Net(port, Network.localhostIsIPv6()))
.build();
MongodExecutable executable = STARTER.prepare(config);
process = executable.start();
}
示例8: prepareTestDatabase
import de.flapdoodle.embed.mongo.MongodExecutable; //導入依賴的package包/類
private void prepareTestDatabase(int port) throws IOException {
MongodStarter starter = MongodStarter.getDefaultInstance();
IMongodConfig mongodConfig = new MongodConfigBuilder().version(Version.Main.PRODUCTION)
.net(new Net(port, Network.localhostIsIPv6()))
.build();
MongodExecutable mongodExecutable = starter.prepare(mongodConfig);
mongodExecutable.start();
}
示例9: run
import de.flapdoodle.embed.mongo.MongodExecutable; //導入依賴的package包/類
/**
* {@inheritDoc}
*/
public IResponse run(IContext context) throws CommandException
{
// Creates the response
IResponse response = new Response();
// If the embedded server is not already stated or starting
if(context.getState() != State.STARTING && context.getState() != State.STARTED) {
// Sets the starting state
context.setState(State.STARTING);
// Creates and starts a MongodExecutable
MongodStarter starter = MongodStarter.getInstance(context.getMongoContext().getRuntimeConfig());
MongodExecutable mongodExecutable = starter.prepare(context.getMongoContext().getMongodConfig());
try {
MongodProcess mongodProcess = mongodExecutable.start();
context.getMongoContext().setMongodProcess(mongodProcess);
} catch (IOException ioException) {
throw new CommandException(ioException);
}
context.getMongoContext().setMongodExecutable(mongodExecutable);
// Sets the started state
context.setState(State.STARTED);
}
// Otherwise this is an error because the server is already started
else {
// TODO: Trouver un moyen de modéliser une erreur générique
}
return response;
}
示例10: embeddedMongoServer
import de.flapdoodle.embed.mongo.MongodExecutable; //導入依賴的package包/類
@Bean(initMethod = "start", destroyMethod = "stop")
public MongodExecutable embeddedMongoServer() throws IOException {
return MongoITestUtils.embeddedMongoServer(this.embeddedMongoPort);
}
開發者ID:spring-projects,項目名稱:spring-session-data-mongodb,代碼行數:5,代碼來源:AbstractMongoRepositoryITest.java
示例11: mongodExecutable
import de.flapdoodle.embed.mongo.MongodExecutable; //導入依賴的package包/類
@Bean(destroyMethod = "stop")
public MongodExecutable mongodExecutable() throws IOException {
return MongodStarter.getDefaultInstance().prepare(mongodConfig());
}
示例12: testContextLoads
import de.flapdoodle.embed.mongo.MongodExecutable; //導入依賴的package包/類
@Test
public void testContextLoads() throws Exception {
assertThat(this.context).isNotNull();
assertThat(this.context.getBeanNamesForType(MongodExecutable.class)).isEmpty();
}
開發者ID:michael-simons,項目名稱:datamongotest-autoconfigure-spring-boot-DEPRECATED-,代碼行數:7,代碼來源:AutoConfigureEmbeddedMongodDisabledIntegrationTest.java
示例13: testContextLoads
import de.flapdoodle.embed.mongo.MongodExecutable; //導入依賴的package包/類
@Test
public void testContextLoads() throws Exception {
assertThat(this.context).isNotNull();
assertThat(this.context.getBeanNamesForType(MongodExecutable.class)).isNotEmpty();
}
開發者ID:michael-simons,項目名稱:datamongotest-autoconfigure-spring-boot-DEPRECATED-,代碼行數:7,代碼來源:AutoConfigureEmbeddedMongodEnabledIntegrationTest.java
示例14: mongodExe
import de.flapdoodle.embed.mongo.MongodExecutable; //導入依賴的package包/類
@Bean(destroyMethod = "stop")
public MongodExecutable mongodExe() throws IOException {
return starter.prepare(mongodConfig());
}
示例15: getMongodExecutable
import de.flapdoodle.embed.mongo.MongodExecutable; //導入依賴的package包/類
/**
* {@inheritDoc}
*/
public MongodExecutable getMongodExecutable() {
return this.mongodExecutable;
}