From dd2af6462d2b7c3e3130c469811f99ab2e72203e Mon Sep 17 00:00:00 2001 From: Christoph Strobl Date: Thu, 15 Nov 2018 08:24:17 +0100 Subject: [PATCH] DATAMONGO-2130 - Polishing. Set timeout for InetAdress host lookup to reduce test execution time. Original pull request: #618. --- .../config/ServerAddressPropertyEditorUnitTests.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/config/ServerAddressPropertyEditorUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/config/ServerAddressPropertyEditorUnitTests.java index 140b93720..5dfc01504 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/config/ServerAddressPropertyEditorUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/config/ServerAddressPropertyEditorUnitTests.java @@ -18,6 +18,7 @@ package org.springframework.data.mongodb.config; import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; +import java.io.IOException; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.Arrays; @@ -124,7 +125,8 @@ public class ServerAddressPropertyEditorUnitTests { * We can't tell whether the last part of the hostAddress represents a port or not. */ @Test // DATAMONGO-808 - public void shouldFailToHandleAmbiguousIPv6HostaddressLongWithoutPortAndWithoutBrackets() throws UnknownHostException { + public void shouldFailToHandleAmbiguousIPv6HostaddressLongWithoutPortAndWithoutBrackets() + throws UnknownHostException { expectedException.expect(IllegalArgumentException.class); @@ -173,9 +175,9 @@ public class ServerAddressPropertyEditorUnitTests { for (String hostname : hostnames) { try { - InetAddress.getByName(hostname); + InetAddress.getByName(hostname).isReachable(1500); Assert.fail("Supposedly unresolveable hostname '" + hostname + "' can be resolved."); - } catch (UnknownHostException expected) { + } catch (IOException expected) { // ok } }