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.ArrayList; |
10 |
| import java.util.HashMap; |
11 |
| import java.util.HashSet; |
12 |
| import java.util.Map; |
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 |
3
| public RecursiveRefTest(String name)
|
23 |
| { |
24 |
3
| super(name);
|
25 |
| } |
26 |
| |
27 |
3
| protected void setUp() throws Exception
|
28 |
| { |
29 |
3
| super.setUp();
|
30 |
3
| log.info("setUp() ....");
|
31 |
3
| boolean toStart = false;
|
32 |
3
| cache = PojoCacheFactory.createCache(CONFIG_FILENAME, toStart);
|
33 |
3
| cache.start();
|
34 |
3
| cache.attach("/aop/test", new HashMap());
|
35 |
3
| cachedMap = (Map) cache.find("/aop/test");
|
36 |
| } |
37 |
| |
38 |
3
| protected void tearDown() throws Exception
|
39 |
| { |
40 |
3
| super.tearDown();
|
41 |
| } |
42 |
| |
43 |
0
| public void XtestDummy()
|
44 |
| { |
45 |
| |
46 |
| } |
47 |
| |
48 |
| |
49 |
| |
50 |
| |
51 |
| |
52 |
| |
53 |
| |
54 |
| |
55 |
| |
56 |
| |
57 |
| |
58 |
1
| public void testRecursiveList() throws Exception
|
59 |
| { |
60 |
1
| ArrayList list = new ArrayList();
|
61 |
1
| list.add("1");
|
62 |
1
| cache.attach("list", list);
|
63 |
1
| list = (ArrayList) cache.find("list");
|
64 |
1
| list.add(list);
|
65 |
1
| System.out.println(list.toString());
|
66 |
| } |
67 |
| |
68 |
1
| public void testRecursiveSet() throws Exception
|
69 |
| { |
70 |
1
| HashSet set = new HashSet();
|
71 |
1
| set.add("1");
|
72 |
1
| cache.attach("set", set);
|
73 |
1
| set = (HashSet) cache.find("set");
|
74 |
1
| set.add(set);
|
75 |
1
| System.out.println(set.toString());
|
76 |
| } |
77 |
| |
78 |
1
| public void testRecursiveMap() throws Exception
|
79 |
| { |
80 |
1
| HashMap map = new HashMap();
|
81 |
1
| map.put("1", "1");
|
82 |
1
| cache.attach("map", map);
|
83 |
1
| map = (HashMap) cache.find("map");
|
84 |
1
| map.put("2", map);
|
85 |
1
| System.out.println(map.toString());
|
86 |
| } |
87 |
| |
88 |
| } |
89 |
| |
90 |
| |