1 package org.jboss.cache.pojo; 2 3 import junit.framework.TestCase; 4 import org.apache.commons.logging.Log; 5 import org.apache.commons.logging.LogFactory; 6 import org.jboss.cache.pojo.test.IdObject; 7 import org.jboss.cache.pojo.test.ValueObject; 8 9 import java.util.HashMap ; 10 import java.util.Map ; 11 import java.util.ArrayList ; 12 import java.util.HashSet ; 13 14 public class RecursiveRefTest extends TestCase 15 { 16 private static final String CONFIG_FILENAME = "META-INF/local-service.xml"; 17 private PojoCache cache; 18 Log log = LogFactory.getLog(RecursiveRefTest.class); 19 20 private Map cachedMap; 21 22 public RecursiveRefTest(String name) 23 { 24 super(name); 25 } 26 27 protected void setUp() throws Exception 28 { 29 super.setUp(); 30 log.info("setUp() ...."); 31 boolean toStart = false; 32 cache = PojoCacheFactory.createCache(CONFIG_FILENAME, toStart); 33 cache.start(); 34 cache.attach("/aop/test", new HashMap ()); 35 cachedMap = (Map ) cache.find("/aop/test"); 36 } 37 38 protected void tearDown() throws Exception 39 { 40 super.tearDown(); 41 } 42 43 public void XtestDummy() 44 { 45 46 } 47 48 52 public void testRecuriveMapKey() 53 { 54 try 55 { 56 IdObject id = new IdObject("1"); 57 ValueObject value = new ValueObject(id, 3.0f); 58 cachedMap.put(id, value); 59 } catch (Exception x) 61 { 62 x.printStackTrace(); 63 fail("testFailed"); 64 } } 67 public void testRecursiveList() throws Exception 68 { 69 ArrayList list = new ArrayList (); 70 list.add("1"); 71 cache.attach("list", list); 72 list = (ArrayList )cache.find("list"); 73 list.add(list); 74 System.out.println(list.toString()); 75 } 76 77 public void testRecursiveSet() throws Exception 78 { 79 HashSet set = new HashSet (); 80 set.add("1"); 81 cache.attach("set", set); 82 set = (HashSet )cache.find("set"); 83 set.add(set); 84 System.out.println(set.toString()); 85 } 86 87 public void testRecursiveMap() throws Exception 88 { 89 HashMap map = new HashMap (); 90 map.put("1", "1"); 91 cache.attach("map", map); 92 map = (HashMap )cache.find("map"); 93 map.put("2", map); 94 System.out.println(map.toString()); 95 } 96 97 } 99 100 | Popular Tags |