### Question:
A implements AutoCloseable { public static void main(final String[] args) throws FileNotFoundException, IOException { final CountDownLatch terminatorStopper = new CountDownLatch(1); ExecutorService executor = null; boolean gui = false; try { LoggingFunctions.startLogging(); final Option option = new Option(args); if (Boolean.parseBoolean(option.get(Option.Item.help))) { System.out.println(Option.toHelpString()); return; } final Environment environment = new Environment(option); environment.startLogging(); option.afterStartLogging(); LOG.log(Level.CONFIG, "以下の設定が使用されます: " + System.lineSeparator() + option.toCommandlineString()); preprocess(environment); final A instance = new A(environment); Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { LOG.log(Level.FINEST, "システムが終了されます。"); instance.shutdownStarted.set(true); instance.stopper.countDown(); try { if (!terminatorStopper.await(environment.getShutdownTimeout(), TimeUnit.MILLISECONDS)) { LOG.log(Level.SEVERE, "{0} ミリ秒以内に終処理が完了しませんでした。", environment.getShutdownTimeout()); } } catch (final InterruptedException e) { LOG.log(Level.SEVERE, "終処理が完了しませんでした。"); } } }); executor = environment.getExecutor(); gui = environment.getGui(); instance.execute(); try { instance.close(); } catch (MyRuleException | InterruptedException | IOException e) { LOG.log(Level.WARNING, "異常が発生しました", e); LOG.log(Level.SEVERE, "データの保管に失敗したかもしれません。"); } } catch (final Throwable e) { LOG.log(Level.WARNING, "異常が発生しました", e); LOG.log(Level.SEVERE, "対処不能です。"); } finally { try { if (executor != null && !executor.isTerminated()) { LOG.log(Level.SEVERE, "強制終了します。"); System.exit(1); } else { LogInitializer.reset(); } } finally { try { terminatorStopper.countDown(); } finally { LogInitializer.reset(); } } } if (gui) { System.exit(0); } } A(final Environment environment); @Override void close(); static void main(final String[] args);  }### Answer:
@Test public void testBoot() throws Exception { final ExecutorService executor = Executors.newCachedThreadPool(); final File root = new File(ATest.ROOT, "boot"); final int port = FIRST_PORT + portOffset.getAndIncrement(); final int bbsPort = FIRST_PORT + portOffset.getAndIncrement(); executor.submit(new Reporter<Void>(Level.INFO) { @Override public Void subCall() throws Exception { A.main(("-root " + root.getPath() + " -port " + port + " -bbsPort " + bbsPort + " -consoleLogLevel " + Level.WARNING.getName() + " -fileLogLevel " + Level.OFF.getName()).split(" ")); return null; } }); Thread.sleep(3 * Duration.SECOND); executor.shutdownNow(); Assert.assertTrue(executor.awaitTermination(Duration.SECOND, TimeUnit.MILLISECONDS)); }