@Test
public void testHandlingApplicationFinishedEvent() {

  Configuration conf = new Configuration();
  LocalDirsHandlerService dirsService  = new LocalDirsHandlerService();
  DeletionService delService = new DeletionService(null);
  NonAggregatingLogHandler aggregatingLogHandler =
      new NonAggregatingLogHandler(new InlineDispatcher(),
          delService,
          dirsService);
  dirsService.init(conf);
  dirsService.start();
  delService.init(conf);
  delService.start();
  aggregatingLogHandler.init(conf);
  aggregatingLogHandler.start();
  ApplicationId appId = BuilderUtils.newApplicationId(1234, 1);
  // It should NOT throw RejectedExecutionException
  aggregatingLogHandler.handle(new LogHandlerAppFinishedEvent(appId));
  aggregatingLogHandler.stop();
  // It should NOT throw RejectedExecutionException after stopping
  // handler service.
  aggregatingLogHandler.handle(new LogHandlerAppFinishedEvent(appId));
}