@Test
  public void testDeleteFileWithCleanerDisabled() throws Exception {
    Stoppable stop = new StoppableImplementation();
    Configuration conf = UTIL.getConfiguration();
    Path testDir = UTIL.getDataTestDir();
    FileSystem fs = UTIL.getTestFileSystem();
    String confKey = "hbase.test.cleaner.delegates";
    conf.set(confKey, AlwaysDelete.class.getName());

    AllValidPaths chore =
      new AllValidPaths("test-file-cleaner", stop, conf, fs, testDir, confKey, POOL);

    // Disable cleaner
    chore.setEnabled(false);

    // create the directory layout in the directory to clean
    Path parent = new Path(testDir, "parent");
    Path child = new Path(parent, "child");
    Path file = new Path(child, "someFile");
    fs.mkdirs(child);

    // touch a new file
    fs.create(file).close();
    assertTrue("Test file didn't get created.", fs.exists(file));

    // run the chore
    chore.chore();

    // verify all the files exist
    assertTrue("File got deleted with cleaner disabled", fs.exists(file));
    assertTrue("Directory got deleted", fs.exists(child));
    assertTrue("Directory got deleted", fs.exists(parent));
  }
The cleaner runs in a loop, where it first checks to see all the files under a directory can be
deleted. If they all can, then we try to delete the directory. However, a file may be added
that directory to after the original check. This ensures that we don't accidentally delete that
directory on and don't get spurious IOExceptions.
<p>
This was from HBASE-7465.
@throws Exception on failure
hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestCleanerChore.java