### Question:
ZooCacheFactory { public ZooCache getZooCache(String zooKeepers, int sessionTimeout) { String key = zooKeepers + ":" + sessionTimeout; synchronized (instances) { if (!isEnabled()) { throw new IllegalStateException("\"The Accumulo singleton for zookeeper caching is " + "disabled. This is likely caused by all AccumuloClients being closed"); } ZooCache zc = instances.get(key); if (zc == null) { zc = new ZooCache(zooKeepers, sessionTimeout); instances.put(key, zc); } return zc; } }  ZooCache getZooCache(String zooKeepers, int sessionTimeout); ZooCache getZooCache(String zooKeepers, int sessionTimeout, Watcher watcher);  }### Answer:
@Test public void testGetZooCache() { String zks1 = "zk1"; int timeout1 = 1000; ZooCache zc1 = zcf.getZooCache(zks1, timeout1); ZooCache zc1a = zcf.getZooCache(zks1, timeout1); assertSame(zc1, zc1a); String zks2 = "zk2"; int timeout2 = 1000; ZooCache zc2 = zcf.getZooCache(zks2, timeout2); assertNotSame(zc1, zc2); String zks3 = "zk1"; int timeout3 = 2000; ZooCache zc3 = zcf.getZooCache(zks3, timeout3); assertNotSame(zc1, zc3); }
@Test public void testGetZooCacheWatcher() { String zks1 = "zk1"; int timeout1 = 1000; Watcher watcher = createMock(Watcher.class); ZooCache zc1 = zcf.getZooCache(zks1, timeout1, watcher); assertNotNull(zc1); }
@Test public void testGetZooCacheWatcher_Null() { String zks1 = "zk1"; int timeout1 = 1000; ZooCache zc1 = zcf.getZooCache(zks1, timeout1, null); assertNotNull(zc1); ZooCache zc1a = zcf.getZooCache(zks1, timeout1); assertSame(zc1, zc1a); }