Speed Up Mongo Build When No Mongo
@Rule used a 10 second connection timeout. Polishing Conflicts: spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/rules/MongoDbAvailableRule.java Accept changes according to the current version of Mongo driver
This commit is contained in:
committed by
Artem Bilan
parent
3be6016987
commit
34f340a879
@@ -23,6 +23,8 @@ import org.junit.runners.model.FrameworkMethod;
|
||||
import org.junit.runners.model.Statement;
|
||||
|
||||
import com.mongodb.Mongo;
|
||||
import com.mongodb.MongoOptions;
|
||||
import com.mongodb.ServerAddress;
|
||||
|
||||
/**
|
||||
* A {@link MethodRule} implementation that checks for a running MongoDB process.
|
||||
@@ -35,6 +37,7 @@ public final class MongoDbAvailableRule implements MethodRule {
|
||||
|
||||
private final Log logger = LogFactory.getLog(this.getClass());
|
||||
|
||||
@Override
|
||||
public Statement apply(final Statement base, final FrameworkMethod method, final Object target) {
|
||||
return new Statement() {
|
||||
@Override
|
||||
@@ -42,7 +45,9 @@ public final class MongoDbAvailableRule implements MethodRule {
|
||||
MongoDbAvailable mongoAvailable = method.getAnnotation(MongoDbAvailable.class);
|
||||
if (mongoAvailable != null) {
|
||||
try {
|
||||
Mongo mongo = new Mongo();
|
||||
MongoOptions options = new MongoOptions();
|
||||
options.setConnectTimeout(100);
|
||||
Mongo mongo = new Mongo(ServerAddress.defaultHost(), options);
|
||||
mongo.getDatabaseNames();
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
||||
Reference in New Issue
Block a user