1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
| |
18 |
| |
19 |
| |
20 |
| |
21 |
| |
22 |
| |
23 |
| package org.jboss.cache.pojo.collection; |
24 |
| |
25 |
| import junit.framework.TestCase; |
26 |
| import junit.framework.Test; |
27 |
| import junit.framework.TestSuite; |
28 |
| import org.apache.commons.logging.Log; |
29 |
| import org.apache.commons.logging.LogFactory; |
30 |
| import org.jboss.cache.config.Configuration.CacheMode; |
31 |
| import org.jboss.cache.factories.UnitTestCacheFactory; |
32 |
| import org.jboss.cache.pojo.PojoCache; |
33 |
| import org.jboss.cache.pojo.PojoCacheFactory; |
34 |
| import org.jboss.cache.Fqn; |
35 |
| |
36 |
| import java.util.List; |
37 |
| import java.util.ArrayList; |
38 |
| import java.util.Map; |
39 |
| import java.util.HashMap; |
40 |
| |
41 |
| |
42 |
| |
43 |
| |
44 |
| |
45 |
| |
46 |
| |
47 |
| public class CachedMapImplTest extends TestCase |
48 |
| { |
49 |
| Log log = LogFactory.getLog(CachedMapImplTest.class); |
50 |
| PojoCache cache_, cache1_; |
51 |
| |
52 |
2
| public CachedMapImplTest(String name)
|
53 |
| { |
54 |
2
| super(name);
|
55 |
| } |
56 |
| |
57 |
| |
58 |
2
| protected void setUp() throws Exception
|
59 |
| { |
60 |
2
| super.setUp();
|
61 |
2
| log.info("setUp() ....");
|
62 |
2
| boolean toStart = true;
|
63 |
2
| cache_ = PojoCacheFactory.createCache(UnitTestCacheFactory.createConfiguration(CacheMode.REPL_SYNC), toStart);
|
64 |
| |
65 |
2
| cache1_ = PojoCacheFactory.createCache(UnitTestCacheFactory.createConfiguration(CacheMode.REPL_SYNC), toStart);
|
66 |
| } |
67 |
| |
68 |
2
| protected void tearDown() throws Exception
|
69 |
| { |
70 |
2
| super.tearDown();
|
71 |
2
| cache_.stop();
|
72 |
2
| cache1_.stop();
|
73 |
| } |
74 |
| |
75 |
2
| public void testSimpleRepl()
|
76 |
| { |
77 |
2
| Map map = new HashMap();
|
78 |
2
| map.put("1", "1");
|
79 |
2
| map.put("2", "2");
|
80 |
| |
81 |
2
| cache_.attach("map", map);
|
82 |
| |
83 |
| |
84 |
2
| map = (Map)cache_.find("map");
|
85 |
| |
86 |
| |
87 |
2
| cache_.getCache().put(Fqn.fromString("test"), "1", map);
|
88 |
| |
89 |
0
| Map m1 = (Map)cache1_.getCache().get(Fqn.fromString("test"), "1");
|
90 |
0
| System.out.println(" map : " +m1);
|
91 |
| } |
92 |
| |
93 |
2
| public static Test suite() throws Exception
|
94 |
| { |
95 |
2
| return new TestSuite(CachedMapImplTest.class);
|
96 |
| } |
97 |
| |
98 |
0
| public static void main(String[] args) throws Exception
|
99 |
| { |
100 |
0
| junit.textui.TestRunner.run(suite());
|
101 |
| } |
102 |
| |
103 |
| } |