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:
Janne Valkealahti
2017-02-10 16:12:03 +00:00
parent 573397b86e
commit 1a3f7da81c
2 changed files with 6 additions and 4 deletions

View File

@@ -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() {

View File

@@ -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() {