KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > dynaop > util > CacheTest


1 package dynaop.util;
2
3 import junit.framework.TestCase;
4
5 /**
6  *
7  *
8  * @author Bob Lee (crazybob@crazybob.org)
9  */

10 public class CacheTest extends TestCase {
11
12     public void testGet() {
13         final Object JavaDoc keyA = new Object JavaDoc();
14         final Object JavaDoc valueA = new Object JavaDoc();
15         final Object JavaDoc keyB = new Object JavaDoc();
16         final Object JavaDoc valueB = new Object JavaDoc();
17
18         Cache cache = new Cache() {
19             protected Object JavaDoc create(Object JavaDoc 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 JavaDoc()));
31         assertNull(cache.get(null));
32     }
33 }
34
Popular Tags