@Test
  public void testMasterAddressTrackerFromZK() throws Exception {
    // Create the master node with a dummy address
    final int infoPort = 1235;
    final ServerName sn =
      ServerName.valueOf("localhost", 1234, EnvironmentEdgeManager.currentTime());
    final MasterAddressTracker addressTracker = setupMasterTracker(sn, infoPort);
    try {
      assertTrue(addressTracker.hasMaster());
      ServerName pulledAddress = addressTracker.getMasterAddress();
      assertTrue(pulledAddress.equals(sn));
      assertEquals(infoPort, addressTracker.getMasterInfoPort());
    } finally {
      assertTrue("Couldn't clean up master",
        MasterAddressTracker.deleteIfEquals(addressTracker.getWatcher(), sn.toString()));
    }
  }
Unit tests that uses ZooKeeper but does not use the master-side methods but rather acts
directly on ZK.
hbase-zookeeper/src/test/java/org/apache/hadoop/hbase/zookeeper/TestMasterAddressTracker.java