Skip to content

Commit 73de078

Browse files
committed
Minor updates to host resolver tests
1 parent 09e4f3a commit 73de078

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

browsermob-core/src/test/java/net/lightbody/bmp/proxy/dns/AdvancedHostResolverCacheTest.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import org.junit.Test;
77
import org.junit.runner.RunWith;
88
import org.junit.runners.Parameterized;
9+
import org.slf4j.Logger;
10+
import org.slf4j.LoggerFactory;
911

1012
import java.net.InetAddress;
1113
import java.util.Arrays;
@@ -21,6 +23,8 @@
2123

2224
@RunWith(Parameterized.class)
2325
public class AdvancedHostResolverCacheTest {
26+
private static final Logger log = LoggerFactory.getLogger(AdvancedHostResolverCacheTest.class);
27+
2428
@Parameterized.Parameters
2529
public static Collection<Object[]> data() {
2630
return Arrays.asList(new Object[][]{
@@ -194,13 +198,13 @@ public void testSetEternalPositiveCacheTtl() {
194198
resolver.clearDNSCache();
195199
resolver.setPositiveDNSCacheTimeout(-1, TimeUnit.SECONDS);
196200

197-
System.out.println("Resolver: " + resolver);
201+
log.info("Using resolver: {}", resolver.getClass().getSimpleName());
198202

199203
// populate the cache
200204
long one = System.nanoTime();
201205
Collection<InetAddress> addresses = resolver.resolve("www.msn.com");
202206
long two = System.nanoTime();
203-
System.out.println("Time to resolve without cache: " + TimeUnit.MILLISECONDS.convert(two - one, TimeUnit.NANOSECONDS));
207+
log.info("Time to resolve address without cache: {}ms", TimeUnit.MILLISECONDS.convert(two - one, TimeUnit.NANOSECONDS));
204208

205209
// make sure there are addresses, since this is a *positive* TTL test
206210
assertNotNull("Collection of resolved addresses should never be null", addresses);
@@ -212,7 +216,7 @@ public void testSetEternalPositiveCacheTtl() {
212216

213217
long cachedLookupMs = TimeUnit.MILLISECONDS.convert(finish - start, TimeUnit.NANOSECONDS);
214218

215-
System.out.println("Time to resolve with cache: " + TimeUnit.MILLISECONDS.convert(finish - start, TimeUnit.NANOSECONDS));
219+
log.info("Time to resolve address with cache: {}ms", TimeUnit.MILLISECONDS.convert(finish - start, TimeUnit.NANOSECONDS));
216220

217221
assertNotNull("Collection of resolved addresses should never be null", addresses);
218222
assertNotEquals("Expected to find addresses for www.msn.com", 0, addresses.size());

browsermob-core/src/test/java/net/lightbody/bmp/proxy/dns/AdvancedHostResolverTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,8 @@ public void testResolveIPv4AndIPv6Addresses() {
9696

9797
// disabling this assert to prevent test failures on systems without ipv6 access, or when the DNS server does not return IPv6 addresses
9898
//assertTrue("Expected to find at least one IPv6 address for www.google.com", foundIPv6);
99-
if (!foundIPv6) {
100-
log.warn("Could not resolve IPv6 address for www.google.com using resolver {}", resolver.getClass().getSimpleName());
101-
}
99+
// update: since the dnsjava resolver now returns ipv6 addresses *only if there are no ipv4 addresses*, it will generally not return
100+
// any ipv6 addresses for most hostnames
102101

103102
}
104103

0 commit comments

Comments
 (0)