Correct unit test flaw introduced in 54c9ecf682

Motivation:
54c9ecf682 introduced a unit tests which attempted to exclude addresses which resolved to loop back addresses from an assert statement. This was done with a static check for localhost but depending on machine configuration it is possible for other interfaces to be resolved.

Modifications:
- Use InetAddress#isLoopbackAddress() instead of string match on localhost

Result:
DnsNameResolverTest#testNameServerCache is more reliable.
This commit is contained in:
Scott Mitchell 2017-02-13 18:36:03 -08:00
parent a1b5b5dcca
commit 9ce74d46c1

View File

@ -385,7 +385,7 @@ public class DnsNameResolverTest {
try {
final Map<String, InetAddress> resultA = testResolve0(resolver, EXCLUSIONS_RESOLVE_A);
for (Entry<String, InetAddress> resolvedEntry : resultA.entrySet()) {
if (resolvedEntry.getValue().getHostAddress().equalsIgnoreCase("localhost")) {
if (resolvedEntry.getValue().isLoopbackAddress()) {
continue;
}
if (overridenHostnames.contains(resolvedEntry.getKey())) {