本文整理汇总了Java中de.flapdoodle.embed.mongo.MongodStarter.prepare方法的典型用法代码示例。如果您正苦于以下问题:Java MongodStarter.prepare方法的具体用法?Java MongodStarter.prepare怎么用?Java MongodStarter.prepare使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类de.flapdoodle.embed.mongo.MongodStarter
的用法示例。
在下文中一共展示了MongodStarter.prepare方法的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);
}
示例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();
}
示例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();
}
示例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);
}
示例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();
}
}
示例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");
}
示例7: setup
import de.flapdoodle.embed.mongo.MongodStarter; //导入方法依赖的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);
}
示例8: 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());
}
示例9: 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());
}
示例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);
}
示例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);
}
示例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);
}
}
示例13: MongoClientTestConfiguration
import de.flapdoodle.embed.mongo.MongodStarter; //导入方法依赖的package包/类
public MongoClientTestConfiguration() throws IOException {
Command command = Command.MongoD;
IDownloadConfig downloadConfig = new DownloadConfigBuilder().defaultsForCommand(command)
.progressListener(new Slf4jProgressListener(LOGGER))
.build();
IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder().defaults(command)
.artifactStore(new ExtractedArtifactStoreBuilder()
.defaults(command)
.download(downloadConfig))
.build();
final MongodStarter runtime = MongodStarter.getInstance(runtimeConfig);
mongodExecutable = runtime.prepare(newMongodConfig(Version.Main.PRODUCTION));
startMongodExecutable();
}
开发者ID:krraghavan,项目名称:mongodb-aggregate-query-support,代码行数:16,代码来源:MongoClientTestConfiguration.java
示例14: 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();
}
}
示例15: MongoInstance
import de.flapdoodle.embed.mongo.MongodStarter; //导入方法依赖的package包/类
public MongoInstance() throws IOException, InterruptedException {
// Download Mongo artifacts into the project directory to ease cleanup
IDownloadConfig downloadConfig = new DownloadConfigBuilder()
.defaultsForCommand(Command.MongoD)
.artifactStorePath(ARTIFACT_STORE_PATH)
.build();
// Extract Mongo artifacts into the project directory to ease cleanup
IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder()
.defaults(Command.MongoD)
.artifactStore(new ExtractedArtifactStoreBuilder()
.defaults(Command.MongoD)
.download(downloadConfig)
.extractDir(EXTRACTED_STORE_PATH)
)
.build();
// Store Mongo data into the project directory to ease cleanup
Storage replication = new Storage("./data/mongodb/data", null, 0);
MongodStarter starter = MongodStarter.getInstance(runtimeConfig);
IMongodConfig mongodConfig = new MongodConfigBuilder()
.version(Version.Main.PRODUCTION)
.cmdOptions(new MongoCmdOptionsBuilder()
.useNoJournal(false)
.useSmallFiles(true)
.build())
.net(new Net(MongoProperties.DEFAULT_PORT, Network.localhostIsIPv6()))
.replication(replication)
.build();
mongo = starter.prepare(mongodConfig);
process = mongo.start();
}