@Test
public void testNestedUserQueuePrimaryGroup() throws Exception {

  StringBuffer sb = new StringBuffer();
  sb.append("<queuePlacementPolicy>");
  sb.append("  <rule name='specified' create='false' />");
  sb.append("  <rule name='nestedUserQueue'>");
  sb.append("       <rule name='primaryGroup'/>");
  sb.append("  </rule>");
  sb.append("  <rule name='default' />");
  sb.append("</queuePlacementPolicy>");
  // User queue would be created under primary group queue
  QueuePlacementPolicy policy = parse(sb.toString());
  assertEquals("root.user1group.user1",
      policy.assignAppToQueue("root.default", "user1"));
  // Other rules above and below hierarchical user queue rule should work as
  // usual
  configuredQueues.get(FSQueueType.LEAF).add("root.specifiedq");
  // test if specified rule(above nestedUserQueue rule) works ok
  assertEquals("root.specifiedq",
      policy.assignAppToQueue("root.specifiedq", "user2"));
  // test if default rule(below nestedUserQueue rule) works
  configuredQueues.get(FSQueueType.LEAF).add("root.user3group");
  assertEquals("root.default",
      policy.assignAppToQueue("root.default", "user3"));
}