### Question:
ZookeeperClusterStatus extends ClusterStatus { @Override public boolean isInSafeMode(boolean useCache, String cluster) { if (useCache) { Long safeModeTimestamp = _safeModeMap.get(cluster); if (safeModeTimestamp != null && safeModeTimestamp != Long.MIN_VALUE) { return safeModeTimestamp < System.currentTimeMillis() ? false : true; } } long s = System.nanoTime(); try { checkIfOpen(); String blurSafemodePath = ZookeeperPathConstants.getSafemodePath(cluster); Stat stat = _zk.exists(blurSafemodePath, false); if (stat == null) { return false; } byte[] data = _zk.getData(blurSafemodePath, false, stat); if (data == null) { return false; } long timestamp = Long.parseLong(new String(data)); long waitTime = timestamp - System.currentTimeMillis(); if (waitTime > 0) { return true; } return false; } catch (KeeperException e) { throw new RuntimeException(e); } catch (InterruptedException e) { throw new RuntimeException(e); } finally { long e = System.nanoTime(); LOG.debug("trace isInSafeMode took [" + (e - s) / 1000000.0 + " ms]"); } } ZookeeperClusterStatus(ZooKeeper zooKeeper);  ZookeeperClusterStatus(String connectionStr); @Override List<String> getClusterList(boolean useCache); @Override List<String> getControllerServerList(); @Override List<String> getOnlineShardServers(boolean useCache, String cluster); @Override List<String> getShardServerList(String cluster); @Override boolean exists(boolean useCache, String cluster, String table); @Override boolean isEnabled(boolean useCache, String cluster, String table); @Override TableDescriptor getTableDescriptor(boolean useCache, String cluster, String table); @Override List<String> getTableList(boolean useCache, String cluster); void close(); @Override String getCluster(boolean useCache, String table); @Override boolean isInSafeMode(boolean useCache, String cluster); @Override int getShardCount(boolean useCache, String cluster, String table); @Override Set<String> getBlockCacheFileTypes(String cluster, String table); @Override boolean isBlockCacheEnabled(String cluster, String table); @Override boolean isReadOnly(boolean useCache, String cluster, String table); @Override void createTable(TableDescriptor tableDescriptor); @Override void disableTable(String cluster, String table); @Override void enableTable(String cluster, String table); @Override void removeTable(String cluster, String table, boolean deleteIndexFiles); @Override boolean isOpen();  }### Answer:
@Test public void testSafeModeNotSet() throws KeeperException, InterruptedException { LOG.warn("testSafeModeNotSet"); assertFalse(clusterStatus.isInSafeMode(false, DEFAULT)); new WaitForAnswerToBeCorrect(20L) { @Override public Object run() { return clusterStatus.isInSafeMode(true, DEFAULT); } }.test(false); }
@Test public void testSafeModeSetInPast() throws KeeperException, InterruptedException { LOG.warn("testSafeModeSetInPast"); setSafeModeInPast(); assertFalse(clusterStatus.isInSafeMode(false, DEFAULT)); new WaitForAnswerToBeCorrect(20L) { @Override public Object run() { return clusterStatus.isInSafeMode(true, DEFAULT); } }.test(false); }
@Test public void testSafeModeSetInFuture() throws KeeperException, InterruptedException { LOG.warn("testSafeModeSetInFuture"); setSafeModeInFuture(); assertTrue(clusterStatus.isInSafeMode(false, DEFAULT)); new WaitForAnswerToBeCorrect(20L) { @Override public Object run() { return clusterStatus.isInSafeMode(true, DEFAULT); } }.test(true); }