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