@Test
public void testNestedUserQueuePrimaryGroupNoCreate() throws Exception {

  // Primary group rule has create='false'
  StringBuffer sb = new StringBuffer();
  sb.append("<queuePlacementPolicy>");
  sb.append("  <rule name='nestedUserQueue'>");
  sb.append("       <rule name='primaryGroup' create='false'/>");
  sb.append("  </rule>");
  sb.append("  <rule name='default' />");
  sb.append("</queuePlacementPolicy>");
  QueuePlacementPolicy policy = parse(sb.toString());
  // Should return root.default since primary group 'root.user1group' is not
  // configured
  assertEquals("root.default",
      policy.assignAppToQueue("root.default", "user1"));
  // Let's configure primary group and check if user queue is created
  configuredQueues.get(FSQueueType.PARENT).add("root.user1group");
  policy = parse(sb.toString());
  assertEquals("root.user1group.user1",
      policy.assignAppToQueue("root.default", "user1"));
  // Both Primary group and nestedUserQueue rule has create='false'
  sb = new StringBuffer();
  sb.append("<queuePlacementPolicy>");
  sb.append("  <rule name='nestedUserQueue' create='false'>");
  sb.append("       <rule name='primaryGroup' create='false'/>");
  sb.append("  </rule>");
  sb.append("  <rule name='default' />");
  sb.append("</queuePlacementPolicy>");
  // Should return root.default since primary group and user queue for user 2
  // are not configured.
  assertEquals("root.default",
      policy.assignAppToQueue("root.default", "user2"));
  // Now configure both primary group and the user queue for user2
  configuredQueues.get(FSQueueType.PARENT).add("root.user2group");
  configuredQueues.get(FSQueueType.LEAF).add("root.user2group.user2");
  policy = parse(sb.toString());
  assertEquals("root.user2group.user2",
      policy.assignAppToQueue("root.default", "user2"));
}