@Test
  public void testVersioning() throws IOException {

    // Define data that will be written to cache
    CacheKey key = new SimpleCacheKey("version_test");
    byte[] value = new byte[32];
    value[0] = 'v';

    // Set up cache with version == 1
    DiskStorage storage1 = createDiskStorage(TESTCACHE_CURRENT_VERSION);
    DiskStorageCache cache1 = createDiskCache(storage1, false);

    // Write test data to cache 1
    cache1.insert(key, WriterCallbacks.from(value));

    // Get cached file
    BinaryResource resource1 = getResource(storage1, key);
    assertNotNull(resource1);

    // Set up cache with version == 2
    DiskStorage storageSupplier2 = createDiskStorage(TESTCACHE_NEXT_VERSION);
    DiskStorageCache cache2 = createDiskCache(storageSupplier2, false);

    // Write test data to cache 2
    cache2.insert(key, WriterCallbacks.from(value));

    // Get cached file
    BinaryResource resource2 = getResource(storageSupplier2, key);
    assertNotNull(resource2);

    // Make sure filenames of the two file are different
    assertFalse(resource2.equals(resource1));
  }
Test to make sure that the same item stored with two different versions of the cache will be
stored with two different file names.

@throws UnsupportedEncodingException
imagepipeline-base/src/test/java/com/facebook/cache/disk/DiskStorageCacheTest.java