DiskLruCacheWrapper implements DiskCache { private synchronized DiskLruCache getDiskCache() throws IOException { return diskLruCacheFactory.getDiskCache(); } DiskLruCacheWrapper(DiskLruCacheFactory diskLruCacheFactory); synchronized void setReadOnly(boolean isReadOnly); @Override File get(String key); @Override void put(String key, Writer writer); @Override void delete(String key); @Override synchronized void clear();  }
@Test public void testSharedDiskLruCacheFactorySameInstance() throws Exception { DiskLruCacheWrapper.SharedDiskLruCacheFactory wrapper1 = new DiskLruCacheWrapper.SharedDiskLruCacheFactory( new File(getContext().getCacheDir(), "blank"), 100 * 1024 * 1024); DiskLruCacheWrapper.SharedDiskLruCacheFactory wrapper2 = new DiskLruCacheWrapper.SharedDiskLruCacheFactory( new File(getContext().getCacheDir(), "blank"), 100 * 1024 * 1024); Assert.assertSame(wrapper1.getDiskCache(), wrapper2.getDiskCache()); }
@Test public void testNotSharedDiskLruCacheFactorySameInstance() throws Exception { DiskLruCacheWrapper.SharedDiskLruCacheFactory wrapper1 = new DiskLruCacheWrapper.SharedDiskLruCacheFactory( new File(getContext().getCacheDir(), "fooey"), 100 * 1024 * 1024); DiskLruCacheWrapper.SharedDiskLruCacheFactory wrapper2 = new DiskLruCacheWrapper.SharedDiskLruCacheFactory( new File(getContext().getCacheDir(), "blank"), 100 * 1024 * 1024); Assert.assertNotSame(wrapper1.getDiskCache(), wrapper2.getDiskCache()); }