### Question:
JumiLauncher implements Closeable { @Override public void close() throws IOException { externalResources.close(); } JumiLauncher(ActorRef<SuiteLauncher> suiteLauncher, @WillCloseWhenClosed Closeable externalResources); MessageReceiver<Event<SuiteListener>> getEventStream(); void start(SuiteConfiguration suiteConfiguration, DaemonConfiguration daemonConfiguration); void shutdownDaemon(); @Override void close();  }### Answer:
@Test public void on_close_terminates_the_actor_thread_pool() throws IOException { JumiLauncherBuilder builder = new JumiLauncherBuilder() { @Override protected ExecutorService createActorsThreadPool() { actorsThreadPool = super.createActorsThreadPool(); return actorsThreadPool; } }; JumiLauncher launcher = builder.build(); launcher.close(); assertTrue("should have terminated the actors thread pool", actorsThreadPool.isTerminated()); }
@Test public void on_close_closes_network_sockets() throws IOException { final NetworkServer networkServer = mock(NetworkServer.class); JumiLauncherBuilder builder = new JumiLauncherBuilder() { @Override protected NetworkServer createNetworkServer() { return networkServer; } }; JumiLauncher launcher = builder.build(); launcher.close(); verify(networkServer).close(); }
@Test public void closing_more_than_once_has_no_effect() throws IOException { JumiLauncherBuilder builder = new JumiLauncherBuilder(); JumiLauncher launcher = builder.build(); launcher.close(); launcher.close(); }
@Test public void on_close_stops_the_actor_thread() throws IOException { final ActorThread actorThread = spy(new FakeActorThread()); JumiLauncherBuilder builder = new JumiLauncherBuilder() { @Override protected ActorThread startActorThread(Actors actors) { return actorThread; } }; JumiLauncher launcher = builder.build(); launcher.close(); verify(actorThread).stop(); }