From c0079840be596ab26ace825fcd0e99809ac527d4 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Sat, 25 Oct 2014 17:29:06 +0900 Subject: [PATCH] Improve DnsNameResolverTest.testResolveA() Motivation: DnsNameResolver.testResolveA() tests if the cache works as well as the usual DNS protocol test. To ensure the result from the cache is identical to the result without cache, it compares the two Maps which contain the result of cached/uncached resolution. The comparison of two Maps yields an expected behavior, but the output of the comparison on failure is often unreadable due to its long length. Modifications: Compare entry-by-entry for more comprehensible test failure output Result: When failure occurs, it's easier to see which domain was the cause of the problem. --- .../java/io/netty/resolver/dns/DnsNameResolverTest.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/resolver-dns/src/test/java/io/netty/resolver/dns/DnsNameResolverTest.java b/resolver-dns/src/test/java/io/netty/resolver/dns/DnsNameResolverTest.java index 65d5418aa7..9bb1a40904 100644 --- a/resolver-dns/src/test/java/io/netty/resolver/dns/DnsNameResolverTest.java +++ b/resolver-dns/src/test/java/io/netty/resolver/dns/DnsNameResolverTest.java @@ -286,7 +286,13 @@ public class DnsNameResolverTest { final Map resultB = testResolve0(EXCLUSIONS_RESOLVE_A, InternetProtocolFamily.IPv4); - assertThat(resultA, is(resultB)); + // Ensure the result from the cache is identical from the uncached one. + assertThat(resultB.size(), is(resultA.size())); + for (Entry e: resultA.entrySet()) { + InetAddress expected = e.getValue(); + InetAddress actual = resultB.get(e.getKey()); + assertThat(actual, is(expected)); + } } finally { // Restore the TTL configuration. resolver.setTtl(oldMinTtl, oldMaxTtl);