@Test
public void testGetApplicationAttempts() throws Exception {

  final ApplicationId appId = ApplicationId.newInstance(0, 1);
  Collection<ApplicationAttemptReport> appAttempts;
  if (callerUGI == null) {
    appAttempts = historyManager.getApplicationAttempts(appId).values();
  } else {
    try {
      appAttempts = callerUGI.doAs(
          new PrivilegedExceptionAction<Collection<ApplicationAttemptReport>> () {
        @Override
        public Collection<ApplicationAttemptReport> run() throws Exception {
          return historyManager.getApplicationAttempts(appId).values();
        }
      });
      if (callerUGI != null && callerUGI.getShortUserName().equals("user3")) {
        // The exception is expected
        Assert.fail();
      }
    } catch (AuthorizationException e) {
      if (callerUGI != null && callerUGI.getShortUserName().equals("user3")) {
        // The exception is expected
        return;
      }
      throw e;
    }
  }
  Assert.assertNotNull(appAttempts);
  Assert.assertEquals(SCALE, appAttempts.size());
}