|
@@ -615,20 +615,30 @@ public class TestNetUtils {
|
|
|
* Test for {@link NetUtils#normalizeHostNames}
|
|
|
*/
|
|
|
@Test
|
|
|
- public void testNormalizeHostName() {
|
|
|
- List<String> hosts = Arrays.asList(new String[] {"127.0.0.1",
|
|
|
- "localhost", "1.kanyezone.appspot.com", "UnknownHost123"});
|
|
|
+ public void testNormalizeHostName() {
|
|
|
+ String oneHost = "1.kanyezone.appspot.com";
|
|
|
+ try {
|
|
|
+ InetAddress.getByName(oneHost);
|
|
|
+ } catch (UnknownHostException e) {
|
|
|
+ Assume.assumeTrue("Network not resolving "+ oneHost, false);
|
|
|
+ }
|
|
|
+ List<String> hosts = Arrays.asList("127.0.0.1",
|
|
|
+ "localhost", oneHost, "UnknownHost123");
|
|
|
List<String> normalizedHosts = NetUtils.normalizeHostNames(hosts);
|
|
|
+ String summary = "original [" + StringUtils.join(hosts, ", ") + "]"
|
|
|
+ + " normalized [" + StringUtils.join(normalizedHosts, ", ") + "]";
|
|
|
// when ipaddress is normalized, same address is expected in return
|
|
|
- assertEquals(normalizedHosts.get(0), hosts.get(0));
|
|
|
+ assertEquals(summary, hosts.get(0), normalizedHosts.get(0));
|
|
|
// for normalizing a resolvable hostname, resolved ipaddress is expected in return
|
|
|
- assertFalse(normalizedHosts.get(1).equals(hosts.get(1)));
|
|
|
- assertEquals(normalizedHosts.get(1), hosts.get(0));
|
|
|
+ assertFalse("Element 1 equal "+ summary,
|
|
|
+ normalizedHosts.get(1).equals(hosts.get(1)));
|
|
|
+ assertEquals(summary, hosts.get(0), normalizedHosts.get(1));
|
|
|
// this address HADOOP-8372: when normalizing a valid resolvable hostname start with numeric,
|
|
|
// its ipaddress is expected to return
|
|
|
- assertFalse(normalizedHosts.get(2).equals(hosts.get(2)));
|
|
|
+ assertFalse("Element 2 equal " + summary,
|
|
|
+ normalizedHosts.get(2).equals(hosts.get(2)));
|
|
|
// return the same hostname after normalizing a irresolvable hostname.
|
|
|
- assertEquals(normalizedHosts.get(3), hosts.get(3));
|
|
|
+ assertEquals(summary, hosts.get(3), normalizedHosts.get(3));
|
|
|
}
|
|
|
|
|
|
@Test
|