1 5 package com.opensymphony.oscache.extra; 6 7 import com.opensymphony.oscache.base.CacheEntry; 8 import com.opensymphony.oscache.base.events.CacheMapAccessEvent; 9 import com.opensymphony.oscache.base.events.CacheMapAccessEventType; 10 11 import junit.framework.Test; 12 import junit.framework.TestCase; 13 import junit.framework.TestSuite; 14 15 22 public class TestCacheMapAccessEventListenerImpl extends TestCase { 23 26 private final String KEY = "Test Cache Map Access Event Listener Impl Key"; 27 28 33 public TestCacheMapAccessEventListenerImpl(String str) { 34 super(str); 35 } 36 37 42 public static Test suite() { 43 return new TestSuite(TestCacheMapAccessEventListenerImpl.class); 44 } 45 46 49 public void testCacheMapAccessEventListenerImpl() { 50 CacheEntry entry = new CacheEntry(KEY); 52 CacheMapAccessEventListenerImpl listener = new CacheMapAccessEventListenerImpl(); 53 54 listener.accessed(new CacheMapAccessEvent(CacheMapAccessEventType.HIT, entry)); 56 listener.accessed(new CacheMapAccessEvent(CacheMapAccessEventType.HIT, entry)); 57 listener.accessed(new CacheMapAccessEvent(CacheMapAccessEventType.STALE_HIT, entry)); 58 listener.accessed(new CacheMapAccessEvent(CacheMapAccessEventType.MISS, entry)); 59 60 assertEquals(listener.getHitCount(), 2); 62 assertEquals(listener.getStaleHitCount(), 1); 63 assertEquals(listener.getMissCount(), 1); 64 65 listener.reset(); 67 assertEquals(listener.getHitCount(), 0); 68 assertEquals(listener.getStaleHitCount(), 0); 69 assertEquals(listener.getMissCount(), 0); 70 } 71 } 72 | Popular Tags |