@Test
public void testGetAppsInQueue() throws Exception {

  scheduler.init(conf);
  scheduler.start();
  scheduler.reinitialize(conf, resourceManager.getRMContext());
  ApplicationAttemptId appAttId1 =
      createSchedulingRequest(1024, 1, "queue1.subqueue1", "user1");
  ApplicationAttemptId appAttId2 =
      createSchedulingRequest(1024, 1, "queue1.subqueue2", "user1");
  ApplicationAttemptId appAttId3 =
      createSchedulingRequest(1024, 1, "default", "user1");
  
  List<ApplicationAttemptId> apps =
      scheduler.getAppsInQueue("queue1.subqueue1");
  assertEquals(1, apps.size());
  assertEquals(appAttId1, apps.get(0));
  // with and without root prefix should work
  apps = scheduler.getAppsInQueue("root.queue1.subqueue1");
  assertEquals(1, apps.size());
  assertEquals(appAttId1, apps.get(0));
  
  apps = scheduler.getAppsInQueue("user1");
  assertEquals(1, apps.size());
  assertEquals(appAttId3, apps.get(0));
  // with and without root prefix should work
  apps = scheduler.getAppsInQueue("root.user1");
  assertEquals(1, apps.size());
  assertEquals(appAttId3, apps.get(0));
  // apps in subqueues should be included
  apps = scheduler.getAppsInQueue("queue1");
  Assert.assertEquals(2, apps.size());
  Set<ApplicationAttemptId> appAttIds = Sets.newHashSet(apps.get(0), apps.get(1));
  assertTrue(appAttIds.contains(appAttId1));
  assertTrue(appAttIds.contains(appAttId2));
}