### Question:
LoadingSupplier implements Supplier<T> { @Override public final T get() { try { previous = load(); } catch (Exception e) { LoggerFactory.getLogger(LoadingSupplier.class).error("Error looking up supplier value!", e); } return previous; }  @Override final T get(); abstract T load();  }### Answer:
@Test public void testGet() { int breakInterval = 3; Supplier<Integer> supplier = new FaultTestSupplier(breakInterval); for (int i=1;i<=10;i++) { Integer value = supplier.get(); System.out.println(i+": "+ value); int testValue = i; if (i%breakInterval==0) { testValue--; } assertEquals(value,Integer.valueOf(testValue)); } }
@Test public void testGet2() { int breakInterval = 3; Supplier<Integer> supplier = new FaultTestSupplier2<>(new FaultySupplier(breakInterval)); for (int i=1;i<=10;i++) { Integer value = supplier.get(); System.out.println(i+": "+ value); int testValue = i; if (i%breakInterval==0) { testValue--; } assertEquals(value,Integer.valueOf(testValue)); } }
@Test public void testFlushing() throws Exception { System.out.println("SupplierCache.permanent"); CacheManager cacheManager = CacheManager.createIfNeeded("TestCacheManager"); SupplierCache<Integer> cache = cacheManager.supplierCache("Groups", new RecordingSupplier(), 1, TimeUnit.HOURS); assertEquals(1, cache.get().intValue()); assertEquals(1, cache.get().intValue()); cache.clear(); assertEquals(2, cache.get().intValue()); }