### Question:
FailoverServer { public void run() { LOG.info("The server runs and prepares for leader election"); if (failoverWatcher.blockUntilActive()) { LOG.info("The server becomes active master and prepare to do business logic"); doAsActiveServer(); } failoverWatcher.close(); LOG.info("The server exits after running business logic"); } FailoverServer(FailoverWatcher failoverWatcher);  FailoverServer(Properties properties); FailoverWatcher getFailoverWatcher(); void run(); void doAsActiveServer(); static final String BASE_ZNODE; static final String ZK_QUORUM; static final String SESSION_TIMEOUT; static final String CONNECT_RETRY_TIMES; static final String ZK_SECURE; static final String ZK_ADMIN; static final String JAAS_FILE; static final String KRB5_FILE; static final String SERVER_HOST; static final String SERVER_PORT; }### Answer:
@Test public void testRun() throws KeeperException, InterruptedException, IOException { final TestableFailoverServer server1 = createFailoverServer(new HostPort("127.0.0.1", 11111)); Thread thread1 = new Thread() { @Override public void run() { server1.run(); } }; thread1.start(); final TestableFailoverServer server2 = createFailoverServer(new HostPort("127.0.0.1", 22222)); Thread thread2 = new Thread() { @Override public void run() { server2.run(); } }; thread2.start(); assertTrue(server1.isRunning()); assertFalse(server2.isRunning()); thread1.interrupt(); ZooKeeperUtil.deleteNode(server1.getFailoverWatcher(), server1.getFailoverWatcher() .getMasterZnode()); Thread.sleep(500); assertFalse(server1.isRunning()); assertTrue(server2.isRunning()); thread2.interrupt(); server1.getFailoverWatcher().close(); server2.getFailoverWatcher().close(); }