@Test public void testCompositeInsertsToAllCaches() { DiskCache cache1 = Mockito.mock(DiskCache.class); DiskCache cache2 = Mockito.mock(DiskCache.class); DiskCache cache3 = Mockito.mock(DiskCache.class); CompositeDiskCache cache = new CompositeDiskCache(cache1, cache2, cache3); cache.put("", null); Mockito.verify(cache1, Mockito.times(1)).put(Mockito.anyString(), (DiskCache.Writer)Mockito.any()); Mockito.verify(cache2, Mockito.times(1)).put(Mockito.anyString(), (DiskCache.Writer)Mockito.any()); Mockito.verify(cache3, Mockito.times(1)).put(Mockito.anyString(), (DiskCache.Writer)Mockito.any()); }
@Override public void put(String key, Writer writer) { synchronized (this) { for (int i=0; i<leafs.size(); i++) { DiskCache cache = leafs.get(i); cache.put(key, writer); } } }
CompositeDiskCache implements DiskCache { @Override public void put(String key, Writer writer) { synchronized (this) { for (int i=0; i<leafs.size(); i++) { DiskCache cache = leafs.get(i); cache.put(key, writer); } } } }
CompositeDiskCache implements DiskCache { @Override public void put(String key, Writer writer) { synchronized (this) { for (int i=0; i<leafs.size(); i++) { DiskCache cache = leafs.get(i); cache.put(key, writer); } } } CompositeDiskCache(DiskCache... caches); }
CompositeDiskCache implements DiskCache { @Override public void put(String key, Writer writer) { synchronized (this) { for (int i=0; i<leafs.size(); i++) { DiskCache cache = leafs.get(i); cache.put(key, writer); } } } CompositeDiskCache(DiskCache... caches); @Override File get(String key); @Override void put(String key, Writer writer); @Override void delete(String key); @Override void clear(); }
CompositeDiskCache implements DiskCache { @Override public void put(String key, Writer writer) { synchronized (this) { for (int i=0; i<leafs.size(); i++) { DiskCache cache = leafs.get(i); cache.put(key, writer); } } } CompositeDiskCache(DiskCache... caches); @Override File get(String key); @Override void put(String key, Writer writer); @Override void delete(String key); @Override void clear();  }