1 5 package com.opensymphony.oscache.extra; 6 7 import com.opensymphony.oscache.base.Cache; 8 import com.opensymphony.oscache.base.CacheEntry; 9 import com.opensymphony.oscache.base.events.CacheEntryEvent; 10 import com.opensymphony.oscache.base.events.CacheGroupEvent; 11 import com.opensymphony.oscache.base.events.CachePatternEvent; 12 import com.opensymphony.oscache.general.GeneralCacheAdministrator; 13 14 import junit.framework.Test; 15 import junit.framework.TestCase; 16 import junit.framework.TestSuite; 17 18 25 public class TestCacheEntryEventListenerImpl extends TestCase { 26 29 private final String KEY = "Test Cache Entry Event Listener Impl Key"; 30 31 36 public TestCacheEntryEventListenerImpl(String str) { 37 super(str); 38 } 39 40 45 public static Test suite() { 46 return new TestSuite(TestCacheEntryEventListenerImpl.class); 47 } 48 49 52 public void testCacheEntryEventListenerImpl() { 53 CacheEntry entry = new CacheEntry(KEY); 55 GeneralCacheAdministrator admin = new GeneralCacheAdministrator(); 56 Cache cache = new Cache(admin.isMemoryCaching(), admin.isUnlimitedDiskCache(), admin.isOverflowPersistence()); 57 CacheEntryEvent event = new CacheEntryEvent(cache, entry, null); 58 CacheEntryEventListenerImpl listener = new CacheEntryEventListenerImpl(); 59 60 assertEquals(listener.getEntryAddedCount(), 0); 62 assertEquals(listener.getEntryFlushedCount(), 0); 63 assertEquals(listener.getEntryRemovedCount(), 0); 64 assertEquals(listener.getEntryUpdatedCount(), 0); 65 assertEquals(listener.getGroupFlushedCount(), 0); 66 assertEquals(listener.getPatternFlushedCount(), 0); 67 68 listener.cacheEntryAdded(event); 70 listener.cacheEntryFlushed(event); 71 listener.cacheEntryRemoved(event); 72 listener.cacheEntryUpdated(event); 73 74 listener.cacheGroupFlushed(new CacheGroupEvent(cache, "testGroup", null)); 75 listener.cachePatternFlushed(new CachePatternEvent(cache, "testPattern", null)); 76 77 assertEquals(listener.getEntryAddedCount(), 1); 79 assertEquals(listener.getEntryFlushedCount(), 1); 80 assertEquals(listener.getEntryRemovedCount(), 1); 81 assertEquals(listener.getEntryUpdatedCount(), 1); 82 assertEquals(listener.getGroupFlushedCount(), 1); 83 assertEquals(listener.getPatternFlushedCount(), 1); 84 } 85 } 86 | Popular Tags |