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


Java IMongodConfig类代码示例

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


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

示例1: setup

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

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

示例3: startMongod

import de.flapdoodle.embed.mongo.config.IMongodConfig; //导入依赖的package包/类
private void startMongod(final MongodConfiguration config) {

        List<IMongodConfig> mongodConfigList;
        try {
            if (config.getHosts().size() == 1) {
                mongodConfigList = buildMongodConfiguration(config.getHosts(), false);
                startMongo(mongodConfigList);
            } else if (config.getHosts().size() >= 3) {
                mongodConfigList = buildMongodConfiguration(config.getHosts(), true);
                startMongo(mongodConfigList);
                initializeReplicaSet(mongodConfigList);
            } else {
                throw new RuntimeException("It looks like replica set is configured. A replica set however requires at least 3 hosts");
            }

        } catch (final IOException | InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
 
开发者ID:dadrus,项目名称:jpa-unit,代码行数:20,代码来源:MongodManager.java

示例4: startMangoDb

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

示例5: setup

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

示例6: before

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

示例7: before

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

示例8: before

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

示例9: MongoDatabaseForTestsFactory

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

示例10: MongoDBForTestsFactory

import de.flapdoodle.embed.mongo.config.IMongodConfig; //导入依赖的package包/类
/**
 * Constructor
 * 
 * @throws Exception
 */
@SuppressWarnings("deprecation")
public MongoDBForTestsFactory() throws Exception
{
    MongodStarter starter = MongodStarter.getDefaultInstance();
    IMongodConfig mongodConfig = new MongodConfigBuilder()
            .version(version)
            .processListener(new MongoDBProcessListener())
            .build();
    
    mongodExecutable = starter.prepare(mongodConfig);
    mongodProcess = mongodExecutable.start();

    // We use a randomly-assigned port, so get it
    InetAddress address = mongodProcess.getConfig().net().getServerAddress();
    int port = mongodProcess.getConfig().net().getPort();
    
    mongo = new MongoClient(new ServerAddress(address, port));
    db = mongo.getDB(UUID.randomUUID().toString());
}
 
开发者ID:AlfrescoBenchmark,项目名称:alfresco-benchmark,代码行数:25,代码来源:MongoDBForTestsFactory.java

示例11: crateConfigServerConfig

import de.flapdoodle.embed.mongo.config.IMongodConfig; //导入依赖的package包/类
private static IMongodConfig crateConfigServerConfig(int configServerPort,
    boolean flag) throws UnknownHostException, IOException {
  IMongoCmdOptions cmdOptions = new MongoCmdOptionsBuilder().verbose(false)
      .build();

  IMongodConfig mongodConfig = new MongodConfigBuilder()
      .version(Version.Main.PRODUCTION)
      .net(new Net(LOCALHOST, configServerPort, Network.localhostIsIPv6()))
      .configServer(flag).cmdOptions(cmdOptions).build();
  return mongodConfig;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:12,代码来源:MongoTestSuit.java

示例12: crateIMongodConfig

import de.flapdoodle.embed.mongo.config.IMongodConfig; //导入依赖的package包/类
private static IMongodConfig crateIMongodConfig(int mongodPort,
    boolean flag, String replicaName) throws UnknownHostException,
    IOException {
  IMongoCmdOptions cmdOptions = new MongoCmdOptionsBuilder().verbose(false)
      .build();

  Storage replication = new Storage(null, replicaName, 0);
  IMongodConfig mongodConfig = new MongodConfigBuilder()
      .version(Version.Main.PRODUCTION)
      .net(new Net(LOCALHOST, mongodPort, Network.localhostIsIPv6()))
      .configServer(flag).replication(replication).cmdOptions(cmdOptions)
      .build();
  return mongodConfig;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:15,代码来源:MongoTestSuit.java

示例13: before

import de.flapdoodle.embed.mongo.config.IMongodConfig; //导入依赖的package包/类
@Override
protected void before() throws Throwable {
	MongodStarter starter = MongodStarter.getDefaultInstance();
		
	IMongodConfig mongodConfig = new MongodConfigBuilder()
		.version(Version.Main.PRODUCTION)
		.net(new Net(URL, PORT, Network.localhostIsIPv6()))
		.build();
	
	mongodExecutable = starter.prepare(mongodConfig);
	mongodExecutable.start();

	mongo = new MongoClient(URL, PORT);
}
 
开发者ID:wesley-ramos,项目名称:spring-multitenancy,代码行数:15,代码来源:MongoEmbedded.java

示例14: embeddedMongoServer

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

示例15: start

import de.flapdoodle.embed.mongo.config.IMongodConfig; //导入依赖的package包/类
public void start(final int port) {
    MongodStarter starter = MongodStarter.getDefaultInstance();

    try {
        IMongodConfig mongodConfig = new MongodConfigBuilder()
                .version(Version.Main.PRODUCTION)
                .net(new Net(port, Network.localhostIsIPv6()))
                .build();

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

        // populate
        final MongoClient mongo = new MongoClient("localhost", port);
        final MongoDatabase db = mongo.getDatabase("users");
        db.createCollection("users");
        final MongoCollection<Document> collection = db.getCollection("users");
        final PasswordEncoder encoder = new BasicSaltedSha512PasswordEncoder(SALT);
        final String password = encoder.encode(PASSWORD);
        Map<String, Object> properties1 = new HashMap<>();
        properties1.put(USERNAME, GOOD_USERNAME);
        properties1.put(PASSWORD, password);
        properties1.put(FIRSTNAME, FIRSTNAME_VALUE);
        collection.insertOne(new Document(properties1));
        Map<String, Object> properties2 = new HashMap<>();
        properties2.put(USERNAME, MULTIPLE_USERNAME);
        properties2.put(PASSWORD, password);
        collection.insertOne(new Document(properties2));
        Map<String, Object> properties3 = new HashMap<>();
        properties3.put(USERNAME, MULTIPLE_USERNAME);
        properties3.put(PASSWORD, password);
        collection.insertOne(new Document(properties3));

    } catch (final IOException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:38,代码来源:MongoServer.java


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