@Test
public void testGetContainers() throws Exception {

  final ApplicationAttemptId appAttemptId =
      ApplicationAttemptId.newInstance(ApplicationId.newInstance(0, 1), 1);
  Collection<ContainerReport> containers;
  if (callerUGI == null) {
    containers = historyManager.getContainers(appAttemptId).values();
  } else {
    try {
      containers = callerUGI.doAs(
          new PrivilegedExceptionAction<Collection<ContainerReport>> () {
        @Override
        public Collection<ContainerReport> run() throws Exception {
          return historyManager.getContainers(appAttemptId).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(containers);
  Assert.assertEquals(SCALE, containers.size());
}