本文整理匯總了Java中de.flapdoodle.embed.mongo.MongodExecutable.start方法的典型用法代碼示例。如果您正苦於以下問題:Java MongodExecutable.start方法的具體用法?Java MongodExecutable.start怎麽用?Java MongodExecutable.start使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類de.flapdoodle.embed.mongo.MongodExecutable
的用法示例。
在下文中一共展示了MongodExecutable.start方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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");
}
示例2: 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);
}
}
示例3: 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();
}
示例4: 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();
}
示例5: 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();
}
示例6: 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;
}
示例7: setup_mongo
import de.flapdoodle.embed.mongo.MongodExecutable; //導入方法依賴的package包/類
@BeforeClass
public static void setup_mongo() throws UnknownHostException, IOException{
String proxyHost = System.getenv("http.proxyHost");
String proxyPort = System.getenv("http.proxyPort");
String proxy = System.getenv("http_proxy");
System.out.println("Proxy URL : " + proxy);
if(proxy != null){
if(proxyHost == null && proxyPort == null){
URL proxyurl = new URL(proxy);
proxyHost = proxyurl.getHost();
proxyPort = String.valueOf(proxyurl.getPort());
}
}
MongodStarter starter ;
System.out.println("Proxy Host : " + proxyHost);
System.out.println("Proxy Port : " + proxyPort);
if (proxyHost != null && proxyPort != null) {
IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder().defaults(Command.MongoD)
.artifactStore(
new ArtifactStoreBuilder().defaults(Command.MongoD)
.download(
new DownloadConfigBuilder()
.defaultsForCommand(Command.MongoD)
.proxyFactory(
new HttpProxyFactory(
proxyHost,
Integer.parseInt(proxyPort)))
.build()).build()).build();
starter = MongodStarter.getInstance(runtimeConfig);
} else {
starter = MongodStarter.getDefaultInstance();
}
IMongodConfig mongodConfig = new MongodConfigBuilder()
.version(Version.Main.PRODUCTION)
.net(new Net(mongoport, Network.localhostIsIPv6())).build();
MongodExecutable mongodExecutable = null;
mongodExecutable = starter.prepare(mongodConfig);
mongod = mongodExecutable.start();
}