1 17 package org.alfresco.repo.cache; 18 19 import java.io.Serializable ; 20 21 import org.jboss.cache.DummyTransactionManagerLookup; 22 import org.jboss.cache.Fqn; 23 import org.jboss.cache.TreeCache; 24 25 import junit.framework.TestCase; 26 27 32 public class TreeCacheAdapterTest extends TestCase 33 { 34 private static final String KEY_A = "A"; 35 private static final String VALUE_A = "AAA"; 36 private static final String KEY_B = "B"; 37 private static final String VALUE_B = "BBB"; 38 39 private TreeCache treeCache; 40 private TreeCacheAdapter<Serializable , Serializable > cache; 41 42 @Override 43 public void setUp() throws Exception 44 { 45 treeCache = new TreeCache(); 46 treeCache.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName()); 47 treeCache.start(); 48 49 cache = new TreeCacheAdapter<Serializable , Serializable >(); 50 cache.setCache(treeCache); 51 cache.setRegionName(getName()); 52 } 53 54 public void testSimplePutGet() throws Exception 55 { 56 cache.put(KEY_A, VALUE_A); 57 cache.put(KEY_B, VALUE_B); 58 59 Serializable checkValueA = (Serializable ) treeCache.get(new Fqn(getName()), KEY_A); 61 assertNotNull("Value A is not present in underlying cache", checkValueA); 62 assertEquals("Value A is incorrect in underlying cache", VALUE_A, checkValueA); 63 64 Serializable checkValueB = cache.get(KEY_B); 65 assertNotNull("Value B is not present in cache", checkValueB); 66 assertEquals("Value B is incorrect in cache", VALUE_B, checkValueB); 67 } 68 } 69 | Popular Tags |