RESTServer extends Thread { public void shutdown() throws IOException { logger.info("Caught shutdown command to RESTServer"); shutdownCalled = true; ioReactor.shutdown(); } @SuppressWarnings("rawtypes")  RESTServer(int port, HttpRESTHandler requestHandler); @SuppressWarnings("rawtypes")  RESTServer(CoreConfiguration conf, HttpRESTHandler requestHandler); boolean isExecuting(); boolean hasError(); Exception getError(); int getPort(); boolean blockingStart(); boolean isWorking(long startTime, long timeout); @Override void run(); void shutdown(); static RESTServer getNewStartedRESTServer(int port, HttpRESTHandler<?> restHandler);  }
@Test public void testShutdown() throws IOException, InterruptedException { CoreConfiguration conf = ConfigurationFactory.getConfiguration("jUnit-RESTServerTest"); RESTServer server = RESTServer.getNewStartedRESTServer(conf.getRestPort(), new HttpRESTHandler<MongoType>(new MongoConnector(conf))); server.shutdown(); Thread.sleep(1000); if(server.isAlive()) { fail("Thread should be dead"); } if(server.isExecuting()) { fail("IOReactor should not be executing"); } if(server.hasError()) { server.getError().printStackTrace(); fail("Server should not have error "+ server.getError().getMessage()); } if(server.isWorking(System.currentTimeMillis(), 1000)) { fail("Server should not be working"); } }