@Test
  public void deleteOnExit() throws IOException {
    File file = FileUtils.createTempFile(null, "tmp", null);
    Assert.assertTrue(ShutdownHookManager.isRegisteredToDeleteOnExit(file));
    FileUtils.deleteTmpFile(file);
    Assert.assertFalse(ShutdownHookManager.isRegisteredToDeleteOnExit(file));
  }
TestShutdownHookManager.

Originally taken from o.a.hadoop.util.TestShutdownHookManager
common/src/test/org/apache/hive/common/util/TestShutdownHookManager.java