### Question:
MITKerberosOperationHandler extends KDCKerberosOperationHandler { @Override public boolean principalExists(String principal, boolean service) throws KerberosOperationException { if (!isOpen()) { throw new KerberosOperationException("This operation handler has not been opened"); } if (!StringUtils.isEmpty(principal)) { ShellCommandUtil.Result result = invokeKAdmin(String.format("get_principal %s", principal)); String stdOut = result.getStdout(); return (stdOut != null) && stdOut.contains(String.format("Principal: %s", principal)); } return false; }  @Override void open(PrincipalKeyCredential administratorCredentials, String realm, Map<String, String> kerberosConfiguration); @Override void close(); @Override boolean principalExists(String principal, boolean service); @Override Integer createPrincipal(String principal, String password, boolean service); @Override boolean removePrincipal(String principal, boolean service);  }### Answer:
@Test public void testSetPrincipalPassword() throws Exception { MITKerberosOperationHandler handler = createMockedHandler(methodIsOpen, methodPrincipalExists); expect(handler.isOpen()).andReturn(true).atLeastOnce(); expect(handler.principalExists(DEFAULT_ADMIN_PRINCIPAL, false)).andReturn(true).atLeastOnce(); expect(handler.principalExists(null, false)).andReturn(false).atLeastOnce(); expect(handler.principalExists("", false)).andReturn(false).atLeastOnce(); replayAll(); Integer expected = 0; Assert.assertEquals(expected, handler.setPrincipalPassword(DEFAULT_ADMIN_PRINCIPAL, null, false)); Assert.assertEquals(expected, handler.setPrincipalPassword(DEFAULT_ADMIN_PRINCIPAL, "", false)); try { handler.setPrincipalPassword(null, DEFAULT_ADMIN_PASSWORD, false); Assert.fail("Expected KerberosPrincipalDoesNotExistException"); } catch (KerberosPrincipalDoesNotExistException e) { } try { handler.setPrincipalPassword("", DEFAULT_ADMIN_PASSWORD, false); Assert.fail("Expected KerberosPrincipalDoesNotExistException"); } catch (KerberosPrincipalDoesNotExistException e) { } verifyAll(); }