use of de.flapdoodle.embed.mongo.config.Timeout in project logging-log4j2 by apache.
the class MongoDb3TestRule method apply.
@Override
public Statement apply(final Statement base, final Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
final String value = Objects.requireNonNull(System.getProperty(portSystemPropertyName), "System property '" + portSystemPropertyName + "' is null");
final int port = Integer.parseInt(value);
try {
mongodExecutable = starter.prepare(// @formatter:off
new MongodConfigBuilder().version(Version.Main.PRODUCTION).timeout(new Timeout(BUILDER_TIMEOUT_MILLIS)).net(new Net("localhost", port, Network.localhostIsIPv6())).build());
// @formatter:on
} catch (final IllegalArgumentException e) {
if (e.getMessage().contains("this version does not support 32Bit")) {
throw new AssumptionViolatedException("Unsupported platform: " + e.getMessage());
}
}
mongodProcess = mongodExecutable.start();
mongoClient = new MongoClient("localhost", port);
try {
base.evaluate();
} finally {
if (mongodProcess != null) {
mongodProcess.stop();
mongodProcess = null;
}
if (mongodExecutable != null) {
mongodExecutable.stop();
mongodExecutable = null;
}
}
}
};
}
use of de.flapdoodle.embed.mongo.config.Timeout in project logging-log4j2 by apache.
the class MongoDb4TestRule method apply.
@Override
public Statement apply(final Statement base, final Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
final String value = Objects.requireNonNull(System.getProperty(portSystemPropertyName), "System property '" + portSystemPropertyName + "' is null");
final int port = Integer.parseInt(value);
try {
mongodExecutable = starter.prepare(// @formatter:off
new MongodConfigBuilder().version(Version.Main.PRODUCTION).timeout(new Timeout(BUILDER_TIMEOUT_MILLIS)).net(new Net("localhost", port, Network.localhostIsIPv6())).build());
// @formatter:on
} catch (final IllegalArgumentException e) {
if (e.getMessage().contains("this version does not support 32Bit")) {
throw new AssumptionViolatedException("Unsupported platform: " + e.getMessage());
}
}
mongodProcess = mongodExecutable.start();
mongoClient = MongoClients.create("mongodb://localhost:" + port);
try {
base.evaluate();
} finally {
if (mongodProcess != null) {
mongodProcess.stop();
mongodProcess = null;
}
if (mongodExecutable != null) {
mongodExecutable.stop();
mongodExecutable = null;
}
}
}
};
}
use of de.flapdoodle.embed.mongo.config.Timeout in project embedmongo-maven-plugin by joelittlejohn.
the class MongoImportMojo method sendImportScript.
private void sendImportScript() throws IOException, InterruptedException, MojoExecutionException {
List<MongoImportProcess> pendingMongoProcess = new ArrayList<MongoImportProcess>();
if (imports == null || imports.length == 0) {
getLog().error("No imports found, check your configuration");
return;
}
getLog().info("Default import database: " + defaultImportDatabase);
for (ImportDataConfig importData : imports) {
getLog().info("Import " + importData);
verify(importData);
String database = importData.getDatabase();
if (StringUtils.isBlank(database)) {
database = defaultImportDatabase;
}
IMongoImportConfig mongoImportConfig = new MongoImportConfigBuilder().version(getVersion()).net(new Net(getPort(), NetworkUtils.localhostIsIPv6())).db(database).collection(importData.getCollection()).upsert(importData.getUpsertOnImport()).dropCollection(importData.getDropOnImport()).importFile(importData.getFile()).jsonArray(true).timeout(new Timeout(importData.getTimeout())).build();
MongoImportExecutable mongoImport = MongoImportStarter.getDefaultInstance().prepare(mongoImportConfig);
MongoImportProcess importProcess = mongoImport.start();
if (parallel) {
pendingMongoProcess.add(importProcess);
} else {
waitFor(importProcess);
}
}
for (MongoImportProcess importProcess : pendingMongoProcess) {
waitFor(importProcess);
}
}
Aggregations