@Test public void bake() throws IOException { OPTS_SET.set(false); int stop; int http; try (final ServerSocket s1 = new ServerSocket(0)) { stop = s1.getLocalPort(); try (final ServerSocket s2 = new ServerSocket(0)) { http = s2.getLocalPort(); } } final Thread runner = new Thread() { { setName("CLI thread"); } @Override public void run() { Cli.main(new String[]{ "--context", "app", "--stop", Integer.toString(stop), "--http", Integer.toString(http), "--tmp-dir", "target/CliTest/simple", "--my-config", "val" }); } }; try { runner.start(); boolean jsonOk = false; for (int i = 0; i < 60; i++) { try { assertEquals("{\"name\":\"test\"}", slurp(new URL("http: jsonOk = true; break; } catch (final AssertionError notYet) { try { Thread.sleep(1000); } catch (final InterruptedException e) { Thread.interrupted(); fail(); } } } assertTrue(jsonOk); assertTrue(OPTS_SET.get()); } finally { try (final Socket client = new Socket("localhost", stop)) { client.getOutputStream().write("SHUTDOWN".getBytes(StandardCharsets.UTF_8)); } catch (final IOException ioe) { } finally { try { runner.join(TimeUnit.MINUTES.toMillis(1)); } catch (final InterruptedException e) { Thread.currentThread().interrupt(); } } } }
public static void main(final String[] args) { new Cli(args).run(); }
Cli implements Runnable, AutoCloseable { public static void main(final String[] args) { new Cli(args).run(); } }
Cli implements Runnable, AutoCloseable { public static void main(final String[] args) { new Cli(args).run(); } Cli(final String[] args); }
Cli implements Runnable, AutoCloseable { public static void main(final String[] args) { new Cli(args).run(); } Cli(final String[] args); void run(); @Override synchronized void close(); static void main(final String[] args); static Meecrowave.Builder create(final String[] args); }
Cli implements Runnable, AutoCloseable { public static void main(final String[] args) { new Cli(args).run(); } Cli(final String[] args); void run(); @Override synchronized void close(); static void main(final String[] args); static Meecrowave.Builder create(final String[] args);  }