### Question:
ZooKeeperInitialization { public static void ensureZooKeeperInitialized(final ZooReaderWriter zooReaderWriter, final String zRoot) throws KeeperException, InterruptedException { if (!zooReaderWriter.exists(zRoot + ReplicationConstants.ZOO_TSERVERS, null)) { zooReaderWriter.mkdirs(zRoot + ReplicationConstants.ZOO_TSERVERS); } if (!zooReaderWriter.exists(zRoot + ReplicationConstants.ZOO_WORK_QUEUE, null)) { zooReaderWriter.mkdirs(zRoot + ReplicationConstants.ZOO_WORK_QUEUE); } }  static void ensureZooKeeperInitialized(final ZooReaderWriter zooReaderWriter,
      final String zRoot);  }### Answer:
@Test public void parentNodesAreCreatedWhenMissing() throws Exception { ZooReaderWriter zReaderWriter = createMock(ZooReaderWriter.class); String zRoot = "/accumulo"; expect(zReaderWriter.exists(zRoot + ReplicationConstants.ZOO_TSERVERS, null)).andReturn(false) .once(); zReaderWriter.mkdirs(zRoot + ReplicationConstants.ZOO_TSERVERS); expectLastCall().once(); expect(zReaderWriter.exists(zRoot + ReplicationConstants.ZOO_WORK_QUEUE, null)).andReturn(false) .once(); zReaderWriter.mkdirs(zRoot + ReplicationConstants.ZOO_WORK_QUEUE); expectLastCall().once(); replay(zReaderWriter); ZooKeeperInitialization.ensureZooKeeperInitialized(zReaderWriter, zRoot); verify(zReaderWriter); }
@Test public void parentNodesAreNotRecreatedWhenAlreadyExist() throws Exception { ZooReaderWriter zReaderWriter = createMock(ZooReaderWriter.class); String zRoot = "/accumulo"; expect(zReaderWriter.exists(zRoot + ReplicationConstants.ZOO_TSERVERS, null)).andReturn(true) .once(); expect(zReaderWriter.exists(zRoot + ReplicationConstants.ZOO_WORK_QUEUE, null)).andReturn(true) .once(); replay(zReaderWriter); ZooKeeperInitialization.ensureZooKeeperInitialized(zReaderWriter, zRoot); verify(zReaderWriter); }