@Test
public void testGetActiveData() throws ActiveNotFoundException,
    KeeperException, InterruptedException, IOException {

  // get valid active data
  byte[] data = new byte[8];
  Mockito.when(
      mockZK.getData(Mockito.eq(ZK_LOCK_NAME), Mockito.eq(false),
          Mockito.<Stat> anyObject())).thenReturn(data);
  Assert.assertEquals(data, elector.getActiveData());
  Mockito.verify(mockZK, Mockito.times(1)).getData(
      Mockito.eq(ZK_LOCK_NAME), Mockito.eq(false),
      Mockito.<Stat> anyObject());
  // active does not exist
  Mockito.when(
      mockZK.getData(Mockito.eq(ZK_LOCK_NAME), Mockito.eq(false),
          Mockito.<Stat> anyObject())).thenThrow(
      new KeeperException.NoNodeException());
  try {
    elector.getActiveData();
    Assert.fail("ActiveNotFoundException expected");
  } catch(ActiveNotFoundException e) {
    Mockito.verify(mockZK, Mockito.times(2)).getData(
        Mockito.eq(ZK_LOCK_NAME), Mockito.eq(false),
        Mockito.<Stat> anyObject());
  }
  // error getting active data rethrows keeperexception
  try {
    Mockito.when(
        mockZK.getData(Mockito.eq(ZK_LOCK_NAME), Mockito.eq(false),
            Mockito.<Stat> anyObject())).thenThrow(
        new KeeperException.AuthFailedException());
    elector.getActiveData();
    Assert.fail("KeeperException.AuthFailedException expected");
  } catch(KeeperException.AuthFailedException ke) {
    Mockito.verify(mockZK, Mockito.times(3)).getData(
        Mockito.eq(ZK_LOCK_NAME), Mockito.eq(false),
        Mockito.<Stat> anyObject());
  }
}