PersistentCacheStorage extends MemoryCacheStorage implements MemoryCache.KeyListener { FileManager getFileManager() { return fileManager; } PersistentCacheStorage(File storageDirectory);  PersistentCacheStorage(final int capacity, final File storageDirectory);  PersistentCacheStorage(final int capacity, final File storageDirectory, final String name); void onRemove(Key key); void setSerializationPolicy(SerializationPolicy serializationPolicy);  }
@Test public void testMultipleInserts() { Key key = new Key(URI.create("foo"), new Vary()); HTTPResponse res = null; for (int i = 0; i < 100; i++) { HTTPResponse response = createRealResponse(); res = storage.insert(REQUEST, response); } assertNotNull("Result may not be null", res); if (res.hasPayload()) { PersistentCacheStorage cacheStorage = (PersistentCacheStorage) storage; FilePayload payload = (FilePayload) res.getPayload().get(); final File parent = payload.getFile().getParentFile(); final File file = cacheStorage.getFileManager().resolve(key); assertEquals(file.toString(), payload.getFile().toString()); assertTrue(parent.isDirectory()); assertEquals(1, parent.list().length); } }