当前位置: 首页>>代码示例>>Java>>正文


Java MongodConfigBuilder类代码示例

本文整理汇总了Java中de.flapdoodle.embed.mongo.config.MongodConfigBuilder的典型用法代码示例。如果您正苦于以下问题:Java MongodConfigBuilder类的具体用法?Java MongodConfigBuilder怎么用?Java MongodConfigBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MongodConfigBuilder类属于de.flapdoodle.embed.mongo.config包,在下文中一共展示了MongodConfigBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setup

import de.flapdoodle.embed.mongo.config.MongodConfigBuilder; //导入依赖的package包/类
private static void setup() throws UnknownHostException, IOException {
  IMongoCmdOptions cmdOptions = new MongoCmdOptionsBuilder().verbose(false)
      .enableAuth(authEnabled).build();

  IMongodConfig mongodConfig = new MongodConfigBuilder()
      .version(Version.Main.PRODUCTION)
      .net(new Net(LOCALHOST, MONGOS_PORT, Network.localhostIsIPv6()))
      .cmdOptions(cmdOptions).build();

  IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder().defaults(
      Command.MongoD).build();
  mongodExecutable = MongodStarter.getInstance(runtimeConfig).prepare(
      mongodConfig);
  mongod = mongodExecutable.start();
  mongoClient = new MongoClient(new ServerAddress(LOCALHOST, MONGOS_PORT));
  createDbAndCollections(EMPLOYEE_DB, EMPINFO_COLLECTION, "employee_id");
  createDbAndCollections(EMPLOYEE_DB, SCHEMA_CHANGE_COLLECTION, "field_2");
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:19,代码来源:MongoTestSuit.java

示例2: start

import de.flapdoodle.embed.mongo.config.MongodConfigBuilder; //导入依赖的package包/类
@BeforeAll
public static void start() throws Exception {
  StopWatch stopWatch = StopWatch.startForSplits();
  port = Network.getFreeServerPort();
  mongodExe =
      starter.prepare(
          new MongodConfigBuilder()
              .version(Version.Main.DEVELOPMENT)
              .net(new Net("localhost", port, Network.localhostIsIPv6()))
              .build());
  long prepareElapsedTime = stopWatch.split();
  mongod = mongodExe.start();
  long startElapsedTime = stopWatch.split();
  logger.info(
      "Started embedded Mongo in {}ms (prepareElapsedTime={}ms, startElapsedTime={}ms)",
      stopWatch.stop(),
      prepareElapsedTime,
      startElapsedTime);
}
 
开发者ID:glytching,项目名称:dragoman,代码行数:20,代码来源:AbstractMongoDBTest.java

示例3: beforeClass

import de.flapdoodle.embed.mongo.config.MongodConfigBuilder; //导入依赖的package包/类
@BeforeClass
public static void beforeClass() throws Exception {
  MongodStarter runtime = MongodStarter.getDefaultInstance();
  mongodExe = runtime.prepare(
    new MongodConfigBuilder().version(Version.V3_3_1)
      .net(new Net(12345, Network.localhostIsIPv6()))
      .build());
  MongodProcess process = mongodExe.start();
  await().until(() -> process != null);
}
 
开发者ID:vert-x3,项目名称:vertx-service-discovery,代码行数:11,代码来源:MongoDataSourceTest.java

示例4: embeddedMongoConfiguration

import de.flapdoodle.embed.mongo.config.MongodConfigBuilder; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean
public IMongodConfig embeddedMongoConfiguration() throws IOException {
	IFeatureAwareVersion featureAwareVersion = new ToStringFriendlyFeatureAwareVersion(
			this.embeddedProperties.getVersion(),
			this.embeddedProperties.getFeatures());
	MongodConfigBuilder builder = new MongodConfigBuilder()
			.version(featureAwareVersion);
	if (this.embeddedProperties.getStorage() != null) {
		builder.replication(
				new Storage(this.embeddedProperties.getStorage().getDatabaseDir(),
						this.embeddedProperties.getStorage().getReplSetName(),
						this.embeddedProperties.getStorage().getOplogSize() != null
								? this.embeddedProperties.getStorage().getOplogSize()
								: 0));
	}
	if (getPort() > 0) {
		builder.net(new Net(getHost().getHostAddress(), getPort(),
				Network.localhostIsIPv6()));
	}
	else {
		builder.net(new Net(getHost().getHostAddress(),
				Network.getFreeServerPort(getHost()), Network.localhostIsIPv6()));
	}
	return builder.build();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:27,代码来源:EmbeddedMongoAutoConfiguration.java

示例5: startMangoDb

import de.flapdoodle.embed.mongo.config.MongodConfigBuilder; //导入依赖的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

示例6: setup

import de.flapdoodle.embed.mongo.config.MongodConfigBuilder; //导入依赖的package包/类
private static void setup() throws UnknownHostException, IOException {
  IMongoCmdOptions cmdOptions = new MongoCmdOptionsBuilder().verbose(false)
      .enableAuth(authEnabled).build();

  IMongodConfig mongodConfig = new MongodConfigBuilder()
      .version(Version.Main.PRODUCTION)
      .net(new Net(LOCALHOST, MONGOS_PORT, Network.localhostIsIPv6()))
      .cmdOptions(cmdOptions).build();

  IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder().defaults(
      Command.MongoD).build();
  mongodExecutable = MongodStarter.getInstance(runtimeConfig).prepare(
      mongodConfig);
  mongod = mongodExecutable.start();
  mongoClient = new MongoClient(new ServerAddress(LOCALHOST, MONGOS_PORT));
  createDbAndCollections(EMPLOYEE_DB, EMPINFO_COLLECTION, "employee_id");
  createDbAndCollections(EMPLOYEE_DB, SCHEMA_CHANGE_COLLECTION, "field_2");
  createDbAndCollections(EMPLOYEE_DB, EMPTY_COLLECTION, "field_2");
  createDbAndCollections(DATATYPE_DB, DATATYPE_COLLECTION, "_id");
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:21,代码来源:MongoTestSuit.java

示例7: SimpleMongoAsyncTest

import de.flapdoodle.embed.mongo.config.MongodConfigBuilder; //导入依赖的package包/类
public SimpleMongoAsyncTest() throws IOException {
    // Start embeded mongo
    config = new MongodConfigBuilder()
            .version(Version.Main.PRODUCTION)
            .net(new Net(27018, Network.localhostIsIPv6()))
            .build();
    exe = MongodStarter.getDefaultInstance().prepare(config);
    mongoProcess = exe.start();

    AtomicBoolean started = new AtomicBoolean(false);

    // Start mongo client
    client = MongoClients.create("mongodb://localhost:27018");
    database = client.getDatabase("test");
    collection = database.getCollection(COLLECTION_NAME);

    morphia = new Morphia().mapPackage("com.querydsl.mongodb.domain");
}
 
开发者ID:egopulse,项目名称:querydsl-mongodb-async,代码行数:19,代码来源:SimpleMongoAsyncTest.java

示例8: start

import de.flapdoodle.embed.mongo.config.MongodConfigBuilder; //导入依赖的package包/类
@Override
public void start(Future<Void> future) {
	MongodStarter starter = MongodStarter.getDefaultInstance();

	try {
		int port = MainVerticle.MONGO_PORT;
		MongodConfigBuilder builder = new MongodConfigBuilder();
		builder.version(Version.Main.PRODUCTION);
		builder.net(new Net(port, Network.localhostIsIPv6()));
		mongod = starter.prepare(builder.build());
		mongod.start();
	} catch (IOException ioe) {
		future.fail(ioe);
		return;
	}
	future.complete();
}
 
开发者ID:aesteve,项目名称:vertx-feeds,代码行数:18,代码来源:EmbeddedMongo.java

示例9: setUp

import de.flapdoodle.embed.mongo.config.MongodConfigBuilder; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
	this._mongodExe = starter.prepare(new MongodConfigBuilder()
			//.version(Version.Main.PRODUCTION)
			.version(Versions.withFeatures(new GenericVersion("3.4.0"),Feature.SYNC_DELAY, Feature.STORAGE_ENGINE))
			.net(new Net("127.0.0.1", 12345, Network.localhostIsIPv6())).build());
	this._mongod = this._mongodExe.start();

	this._mongo = new MongoClient("localhost", 12345);

	//this._mongo = new MongoClient("localhost", 27017);
	for (String dbName : this._mongo.listDatabaseNames()) {
		if (!dbName.equals("admin") && !dbName.equals("local")) { 
			this._mongo.dropDatabase(dbName);
		}
	}
}
 
开发者ID:ralscha,项目名称:bsoncodec-apt,代码行数:18,代码来源:AbstractMongoDBTest.java

示例10: before

import de.flapdoodle.embed.mongo.config.MongodConfigBuilder; //导入依赖的package包/类
@Override
public void before() throws Exception {
  if(defaultPort < 0) {
    currentPort = Helper.findRandomOpenPortOnAllLocalInterfaces();
  } else {
    currentPort = defaultPort;
  }

  IMongodConfig mongodConfig = new MongodConfigBuilder()
      .version(version)
      .net(new Net("localhost", currentPort, Network.localhostIsIPv6()))
      .build();

  MongodStarter runtime = MongodStarter.getDefaultInstance();
  mongodExe = runtime.prepare(mongodConfig);
  mongod = mongodExe.start();
}
 
开发者ID:mlk,项目名称:AssortmentOfJUnitRules,代码行数:18,代码来源:MongoRule.java

示例11: EmbeddedMongoDb

import de.flapdoodle.embed.mongo.config.MongodConfigBuilder; //导入依赖的package包/类
public EmbeddedMongoDb(final String dbName)
        throws IOException {

    this.version = Version.Main.V3_4;
    this.port = 12345;

    // see MongodForTestsFactory for example verbose startup options
    this.mongodExecutable = STARTER.prepare(new MongodConfigBuilder()
                                                    .version(version)
                                                    .net(new Net(port, Network.localhostIsIPv6()))
                                                    .build());
    this.mongodProcess = mongodExecutable.start();

    this.mongoClient = new MongoClient("localhost", port);

    this.db = mongoClient.getDatabase(dbName);
}
 
开发者ID:saalfeldlab,项目名称:render,代码行数:18,代码来源:EmbeddedMongoDb.java

示例12: before

import de.flapdoodle.embed.mongo.config.MongodConfigBuilder; //导入依赖的package包/类
@Override
protected void before() throws IOException {
    MongodStarter runtime = MongodStarter.getDefaultInstance();
    IMongodConfig config = new MongodConfigBuilder().
            version(getMongoVersion()).
            net(new Net(getPort(), Network.localhostIsIPv6())).
            build();
    mongodExe = runtime.prepare(config);

    try {
        mongod = mongodExe.start();
    } catch (IOException e) {
        //Mongo failed to start for the previously stated reason. A single retry will be attempted.
        mongod = mongodExe.start();
    }
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:17,代码来源:MongoServerExternalResource.java

示例13: before

import de.flapdoodle.embed.mongo.config.MongodConfigBuilder; //导入依赖的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

示例14: setup

import de.flapdoodle.embed.mongo.config.MongodConfigBuilder; //导入依赖的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);
	
}
 
开发者ID:spgroup,项目名称:groundhog,代码行数:25,代码来源:GroundhogDBTest.java

示例15: MongoDatabaseForTestsFactory

import de.flapdoodle.embed.mongo.config.MongodConfigBuilder; //导入依赖的package包/类
/**
 * Constructor 
 * 
 * @throws Exception
 */
public MongoDatabaseForTestsFactory() throws Exception
{
    MongodStarter starter = MongodStarter.getDefaultInstance();
    IMongodConfig mongodConfig = new MongodConfigBuilder()
            .version(version)
            .processListener(new MongoDatabaseProcessListener())
            .build();

    this.mongodExecutable = starter.prepare(mongodConfig);
    this.mongodProcess = mongodExecutable.start();

    // We use a randomly-assigned port, so get it
    InetAddress address = mongodProcess.getConfig().net()
            .getServerAddress();
    int port = mongodProcess.getConfig().net().getPort();

    this.mongoClient = new MongoClient(new ServerAddress(address, port));
    this.database = this.mongoClient.getDatabase(UUID.randomUUID()
            .toString());
}
 
开发者ID:AlfrescoBenchmark,项目名称:alfresco-benchmark,代码行数:26,代码来源:MongoDatabaseForTestsFactory.java


注:本文中的de.flapdoodle.embed.mongo.config.MongodConfigBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。