@Test (timeout = 15000)
public void testFetchApplictionLogsHar() throws Exception {

  String remoteLogRootDir = "target/logs/";
  conf.setBoolean(YarnConfiguration.LOG_AGGREGATION_ENABLED, true);
  conf
      .set(YarnConfiguration.NM_REMOTE_APP_LOG_DIR, remoteLogRootDir);
  conf.setBoolean(YarnConfiguration.YARN_ACL_ENABLE, true);
  conf.set(YarnConfiguration.YARN_ADMIN_ACL, "admin");
  FileSystem fs = FileSystem.get(conf);
  UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
  URL harUrl = ClassLoader.getSystemClassLoader()
      .getResource("application_1440536969523_0001.har");
  assertNotNull(harUrl);
  Path path =
      new Path(remoteLogRootDir + ugi.getShortUserName()
          + "/bucket-logs-tfile/0001/application_1440536969523_0001");
  if (fs.exists(path)) {
    fs.delete(path, true);
  }
  assertTrue(fs.mkdirs(path));
  Path harPath = new Path(path, "application_1440536969523_0001.har");
  fs.copyFromLocalFile(false, new Path(harUrl.toURI()), harPath);
  assertTrue(fs.exists(harPath));
  YarnClient mockYarnClient =
      createMockYarnClient(YarnApplicationState.FINISHED,
          ugi.getShortUserName());
  LogsCLI cli = new LogsCLIForTest(mockYarnClient);
  cli.setConf(conf);
  int exitCode = cli.run(new String[]{"-applicationId",
      "application_1440536969523_0001"});
  assertTrue(exitCode == 0);
  String out = sysOutStream.toString();
  assertTrue(
      out.contains("container_1440536969523_0001_01_000001 on host1_1111"));
  assertTrue(out.contains("Hello stderr"));
  assertTrue(out.contains("Hello stdout"));
  assertTrue(out.contains("Hello syslog"));
  assertTrue(
      out.contains("container_1440536969523_0001_01_000002 on host2_2222"));
  assertTrue(out.contains("Goodbye stderr"));
  assertTrue(out.contains("Goodbye stdout"));
  assertTrue(out.contains("Goodbye syslog"));
  sysOutStream.reset();
  fs.delete(new Path(remoteLogRootDir), true);
}