LeaderStatusMonitor extends LeaderSelectorListenerAdapter implements AutoCloseable { public boolean isLeader() { if (isSingleNodeMode) { return true; } lock.lock(); @SuppressWarnings("FieldAccessNotGuarded") boolean leader = isLeader; lock.unlock(); return leader; } @VisibleForTesting protected  LeaderStatusMonitor(Configuration conf); @VisibleForTesting protected  LeaderStatusMonitor(Configuration conf, String incarnationId); @SuppressWarnings("LawOfDemeter") static synchronized LeaderStatusMonitor getLeaderStatusMonitor(Configuration conf); long getLeaderCount(); @Override void close(); void deactivate(); boolean isLeader(); @Override void takeLeadership(CuratorFramework client); @Override String toString();  }
@Test public void testNoZk() throws Exception { Configuration conf = new Configuration(); LeaderStatusMonitor monitor = new LeaderStatusMonitor(conf); assertTrue(monitor.isLeader()); }