@Test
  public void testAlwaysStandBy() throws Exception {
    HBaseTestingUtil testUtil = miniClusterRule.getTestingUtility();
    // Make sure there is an active master.
    assertNotNull(testUtil.getMiniHBaseCluster().getMaster());
    assertEquals(2, testUtil.getMiniHBaseCluster().getMasterThreads().size());
    // Kill the only active master.
    testUtil.getMiniHBaseCluster().stopMaster(0).join();
    // Wait for 5s to make sure the always standby doesn't transition to active state.
    assertFalse(testUtil.getMiniHBaseCluster().waitForActiveAndReadyMaster(5000));
    // Add a new master.
    HMaster newActive = testUtil.getMiniHBaseCluster().startMaster().getMaster();
    assertTrue(testUtil.getMiniHBaseCluster().waitForActiveAndReadyMaster(5000));
    // Newly added master should be the active.
    assertEquals(newActive.getServerName(),
      testUtil.getMiniHBaseCluster().getMaster().getServerName());
  }
Tests that the AlwaysStandByHMaster does not transition to active state even if no active
master exists.
hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAlwaysStandByHMaster.java