NestedZookeeperServers { public synchronized void startServerIfNotStarted(final int port, final String dataDir) { if (!nestedServers.containsKey(port)) { TestingServer testingServer = null; try { testingServer = new TestingServer(port, new File(dataDir)); } catch (final Exception ex) { RegExceptionHandler.handleException(ex); } nestedServers.putIfAbsent(port, testingServer); } }  static NestedZookeeperServers getInstance(); synchronized void startServerIfNotStarted(final int port, final String dataDir); void closeServer(final int port);  }
@Test public void assertStartServerIfNotStarted() throws NoSuchFieldException, SecurityException { nestedZookeeperServers.startServerIfNotStarted(5555, String.format("target/test_zk_data/5555/%s/", System.nanoTime())); nestedZookeeperServers.startServerIfNotStarted(5555, String.format("target/test_zk_data/5555/%s/", System.nanoTime())); assertTrue(getNestedServers().containsKey(5555)); }