@Test
public void testVerifyAndCreateRemoteDirNonExistence()
    throws Exception {

  this.conf.set(YarnConfiguration.NM_LOG_DIRS, localLogDir.getAbsolutePath());
  File aNewFile = new File(String.valueOf("tmp"+System.currentTimeMillis()));
  this.conf.set(YarnConfiguration.NM_REMOTE_APP_LOG_DIR,
      aNewFile.getAbsolutePath());
  LogAggregationService logAggregationService = spy(
      new LogAggregationService(dispatcher, this.context, this.delSrvc,
                                super.dirsHandler));
  logAggregationService.init(this.conf);
  logAggregationService.start();
  boolean existsBefore = aNewFile.exists();
  assertTrue("The new file already exists!", !existsBefore);
  ApplicationId appId = ApplicationId.newInstance(
      System.currentTimeMillis(), 1);
  LogAggregationContext contextWithAMAndFailed =
      Records.newRecord(LogAggregationContext.class);
  contextWithAMAndFailed.setLogAggregationPolicyClassName(
      AMOrFailedContainerLogAggregationPolicy.class.getName());
  logAggregationService.handle(new LogHandlerAppStartedEvent(appId,
      this.user, null, this.acls, contextWithAMAndFailed));
  dispatcher.await();
  boolean existsAfter = aNewFile.exists();
  assertTrue("The new aggregate file is not successfully created", existsAfter);
  aNewFile.delete(); //housekeeping
  logAggregationService.stop();
}