@Test
public void testQueueAcl() throws Exception {

  setupMultiLevelQueues(csConf);
  csConf.setAcl(CapacitySchedulerConfiguration.ROOT, QueueACL.SUBMIT_APPLICATIONS, " ");
  csConf.setAcl(CapacitySchedulerConfiguration.ROOT, QueueACL.ADMINISTER_QUEUE, " ");
  final String Q_C = CapacitySchedulerConfiguration.ROOT + "." + C;
  csConf.setAcl(Q_C, QueueACL.ADMINISTER_QUEUE, "*");
  final String Q_C11= Q_C + "." + C1 +  "." + C11;
  csConf.setAcl(Q_C11, QueueACL.SUBMIT_APPLICATIONS, "*");
  Map<String, CSQueue> queues = new HashMap<String, CSQueue>();
  CSQueue root = 
      CapacityScheduler.parseQueue(csContext, csConf, null, 
          CapacitySchedulerConfiguration.ROOT, queues, queues, 
          TestUtils.spyHook);
  UserGroupInformation user = UserGroupInformation.getCurrentUser();
  // Setup queue configs
  ParentQueue c = (ParentQueue)queues.get(C);
  ParentQueue c1 = (ParentQueue)queues.get(C1);
  ParentQueue c11 = (ParentQueue)queues.get(C11);
  ParentQueue c111 = (ParentQueue)queues.get(C111);
  assertFalse(root.hasAccess(QueueACL.ADMINISTER_QUEUE, user));
  List<QueueUserACLInfo> aclInfos = root.getQueueUserAclInfo(user);
  assertFalse(hasQueueACL(aclInfos, QueueACL.ADMINISTER_QUEUE, "root"));
  
  assertFalse(root.hasAccess(QueueACL.SUBMIT_APPLICATIONS, user));
  assertFalse(hasQueueACL(aclInfos, QueueACL.SUBMIT_APPLICATIONS, "root"));
  // c has no SA, but QA
  assertTrue(c.hasAccess(QueueACL.ADMINISTER_QUEUE, user));
  assertTrue(hasQueueACL(aclInfos,  QueueACL.ADMINISTER_QUEUE, "c"));
  assertFalse(c.hasAccess(QueueACL.SUBMIT_APPLICATIONS, user));
  assertFalse(hasQueueACL(aclInfos, QueueACL.SUBMIT_APPLICATIONS, "c"));
  //Queue c1 has QA, no SA (gotten perm from parent)
  assertTrue(c1.hasAccess(QueueACL.ADMINISTER_QUEUE, user)); 
  assertTrue(hasQueueACL(aclInfos,  QueueACL.ADMINISTER_QUEUE, "c1"));
  assertFalse(c1.hasAccess(QueueACL.SUBMIT_APPLICATIONS, user)); 
  assertFalse(hasQueueACL(aclInfos, QueueACL.SUBMIT_APPLICATIONS, "c1"));
  //Queue c11 has permissions from parent queue and SA
  assertTrue(c11.hasAccess(QueueACL.ADMINISTER_QUEUE, user));
  assertTrue(hasQueueACL(aclInfos,  QueueACL.ADMINISTER_QUEUE, "c11"));
  assertTrue(c11.hasAccess(QueueACL.SUBMIT_APPLICATIONS, user));
  assertTrue(hasQueueACL(aclInfos, QueueACL.SUBMIT_APPLICATIONS, "c11"));
  //Queue c111 has SA and AQ, both from parent
  assertTrue(c111.hasAccess(QueueACL.ADMINISTER_QUEUE, user));
  assertTrue(hasQueueACL(aclInfos,  QueueACL.ADMINISTER_QUEUE, "c111"));
  assertTrue(c111.hasAccess(QueueACL.SUBMIT_APPLICATIONS, user));
  assertTrue(hasQueueACL(aclInfos, QueueACL.SUBMIT_APPLICATIONS, "c111"));
  reset(c);
}