Main { private Main() { } private  Main(); static void main(final String[] args);  }
@Test @org.junit.Ignore @SuppressWarnings("PMD.DoNotUseThreads") public void startsAndListensOnPort() throws Exception { final int port = PortMocker.reserve(); final CountDownLatch done = new CountDownLatch(1); final Thread thread = new Thread( new VerboseRunnable( new Callable<Void>() { @Override public Void call() throws Exception { try { Main.main(new String[]{Integer.toString(port)}); } catch (final InterruptedException ex) { done.countDown(); Thread.currentThread().interrupt(); throw new IllegalStateException(ex); } return null; } }, false ) ); thread.start(); TimeUnit.SECONDS.sleep(1); final URI uri = new URI( String.format("http: ); MatcherAssert.assertThat( uri.toURL().getContent(), Matchers.notNullValue() ); thread.interrupt(); MatcherAssert.assertThat( done.await(1, TimeUnit.SECONDS), Matchers.is(true) ); }