@Test
public void testcheckAndDeleteCgroup() throws Exception {

  CgroupsLCEResourcesHandler handler = new CgroupsLCEResourcesHandler();
  handler.setConf(new YarnConfiguration());
  handler.initConfig();
  FileUtils.deleteQuietly(cgroupDir);
  // Test 0
  // tasks file not present, should return false
  Assert.assertFalse(handler.checkAndDeleteCgroup(cgroupDir));
  File tfile = new File(cgroupDir.getAbsolutePath(), "tasks");
  FileOutputStream fos = FileUtils.openOutputStream(tfile);
  File fspy = Mockito.spy(cgroupDir);
  // Test 1, tasks file is empty
  // tasks file has no data, should return true
  Mockito.when(fspy.delete()).thenReturn(true);
  Assert.assertTrue(handler.checkAndDeleteCgroup(fspy));
  // Test 2, tasks file has data
  fos.write("1234".getBytes());
  fos.close();
  // tasks has data, would not be able to delete, should return false
  Assert.assertFalse(handler.checkAndDeleteCgroup(fspy));
  FileUtils.deleteQuietly(cgroupDir);
}