### Question:
ZooKeeperServerMain { protected void initializeAndRun(String[] args) throws ConfigException, IOException, AdminServerException { try { ManagedUtil.registerLog4jMBeans(); } catch (JMException e) { LOG.warn("Unable to register log4j JMX control", e); } ServerConfig config = new ServerConfig(); if (args.length == 1) { config.parse(args[0]); } else { config.parse(args); } runFromConfig(config); }  static void main(String[] args); void runFromConfig(ServerConfig config);  }### Answer:
@Test public void testWithMinSessionTimeoutGreaterThanMaxSessionTimeout() throws Exception { ClientBase.setupTestEnv(); final int CLIENT_PORT = PortAssignment.unique(); final int tickTime = 2000; final int minSessionTimeout = 20 * tickTime + 1000; final int maxSessionTimeout = tickTime * 2 - 100; final String configs = "maxSessionTimeout=" + maxSessionTimeout + "\n" + "minSessionTimeout=" + minSessionTimeout + "\n"; MainThread main = new MainThread(CLIENT_PORT, true, configs); String[] args = new String[1]; args[0] = main.confFile.toString(); try { main.main.initializeAndRun(args); fail("Must throw exception as " + "minsessiontimeout > maxsessiontimeout"); } catch (ConfigException iae) { } }
@Test public void testInvalidMetricsProvider() throws Exception { ClientBase.setupTestEnv(); final int CLIENT_PORT = PortAssignment.unique(); final String configs = "metricsProvider.className=BadClass\n"; MainThread main = new MainThread(CLIENT_PORT, true, configs); String[] args = new String[1]; args[0] = main.confFile.toString(); try { main.main.initializeAndRun(args); fail("Must throw exception as metrics provider is not " + "well configured"); } catch (ConfigException iae) { } }
@Test public void testFaultyMetricsProviderOnStart() throws Exception { ClientBase.setupTestEnv(); final int CLIENT_PORT = PortAssignment.unique(); final String configs = "metricsProvider.className=" + MetricsProviderWithErrorInStart.class.getName() + "\n"; MainThread main = new MainThread(CLIENT_PORT, true, configs); String[] args = new String[1]; args[0] = main.confFile.toString(); try { main.main.initializeAndRun(args); fail("Must throw exception as metrics provider cannot boot"); } catch (IOException iae) { } }
@Test public void testFaultyMetricsProviderOnConfigure() throws Exception { ClientBase.setupTestEnv(); final int CLIENT_PORT = PortAssignment.unique(); final String configs = "metricsProvider.className=" + MetricsProviderWithErrorInConfigure.class.getName() + "\n"; MainThread main = new MainThread(CLIENT_PORT, true, configs); String[] args = new String[1]; args[0] = main.confFile.toString(); try { main.main.initializeAndRun(args); fail("Must throw exception as metrics provider is cannot boot"); } catch (IOException iae) { } }