### Question:
ActiveStandbyElector implements StatCallback, StringCallback { public synchronized void quitElection(boolean needFence) { LOG.info("Yielding from election"); if (!needFence && state == State.ACTIVE) { tryDeleteOwnBreadCrumbNode(); } reset(); wantToBeInElection = false; } ActiveStandbyElector(String zookeeperHostPorts,
      int zookeeperSessionTimeout, String parentZnodeName, List<ACL> acl,
      List<ZKAuthInfo> authInfo,
      ActiveStandbyElectorCallback app); synchronized void joinElection(byte[] data); synchronized boolean parentZNodeExists(); synchronized void ensureParentZNode(); synchronized void clearParentZNode(); synchronized void quitElection(boolean needFence); synchronized byte[] getActiveData(); @Override synchronized void processResult(int rc, String path, Object ctx,
      String name); @Override synchronized void processResult(int rc, String path, Object ctx,
      Stat stat); @Override String toString(); static final Log LOG; }### Answer:
@Test public void testQuitElection() throws Exception { elector.joinElection(data); Mockito.verify(mockZK, Mockito.times(0)).close(); elector.quitElection(true); Mockito.verify(mockZK, Mockito.times(1)).close(); verifyExistCall(0); byte[] data = new byte[8]; elector.joinElection(data); Assert.assertEquals(2, count); elector.processResult(Code.NODEEXISTS.intValue(), ZK_LOCK_NAME, mockZK, ZK_LOCK_NAME); Mockito.verify(mockApp, Mockito.times(1)).becomeStandby(); verifyExistCall(1); }