1 package dynaop.util; 2 3 import junit.framework.TestCase; 4 5 10 public class CacheTest extends TestCase { 11 12 public void testGet() { 13 final Object keyA = new Object (); 14 final Object valueA = new Object (); 15 final Object keyB = new Object (); 16 final Object valueB = new Object (); 17 18 Cache cache = new Cache() { 19 protected Object create(Object key) { 20 if (key == keyA) 21 return valueA; 22 if (key == keyB) 23 return valueB; 24 return null; 25 } 26 }; 27 28 assertSame(valueA, cache.get(keyA)); 29 assertSame(valueB, cache.get(keyB)); 30 assertNull(cache.get(new Object ())); 31 assertNull(cache.get(null)); 32 } 33 } 34 | Popular Tags |