### Question:
SecurityUtil { @Nullable public static String expandPrincipal(@Nullable String principal) throws UnknownHostException { if (principal == null) { return principal; } String localHostname = InetAddress.getLocalHost().getCanonicalHostName(); return principal.replace("/_HOST@", "/" + localHostname + "@"); } private  SecurityUtil(); static void enableKerberosLogin(CConfiguration cConf); @Nullable static String expandPrincipal(@Nullable String principal); static boolean isKerberosEnabled(CConfiguration cConf); static String getMasterPrincipal(CConfiguration cConf); static String getMasterKeytabURI(CConfiguration cConf); static void loginForMasterService(CConfiguration cConf); static KerberosName getKerberosName(KerberosPrincipalId principalId); static void validateKerberosPrincipal(KerberosPrincipalId principalId); static void validateKerberosPrincipal(String principal); static ImpersonationInfo createImpersonationInfo(OwnerAdmin ownerAdmin, CConfiguration cConf,
                                                          NamespacedEntityId entityId); static void verifyOwnerPrincipal(NamespacedEntityId existingEntity,
                                          @Nullable String specifiedOwnerPrincipal,
                                          OwnerAdmin ownerAdmin); @Nullable static KerberosPrincipalId getEffectiveOwner(OwnerAdmin ownerAdmin, NamespaceId namespaceId,
                                                      @Nullable String ownerPrincipal);  }### Answer:
@Test public void testExpandPrincipal() throws Exception { String localHostname = InetAddress.getLocalHost().getCanonicalHostName(); Assert.assertNull(SecurityUtil.expandPrincipal(null)); Assert.assertEquals("user/" + localHostname + "@REALM.NET", SecurityUtil.expandPrincipal("user/_HOST@REALM.NET")); Assert.assertEquals("user/abc.com@REALM.NET", SecurityUtil.expandPrincipal("user/abc.com@REALM.NET")); Assert.assertEquals("_HOST/abc.com@REALM.NET", SecurityUtil.expandPrincipal("_HOST/abc.com@REALM.NET")); Assert.assertEquals("_HOST/" + localHostname + "@REALM.NET", SecurityUtil.expandPrincipal("_HOST/_HOST@REALM.NET")); Assert.assertEquals("user/_host@REALM.NET", SecurityUtil.expandPrincipal("user/_host@REALM.NET")); }