diff --git a/spring-boot-samples/spring-boot-sample-data-mongodb/src/test/java/sample/data/mongo/SampleMongoApplicationTests.java b/spring-boot-samples/spring-boot-sample-data-mongodb/src/test/java/sample/data/mongo/SampleMongoApplicationTests.java index 1da234e401..1b77d0043e 100644 --- a/spring-boot-samples/spring-boot-sample-data-mongodb/src/test/java/sample/data/mongo/SampleMongoApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-data-mongodb/src/test/java/sample/data/mongo/SampleMongoApplicationTests.java @@ -17,6 +17,7 @@ package sample.data.mongo; import java.io.IOException; +import java.net.ConnectException; import org.junit.Rule; import org.junit.Test; @@ -54,9 +55,9 @@ public class SampleMongoApplicationTests { @SuppressWarnings("serial") NestedCheckedException nested = new NestedCheckedException("failed", ex) { }; - if (nested.contains(IOException.class)) { + if (nested.contains(ConnectException.class)) { Throwable root = nested.getRootCause(); - if (root.getMessage().contains("couldn't connect to [localhost")) { + if (root.getMessage().contains("Connection refused")) { return true; } }