@Test
public void testGetNamenodeWebAddr() {

  HdfsConfiguration conf = new HdfsConfiguration();
  conf.set(DFSUtil.addKeySuffixes(
      DFS_NAMENODE_HTTPS_ADDRESS_KEY, "ns1", "nn1"), NS1_NN1_HTTPS_ADDR);
  conf.set(DFSUtil.addKeySuffixes(
      DFS_NAMENODE_HTTP_ADDRESS_KEY, "ns1", "nn1"), NS1_NN1_HTTP_ADDR);
  conf.set(DFS_HTTP_POLICY_KEY, HttpConfig.Policy.HTTPS_ONLY.name());
  String httpsOnlyWebAddr = DFSUtil.getNamenodeWebAddr(
      conf, "ns1", "nn1");
  assertEquals(NS1_NN1_HTTPS_ADDR, httpsOnlyWebAddr);
  conf.set(DFS_HTTP_POLICY_KEY, HttpConfig.Policy.HTTP_ONLY.name());
  String httpOnlyWebAddr = DFSUtil.getNamenodeWebAddr(
      conf, "ns1", "nn1");
  assertEquals(NS1_NN1_HTTP_ADDR, httpOnlyWebAddr);
  conf.set(DFS_HTTP_POLICY_KEY, HttpConfig.Policy.HTTP_AND_HTTPS.name());
  String httpAndHttpsWebAddr = DFSUtil.getNamenodeWebAddr(
      conf, "ns1", "nn1");
  assertEquals(NS1_NN1_HTTP_ADDR, httpAndHttpsWebAddr);
}