### Question:
KerberosOperationHandler { public void setAdministratorCredential(PrincipalKeyCredential administratorCredential) throws KerberosAdminAuthenticationException { if (administratorCredential == null) { throw new KerberosAdminAuthenticationException("The administrator credential must not be null"); } String principal = administratorCredential.getPrincipal(); if (StringUtils.isEmpty(principal)) { throw new KerberosAdminAuthenticationException("Must specify a principal but it is null or empty"); } char[] password = administratorCredential.getKey(); if (ArrayUtils.isEmpty(password)) { throw new KerberosAdminAuthenticationException("Must specify a password but it is null or empty"); } this.administratorCredential = administratorCredential; }  void open(PrincipalKeyCredential administratorCredential, String defaultRealm, Map<String, String> kerberosConfiguration); void close(); abstract boolean principalExists(String principal, boolean service); abstract Integer createPrincipal(String principal, String password, boolean service); abstract Integer setPrincipalPassword(String principal, String password, boolean service); abstract boolean removePrincipal(String principal, boolean service); boolean testAdministratorCredentials(); boolean createKeytabFile(Keytab keytab, File destinationKeytabFile); PrincipalKeyCredential getAdministratorCredential(); void setAdministratorCredential(PrincipalKeyCredential administratorCredential); String getDefaultRealm(); void setDefaultRealm(String defaultRealm); Set<EncryptionType> getKeyEncryptionTypes(); void setKeyEncryptionTypes(Set<EncryptionType> keyEncryptionTypes); String[] getExecutableSearchPaths(); void setExecutableSearchPaths(String[] executableSearchPaths); void setExecutableSearchPaths(String delimitedExecutableSearchPaths); boolean isOpen(); void setOpen(boolean open); final static String KERBEROS_ENV_LDAP_URL; final static String KERBEROS_ENV_PRINCIPAL_CONTAINER_DN; final static String KERBEROS_ENV_USER_PRINCIPAL_GROUP; final static String KERBEROS_ENV_AD_CREATE_ATTRIBUTES_TEMPLATE; final static String KERBEROS_ENV_KDC_CREATE_ATTRIBUTES; final static String KERBEROS_ENV_ENCRYPTION_TYPES; final static String KERBEROS_ENV_KDC_HOSTS; final static String KERBEROS_ENV_ADMIN_SERVER_HOST; final static String KERBEROS_ENV_KADMIN_PRINCIPAL_NAME; final static String KERBEROS_ENV_EXECUTABLE_SEARCH_PATHS; }### Answer:
@Test(expected = KerberosAdminAuthenticationException.class) public void testAdminCredentialsNullPrincipal() throws KerberosOperationException { KerberosOperationHandler handler = createHandler(); PrincipalKeyCredential credentials = new PrincipalKeyCredential(null, "password"); handler.setAdministratorCredential(credentials); }
@Test(expected = KerberosAdminAuthenticationException.class) public void testAdminCredentialsEmptyPrincipal() throws KerberosOperationException { KerberosOperationHandler handler = createHandler(); PrincipalKeyCredential credentials = new PrincipalKeyCredential("", "password"); handler.setAdministratorCredential(credentials); }
@Test(expected = KerberosAdminAuthenticationException.class) public void testAdminCredentialsNullCredential() throws KerberosOperationException { KerberosOperationHandler handler = createHandler(); PrincipalKeyCredential credentials = new PrincipalKeyCredential("principal", (char[]) null); handler.setAdministratorCredential(credentials); }
@Test(expected = KerberosAdminAuthenticationException.class) public void testAdminCredentialsEmptyCredential1() throws KerberosOperationException { KerberosOperationHandler handler = createHandler(); PrincipalKeyCredential credentials = new PrincipalKeyCredential("principal", ""); handler.setAdministratorCredential(credentials); }