@Test
  public void testMasterInitWithObserverModeClientZKQuorum() throws Exception {
    Configuration conf = new Configuration(TESTUTIL.getConfiguration());
    Assert.assertFalse(Boolean.getBoolean(HConstants.CLIENT_ZOOKEEPER_OBSERVER_MODE));
    // set client ZK to some non-existing address and make sure server won't access client ZK
    // (server start should not be affected)
    conf.set(HConstants.CLIENT_ZOOKEEPER_QUORUM, HConstants.LOCALHOST);
    conf.setInt(HConstants.CLIENT_ZOOKEEPER_CLIENT_PORT,
      TESTUTIL.getZkCluster().getClientPort() + 1);
    // need to enable maintenance mode so we will start master and an in process region server
    conf.setBoolean(HMaster.MAINTENANCE_MODE, true);
    // settings to allow us not to start additional RS
    conf.setInt(ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART, 1);
    // main setting for this test case
    conf.setBoolean(HConstants.CLIENT_ZOOKEEPER_OBSERVER_MODE, true);
    HMaster master = new HMaster(conf);
    master.start();
    while (!master.isInitialized()) {
      Threads.sleep(200);
    }
    Assert.assertNull(master.getMetaLocationSyncer());
    Assert.assertNull(master.masterAddressSyncer);
    master.stopMaster();
    master.join();
  }
Test starting master then stopping it before its fully up.
hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterNoCluster.java