@Test
public void testGetRMPrincipalStandAlone_Configuration() throws IOException {

  Configuration conf = new Configuration();
  conf.set(YarnConfiguration.RM_ADDRESS, "myhost");
  conf.setBoolean(YarnConfiguration.RM_HA_ENABLED, false);
  String result = YarnClientUtils.getRmPrincipal(conf);
  assertNull("The hostname translation did return null when the principal is "
      + "missing from the conf: " + result, result);
  conf = new Configuration();
  conf.set(YarnConfiguration.RM_ADDRESS, "myhost");
  conf.set(YarnConfiguration.RM_PRINCIPAL, "test/_HOST@REALM");
  conf.setBoolean(YarnConfiguration.RM_HA_ENABLED, false);
  result = YarnClientUtils.getRmPrincipal(conf);
  assertEquals("The hostname translation did not produce the expected "
      + "results: " + result, "test/myhost@REALM", result);
  conf.set(YarnConfiguration.RM_PRINCIPAL, "test/yourhost@REALM");
  result = YarnClientUtils.getRmPrincipal(conf);
  assertEquals("The hostname translation did not produce the expected "
      + "results: " + result, "test/yourhost@REALM", result);
}