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


Java MongodStarter.getDefaultInstance方法代碼示例

本文整理匯總了Java中de.flapdoodle.embed.mongo.MongodStarter.getDefaultInstance方法的典型用法代碼示例。如果您正苦於以下問題:Java MongodStarter.getDefaultInstance方法的具體用法?Java MongodStarter.getDefaultInstance怎麽用?Java MongodStarter.getDefaultInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在de.flapdoodle.embed.mongo.MongodStarter的用法示例。


在下文中一共展示了MongodStarter.getDefaultInstance方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: beforeClass

import de.flapdoodle.embed.mongo.MongodStarter; //導入方法依賴的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

示例2: start

import de.flapdoodle.embed.mongo.MongodStarter; //導入方法依賴的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

示例3: before

import de.flapdoodle.embed.mongo.MongodStarter; //導入方法依賴的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

示例4: setupClass

import de.flapdoodle.embed.mongo.MongodStarter; //導入方法依賴的package包/類
@BeforeClass
public static void setupClass() throws Exception {
    MongodStarter runtime = MongodStarter.getDefaultInstance();
    mongodExe = runtime.prepare(new MongodConfig(de.flapdoodle.embed.mongo.distribution.Version.V2_4_3, MONGO_PORT, false));
    try {
        mongod = mongodExe.start();
    } catch (IOException e) {
        // someone probably killed the process in a breakpoint in an ide.. try again
        mongod = mongodExe.start();
    }

    mongo = new Mongo(IN_MEM_CONNECTION_URL);

    Configuration config = new Configuration();
    config.setName(DB_NAME);
    config.setHost(MONGO_HOST);
    config.setPort(String.valueOf(MONGO_PORT));
    crud = new MongoCRUD(config);
}
 
開發者ID:jewzaam,項目名稱:mongo-utility,代碼行數:20,代碼來源:AbstractMongoTest.java

示例5: before

import de.flapdoodle.embed.mongo.MongodStarter; //導入方法依賴的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

示例6: before

import de.flapdoodle.embed.mongo.MongodStarter; //導入方法依賴的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

示例7: MongoDatabaseForTestsFactory

import de.flapdoodle.embed.mongo.MongodStarter; //導入方法依賴的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

示例8: MongoDBForTestsFactory

import de.flapdoodle.embed.mongo.MongodStarter; //導入方法依賴的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

示例9: getMongodStarter

import de.flapdoodle.embed.mongo.MongodStarter; //導入方法依賴的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());
    }
}
 
開發者ID:apache,項目名稱:logging-log4j2,代碼行數:22,代碼來源:MongoDbTestRule.java

示例10: before

import de.flapdoodle.embed.mongo.MongodStarter; //導入方法依賴的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

示例11: embeddedMongoServer

import de.flapdoodle.embed.mongo.MongodStarter; //導入方法依賴的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

示例12: start

import de.flapdoodle.embed.mongo.MongodStarter; //導入方法依賴的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

示例13: setUpClass

import de.flapdoodle.embed.mongo.MongodStarter; //導入方法依賴的package包/類
/**
 * Initiate the MongoDB server on the default port
 */
@Override
public void setUpClass() throws Exception {
  super.setUpClass();
  MongodStarter runtime = MongodStarter.getDefaultInstance();

  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();
  }
}
 
開發者ID:jianglibo,項目名稱:gora-boot,代碼行數:30,代碼來源:GoraMongodbTestDriver.java

示例14: start

import de.flapdoodle.embed.mongo.MongodStarter; //導入方法依賴的package包/類
public void start() throws Exception {
    final MongodStarter starter = MongodStarter.getDefaultInstance();
    executable = starter.prepare(new MongodConfigBuilder()
        .version(Version.Main.PRODUCTION)
        .net(new Net(12345, Network.localhostIsIPv6()))
        .build());
    mongod = executable.start();
}
 
開發者ID:rinoto,項目名稱:migramongo,代碼行數:9,代碼來源:EmbeddedMongo.java

示例15: beforeEach

import de.flapdoodle.embed.mongo.MongodStarter; //導入方法依賴的package包/類
@BeforeMethod
public void beforeEach() throws Exception {
    MongodStarter starter = MongodStarter.getDefaultInstance();
    IMongodConfig mongodConfig = new MongodConfigBuilder()
            .version(Version.Main.PRODUCTION)
            .net(new Net(port, Network.localhostIsIPv6()))
            .build();
    mongodExecutable = starter.prepare(mongodConfig);
    mongod = mongodExecutable.start();
}
 
開發者ID:nimesh-mittal,項目名稱:elastic-match,代碼行數:11,代碼來源:EntityDaoTest.java


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