1717/**
1818 * @author Jerry Lee (oldratlee at gmail dot com)
1919 */
20+ @ SuppressWarnings ("ConstantConditions" )
2021public class DnsCacheManipulatorTest {
2122 private static final String IP1 = "42.42.42.1" ;
2223 private static final String IP2 = "42.42.42.2" ;
23- private static final String IP_CUSTOMIZED = "42.42.42.42" ;
24-
25- private static final String DOMAIN1 = "www.hello1.com" ;
26- private static final String DOMAIN2 = "www.hello2.com" ;
27- private static final String DOMAIN_CUSTOMIZED = "www.customized.com" ;
24+ private static final String IP3 = "42.42.42.3" ;
25+ private static final String IP4 = "42.42.42.4" ;
2826
2927 private static final String DOMAIN_NOT_EXISTED = "www.domain-not-existed-2D4B2C4E-61D5-46B3-81FA-3A975156D1AE.com" ;
3028 private static final String EXISTED_DOMAIN = "bing.com" ;
@@ -263,7 +261,7 @@ public void test_setNegativeDnsCachePolicy() throws Exception {
263261 @ Test
264262 public void test_loadDnsCacheConfig () throws Exception {
265263 DnsCacheManipulator .loadDnsCacheConfig ();
266- final String ip = lookupIpByName (DOMAIN1 );
264+ final String ip = lookupIpByName ("www.hello1.com" );
267265 assertEquals (IP1 , ip );
268266 }
269267
@@ -274,8 +272,8 @@ public void test_loadDnsCacheConfig_from_D_Option() throws Exception {
274272 System .setProperty (key , "customized-dns-cache.properties" );
275273 DnsCacheManipulator .loadDnsCacheConfig ();
276274
277- final String ip = lookupIpByName (DOMAIN_CUSTOMIZED );
278- assertEquals (IP_CUSTOMIZED , ip );
275+ final String ip = lookupIpByName ("www.customized.com" );
276+ assertEquals (IP2 , ip );
279277 } finally {
280278 System .clearProperty (key );
281279 }
@@ -284,7 +282,7 @@ public void test_loadDnsCacheConfig_from_D_Option() throws Exception {
284282 @ Test
285283 public void test_loadDnsCacheConfig_fromMyConfig () throws Exception {
286284 DnsCacheManipulator .loadDnsCacheConfig ("my-dns-cache.properties" );
287- final String ip = lookupIpByName (DOMAIN2 );
285+ final String ip = lookupIpByName ("www.hello2.com" );
288286 assertEquals (IP2 , ip );
289287 }
290288
@@ -294,14 +292,14 @@ public void test_multi_ips_in_config_file() {
294292
295293 final String host = "www.hello-multi-ips.com" ;
296294 DnsCacheEntry expected = new DnsCacheEntry (host ,
297- new String []{"42.42.41.1" , "42.42.41.2" }, Long .MAX_VALUE );
295+ new String []{IP1 , IP2 }, Long .MAX_VALUE );
298296
299297 final DnsCacheEntry actual = DnsCacheManipulator .getDnsCache (host );
300298 assertEqualsIgnoreHostCase (expected , actual );
301299
302300 final String hostLoose = "www.hello-multi-ips-loose.com" ;
303301 DnsCacheEntry expectedLoose = new DnsCacheEntry (hostLoose ,
304- new String []{"42.42.41.1" , "42.42.41.2" , "42.42.41.3" , "42.42.41.4" }, Long .MAX_VALUE );
302+ new String []{IP1 , IP2 , IP3 , IP4 }, Long .MAX_VALUE );
305303
306304 DnsCacheEntry actualLoose = DnsCacheManipulator .getDnsCache (hostLoose );
307305 assertEqualsIgnoreHostCase (expectedLoose , actualLoose );
0 commit comments