/** CacheStatistics should always be sensible when the cache has not started. */ @Test public void testCacheAlive() { Cache cache = new Cache("test", 1, true, false, 5, 2); String string = cache.toString(); assertTrue(string.contains("test")); try { LiveCacheStatistics statistics = cache.getLiveCacheStatistics(); fail(); } catch (IllegalStateException e) { assertEquals("The test Cache is not alive (STATUS_UNINITIALISED)", e.getMessage()); } // initialize cache now manager.addCache(cache); // add as a listener AnotherStatistics anotherStats = new AnotherStatistics(); cache.registerCacheUsageListener(anotherStats); assertEquals(0, anotherStats.getCacheHitCount()); }
public String toString() { return cache.toString(); }