6
6
import org .junit .Test ;
7
7
import org .junit .runner .RunWith ;
8
8
import org .junit .runners .Parameterized ;
9
+ import org .slf4j .Logger ;
10
+ import org .slf4j .LoggerFactory ;
9
11
10
12
import java .net .InetAddress ;
11
13
import java .util .Arrays ;
21
23
22
24
@ RunWith (Parameterized .class )
23
25
public class AdvancedHostResolverCacheTest {
26
+ private static final Logger log = LoggerFactory .getLogger (AdvancedHostResolverCacheTest .class );
27
+
24
28
@ Parameterized .Parameters
25
29
public static Collection <Object []> data () {
26
30
return Arrays .asList (new Object [][]{
@@ -194,13 +198,13 @@ public void testSetEternalPositiveCacheTtl() {
194
198
resolver .clearDNSCache ();
195
199
resolver .setPositiveDNSCacheTimeout (-1 , TimeUnit .SECONDS );
196
200
197
- System . out . println ( "Resolver: " + resolver );
201
+ log . info ( "Using resolver: {}" , resolver . getClass (). getSimpleName () );
198
202
199
203
// populate the cache
200
204
long one = System .nanoTime ();
201
205
Collection <InetAddress > addresses = resolver .resolve ("www.msn.com" );
202
206
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 ));
204
208
205
209
// make sure there are addresses, since this is a *positive* TTL test
206
210
assertNotNull ("Collection of resolved addresses should never be null" , addresses );
@@ -212,7 +216,7 @@ public void testSetEternalPositiveCacheTtl() {
212
216
213
217
long cachedLookupMs = TimeUnit .MILLISECONDS .convert (finish - start , TimeUnit .NANOSECONDS );
214
218
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 ));
216
220
217
221
assertNotNull ("Collection of resolved addresses should never be null" , addresses );
218
222
assertNotEquals ("Expected to find addresses for www.msn.com" , 0 , addresses .size ());
0 commit comments