@Test
public void testSelectCgroup() throws Exception {

  File cpu = new File(tmpPath, "cpu");
  File cpuNoExist = new File(tmpPath, "cpuNoExist");
  File memory = new File(tmpPath, "memory");
  try {
    CGroupsHandlerImpl handler = new CGroupsHandlerImpl(
        createNoMountConfiguration(tmpPath),
        privilegedOperationExecutorMock);
    Map<String, Set<String>> cgroups = new LinkedHashMap<>();
    Assert.assertTrue("temp dir should be created", cpu.mkdirs());
    Assert.assertTrue("temp dir should be created", memory.mkdirs());
    Assert.assertFalse("temp dir should not be created", cpuNoExist.exists());
    cgroups.put(
        memory.getAbsolutePath(), Collections.singleton("memory"));
    cgroups.put(
        cpuNoExist.getAbsolutePath(), Collections.singleton("cpu"));
    cgroups.put(cpu.getAbsolutePath(), Collections.singleton("cpu"));
    String selectedCPU = handler.findControllerInMtab("cpu", cgroups);
    Assert.assertEquals("Wrong CPU mount point selected",
        cpu.getAbsolutePath(), selectedCPU);
  } finally {
    FileUtils.deleteQuietly(cpu);
    FileUtils.deleteQuietly(memory);
  }
}