Skip to content

Commit fe58d13

Browse files
committed
test: cleanup unit test
1 parent e31aa06 commit fe58d13

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed

library/src/test/java/com/alibaba/dcm/DnsCacheManipulatorTest.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,12 @@
1717
/**
1818
* @author Jerry Lee (oldratlee at gmail dot com)
1919
*/
20+
@SuppressWarnings("ConstantConditions")
2021
public 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);

library/src/test/java/com/alibaba/dcm/agent/DcmAgentTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
/**
1616
* @author Jerry Lee (oldratlee at gmail dot com)
1717
*/
18+
@SuppressWarnings("ConstantConditions")
1819
public class DcmAgentTest {
1920
private static final String UTF8 = "UTF-8";
2021

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
www.customized.com=42.42.42.42
1+
www.customized.com=42.42.42.2
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
www.hello-multi-ips.com=42.42.41.1,42.42.41.2
2-
www.hello-multi-ips-loose.com=42.42.41.1 , 42.42.41.2, 42.42.41.3 ,42.42.41.4
1+
www.hello-multi-ips.com=42.42.42.1,42.42.42.2
2+
www.hello-multi-ips-loose.com= 42.42.42.1 , 42.42.42.2, 42.42.42.3 ,42.42.42.4

0 commit comments

Comments
 (0)