Skip to content

Commit b2d2c12

Browse files
christophstroblmp911de
authored andcommitted
DATAMONGO-2130 - Polishing.
Set timeout for InetAdress host lookup to reduce test execution time. Original pull request: #618.
1 parent b50b645 commit b2d2c12

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

spring-data-mongodb/src/test/java/org/springframework/data/mongodb/config/ServerAddressPropertyEditorUnitTests.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import static org.hamcrest.Matchers.*;
1919
import static org.junit.Assert.*;
2020

21+
import java.io.IOException;
2122
import java.net.InetAddress;
2223
import java.net.UnknownHostException;
2324
import java.util.Arrays;
@@ -124,7 +125,8 @@ public void handleIPv6HostaddressLoopbackLongWithBrackets() throws UnknownHostEx
124125
* We can't tell whether the last part of the hostAddress represents a port or not.
125126
*/
126127
@Test // DATAMONGO-808
127-
public void shouldFailToHandleAmbiguousIPv6HostaddressLongWithoutPortAndWithoutBrackets() throws UnknownHostException {
128+
public void shouldFailToHandleAmbiguousIPv6HostaddressLongWithoutPortAndWithoutBrackets()
129+
throws UnknownHostException {
128130

129131
expectedException.expect(IllegalArgumentException.class);
130132

@@ -173,9 +175,9 @@ private void assertUnresolveableHostnames(String... hostnames) {
173175

174176
for (String hostname : hostnames) {
175177
try {
176-
InetAddress.getByName(hostname);
178+
InetAddress.getByName(hostname).isReachable(1500);
177179
Assert.fail("Supposedly unresolveable hostname '" + hostname + "' can be resolved.");
178-
} catch (UnknownHostException expected) {
180+
} catch (IOException expected) {
179181
// ok
180182
}
181183
}

0 commit comments

Comments
 (0)