### Question:
Statistics implements Serializable { public void clearStatistics() { if (cache == null) { throw new IllegalStateException("This statistics object no longer references a Cache."); } cache.clearStatistics(); } Statistics(Ehcache cache, int statisticsAccuracy, long cacheHits, long onDiskHits, long offHeapHits,
                      long inMemoryHits, long misses, long onDiskMisses, long offHeapMisses,
                      long inMemoryMisses, long size, float averageGetTime, long evictionCount,
                      long memoryStoreSize, long offHeapStoreSize, long diskStoreSize); void clearStatistics(); long getCacheHits(); long getInMemoryHits(); long getOffHeapHits(); long getOnDiskHits(); long getCacheMisses(); long getInMemoryMisses(); long getOffHeapMisses(); long getOnDiskMisses(); long getObjectCount(); long getMemoryStoreObjectCount(); long getOffHeapStoreObjectCount(); long getDiskStoreObjectCount(); int getStatisticsAccuracy(); String getStatisticsAccuracyDescription(); String getAssociatedCacheName(); Ehcache getAssociatedCache(); @Override final String toString(); float getAverageGetTime(); long getEvictionCount(); static boolean isValidStatisticsAccuracy(int statisticsAccuracy); static final int STATISTICS_ACCURACY_NONE; static final int STATISTICS_ACCURACY_BEST_EFFORT; static final int STATISTICS_ACCURACY_GUARANTEED; }### Answer:
@Test public void testClearStatistics() throws InterruptedException { Cache cache = new Cache("test", 1, true, false, 5, 2); manager.addCache(cache); cache.setStatisticsEnabled(true); cache.put(new Element("key1", "value1")); cache.put(new Element("key2", "value1")); Thread.sleep(100); cache.get("key1"); Statistics statistics = cache.getStatistics(); assertEquals(1, statistics.getCacheHits()); assertEquals(1, statistics.getOnDiskHits()); assertEquals(0, statistics.getInMemoryHits()); assertEquals(0, statistics.getCacheMisses()); statistics.clearStatistics(); statistics = cache.getStatistics(); assertEquals(0, statistics.getCacheHits()); assertEquals(0, statistics.getOnDiskHits()); assertEquals(0, statistics.getInMemoryHits()); assertEquals(0, statistics.getCacheMisses()); }
@Test public void testClearStatistics() throws InterruptedException { Cache cache = new Cache("test", 1, true, false, 5, 2); manager.addCache(cache); cache.setStatisticsEnabled(true); cache.put(new Element("key1", "value1")); cache.put(new Element("key2", "value1")); cache.get("key1"); Statistics statistics = cache.getStatistics(); assertEquals(1, statistics.getCacheHits()); assertEquals(1, statistics.getOnDiskHits()); assertEquals(0, statistics.getInMemoryHits()); assertEquals(0, statistics.getCacheMisses()); statistics.clearStatistics(); statistics = cache.getStatistics(); assertEquals(0, statistics.getCacheHits()); assertEquals(0, statistics.getOnDiskHits()); assertEquals(0, statistics.getInMemoryHits()); assertEquals(0, statistics.getCacheMisses()); }