@Test
public void filesNotInCacheAreDeleted()
{

    cleaner.setMaxDeleteWatchCount(0);
    int numFiles = 300; // Must be a multiple of number of UrlSource types being tested
    long totalSize = 0; // what is the total size of the sample files?
    File[] files = new File[numFiles];
    for (int i = 0; i < numFiles; i++)
    {
        // Testing with a number of files. The cached file cleaner will be able to determine the 'original'
        // content URL for each file by either retrieving from the companion properties file, or performing
        // a 'reverse lookup' in the cache (i.e. cache.contains(Key.forCacheFile(...))), or there will be no
        // URL determinable for the file.
        UrlSource urlSource = UrlSource.values()[i % UrlSource.values().length];
        File cacheFile = createCacheFile(urlSource, false);
        files[i] = cacheFile;
        totalSize += cacheFile.length();
    }
    // Run cleaner
    cleaner.execute();
    
    // check all files deleted
    for (File file : files)
    {
        assertFalse("File should have been deleted: " + file, file.exists());
    }
    
    assertEquals("Incorrect number of deleted files", numFiles, cleaner.getNumFilesDeleted());
    assertEquals("Incorrect total size of files deleted", totalSize, cleaner.getSizeFilesDeleted());
}