@Test
public void filesNewerThanMinFileAgeMillisAreNotDeleted() throws InterruptedException
{

    final long minFileAge = 1000;
    cleaner.setMinFileAgeMillis(minFileAge);
    cleaner.setMaxDeleteWatchCount(0);
    int numFiles = 10;
    
    File[] oldFiles = new File[numFiles];
    for (int i = 0; i < numFiles; i++)
    {
        oldFiles[i] = createCacheFile(UrlSource.REVERSE_CACHE_LOOKUP, false);
    }
    
    // Sleep to make sure 'old' files really are older than minFileAgeMillis
    Thread.sleep(minFileAge);
    
    File[] newFiles = new File[numFiles];
    long newFilesTotalSize = 0;
    for (int i = 0; i < numFiles; i++)
    {
        newFiles[i] = createCacheFile(UrlSource.REVERSE_CACHE_LOOKUP, false);
        newFilesTotalSize += newFiles[i].length();
    }
    // The cleaner must finish before any of the newFiles are older than minFileAge. If the files are too
    // old the test will fail and it will be necessary to rethink how to test this.
    cleaner.execute();
    
    // check all 'old' files deleted
    for (File file : oldFiles)
    {
        assertFalse("File should have been deleted: " + file, file.exists());
    }
    // check all 'new' files still present
    for (File file : newFiles)
    {
        assertTrue("File should not have been deleted: " + file, file.exists());
    }
    
    assertEquals("Incorrect number of deleted files", newFiles.length, cleaner.getNumFilesDeleted());
    assertEquals("Incorrect total size of files deleted", newFilesTotalSize, cleaner.getSizeFilesDeleted());
}