Make mongo tests faster
- There is a newer mongo client with changed behaviour as junit rule skipping tests if mongo is not running waits 30s for a connect failure. Add new server select timeout. - Fixes #314
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 the original author or authors.
|
||||
* Copyright 2016-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -35,7 +35,8 @@ public class MongoDbRule extends TestWatcher implements TestRule {
|
||||
public Statement apply(Statement base, Description description) {
|
||||
MongoClient client = null;
|
||||
try {
|
||||
client = new MongoClient(new ServerAddress(), MongoClientOptions.builder().connectTimeout(50).build());
|
||||
client = new MongoClient(new ServerAddress(),
|
||||
MongoClientOptions.builder().connectTimeout(50).serverSelectionTimeout(50).build());
|
||||
client.getAddress();
|
||||
} catch (Exception e) {
|
||||
return super.apply(new Statement() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 the original author or authors.
|
||||
* Copyright 2016-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -35,7 +35,8 @@ public class MongoDbRule extends TestWatcher implements TestRule {
|
||||
public Statement apply(Statement base, Description description) {
|
||||
MongoClient client = null;
|
||||
try {
|
||||
client = new MongoClient(new ServerAddress(), MongoClientOptions.builder().connectTimeout(50).build());
|
||||
client = new MongoClient(new ServerAddress(),
|
||||
MongoClientOptions.builder().connectTimeout(50).serverSelectionTimeout(50).build());
|
||||
client.getAddress();
|
||||
} catch (Exception e) {
|
||||
return super.apply(new Statement() {
|
||||
|
||||
Reference in New Issue
Block a user