WebAppStopper { public void stopAsync() { executorService.execute(task); executorService.shutdown(); } WebAppStopper(final WebAppServer webAppServer, final ExecutorService executorService); void stopAsync();  }
@Test public void testStopAsyncShouldShutdownExecutor() { underTest.stopAsync(); verify(executorService).shutdown(); }
@Test public void testStopAsyncShouldStopWebAppServer() { ArgumentCaptor<Runnable> captor = ArgumentCaptor.forClass(Runnable.class); underTest.stopAsync(); verify(executorService).execute(captor.capture()); captor.getValue().run(); verify(webAppServer).stop(); }