@Test
@SuppressWarnings("unchecked")
public void testDelayedDelete() {

  DeletionService delService = mock(DeletionService.class);
  Configuration conf = new YarnConfiguration();
  String user = "testuser";
  File[] localLogDirs = new File[2];
  localLogDirs[0] =
      new File("target", this.getClass().getName() + "-localLogDir0")
          .getAbsoluteFile();
  localLogDirs[1] =
      new File("target", this.getClass().getName() + "-localLogDir1")
          .getAbsoluteFile();
  String localLogDirsString =
      localLogDirs[0].getAbsolutePath() + ","
          + localLogDirs[1].getAbsolutePath();
  conf.set(YarnConfiguration.NM_LOG_DIRS, localLogDirsString);
  conf.setBoolean(YarnConfiguration.LOG_AGGREGATION_ENABLED, false);
  conf.setLong(YarnConfiguration.NM_LOG_RETAIN_SECONDS,
          YarnConfiguration.DEFAULT_NM_LOG_RETAIN_SECONDS);
  DrainDispatcher dispatcher = createDispatcher(conf);
  EventHandler<ApplicationEvent> appEventHandler = mock(EventHandler.class);
  dispatcher.register(ApplicationEventType.class, appEventHandler);
  LocalDirsHandlerService dirsHandler = new LocalDirsHandlerService();
  dirsHandler.init(conf);
  ApplicationId appId1 = BuilderUtils.newApplicationId(1234, 1);
  ApplicationAttemptId appAttemptId1 =
      BuilderUtils.newApplicationAttemptId(appId1, 1);
  ContainerId container11 = BuilderUtils.newContainerId(appAttemptId1, 1);
  NonAggregatingLogHandler logHandler =
      new NonAggregatingLogHandlerWithMockExecutor(dispatcher, delService,
                                                   dirsHandler);
  logHandler.init(conf);
  logHandler.start();
  logHandler.handle(new LogHandlerAppStartedEvent(appId1, user, null,
      ContainerLogsRetentionPolicy.ALL_CONTAINERS, null));
  logHandler.handle(new LogHandlerContainerFinishedEvent(container11, 0));
  logHandler.handle(new LogHandlerAppFinishedEvent(appId1));
  Path[] localAppLogDirs = new Path[2];
  localAppLogDirs[0] =
      new Path(localLogDirs[0].getAbsolutePath(), appId1.toString());
  localAppLogDirs[1] =
      new Path(localLogDirs[1].getAbsolutePath(), appId1.toString());
  ScheduledThreadPoolExecutor mockSched =
      ((NonAggregatingLogHandlerWithMockExecutor) logHandler).mockSched;
  verify(mockSched).schedule(any(Runnable.class), eq(10800l),
      eq(TimeUnit.SECONDS));
}