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