@Test
  public void testCommandLineWorks() throws Exception {
    System.setSecurityManager(new NoExitSecurityManager());
    HBaseZKTestingUtil htu = new HBaseZKTestingUtil();
    // Make it long so for sure succeeds.
    htu.getConfiguration().setInt(HConstants.ZK_SESSION_TIMEOUT, 30000);
    htu.startMiniZKCluster();
    try {
      ZKWatcher zkw = htu.getZooKeeperWatcher();
      String znode = "/testCommandLineWorks";
      ZKUtil.createWithParents(zkw, znode, HConstants.EMPTY_BYTE_ARRAY);
      ZKUtil.checkExists(zkw, znode);
      boolean exception = false;
      try {
        ZKMainServer.main(
          new String[] { "-server", htu.getZkCluster().getAddress().toString(), "delete", znode });
      } catch (ExitException ee) {
        // ZKMS calls System.exit which should trigger this exception.
        exception = true;
      }
      assertTrue(exception);
      assertEquals(-1, ZKUtil.checkExists(zkw, znode));
    } finally {
      htu.shutdownMiniZKCluster();
      System.setSecurityManager(null); // or save and restore original
    }
  }
We need delete of a znode to work at least.
hbase-zookeeper/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKMainServer.java