ConsoleCrossDcServer extends AbstractStartStoppable implements CrossDcClusterServer, LeaderAware, Observer, ApplicationContextAware { @Override public boolean amILeader() { return crossDcLeader; }  @Override boolean amILeader(); @Override void update(Object crossDcLeader, Observable observable); @Override List<String> getAllServers(); @Override void isleader(); @Override void notLeader(); synchronized void setCrossDcLeader(boolean crossDcLeader, String reason); void forceSetCrossLeader(ConfigModel config, Date until); void refreshCrossLeaderStatus(); @Override void setApplicationContext(ApplicationContext applicationContext);  }
@Test public void testNonSiteLeader() throws Exception { siteLeader.set(false); leaderDc = currentDc; crossDcClusterServer.start(); Assert.assertFalse(consoleLeaderElector.amILeader()); sleep(electInterval); Assert.assertFalse(crossDcClusterServer.amILeader()); }
@Test public void testValidLeader() throws Exception { siteLeader.set(true); leaderDc = currentDc; crossDcClusterServer.start(); Assert.assertTrue(consoleLeaderElector.amILeader()); waitConditionUntilTimeOut(() -> crossDcClusterServer.amILeader()); }