當前位置: 首頁>>代碼示例>>Java>>正文


Java MongodExecutable類代碼示例

本文整理匯總了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.");
}
 
開發者ID:badalgeek,項目名稱:EventStreamAnalytics,代碼行數:27,代碼來源:TestServerManager.java

示例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");
}
 
開發者ID:alv-ch,項目名稱:alv-ch-java,代碼行數:17,代碼來源:MongoDbDataStoreAdapterTest.java

示例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);
}
 
開發者ID:spring-projects,項目名稱:spring-session-data-mongodb,代碼行數:18,代碼來源:MongoITestUtils.java

示例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);
    }
}
 
開發者ID:dadrus,項目名稱:jpa-unit,代碼行數:28,代碼來源:MongodManager.java

示例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();
}
 
開發者ID:datafibers-community,項目名稱:df_data_service,代碼行數:13,代碼來源:MyFirstVerticleTest.java

示例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();
}
 
開發者ID:serhuz,項目名稱:dropwizard-morphia,代碼行數:13,代碼來源:BaseMongoTest.java

示例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();
}
 
開發者ID:ImmobilienScout24,項目名稱:switchman,代碼行數:9,代碼來源:TestPersistence.java

示例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;
}
 
開發者ID:gomoob,項目名稱:embedded-mongo,代碼行數:42,代碼來源:StartCommand.java

示例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());
}
 
開發者ID:nerdcoding,項目名稱:angular2-spring-boot,代碼行數:5,代碼來源:EmbeddedMongoConfiguration.java

示例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());
}
 
開發者ID:Spectingular,項目名稱:spectingular.spock,代碼行數:5,代碼來源:EmbeddedMongoDbConfig.java

示例15: getMongodExecutable

import de.flapdoodle.embed.mongo.MongodExecutable; //導入依賴的package包/類
/**
 * {@inheritDoc}
 */
public MongodExecutable getMongodExecutable() {
	return this.mongodExecutable;
}
 
開發者ID:gomoob,項目名稱:embedded-mongo,代碼行數:7,代碼來源:MongoContext.java


注:本文中的de.flapdoodle.embed.mongo.MongodExecutable類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。