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.Fqn; |
9 |
| import org.jboss.cache.config.Configuration.CacheMode; |
10 |
| import org.jboss.cache.factories.UnitTestCacheConfigurationFactory; |
11 |
| import org.jboss.cache.pojo.PojoCache; |
12 |
| import org.jboss.cache.pojo.PojoCacheFactory; |
13 |
| |
14 |
| import java.util.ArrayList; |
15 |
| import java.util.List; |
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 |
1
| public CachedListImplTest(String name)
|
29 |
| { |
30 |
1
| super(name);
|
31 |
| } |
32 |
| |
33 |
| |
34 |
1
| protected void setUp() throws Exception
|
35 |
| { |
36 |
1
| super.setUp();
|
37 |
1
| log.info("setUp() ....");
|
38 |
1
| boolean toStart = false;
|
39 |
1
| cache_ = PojoCacheFactory.createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), toStart);
|
40 |
1
| cache_.getCache().getConfiguration().setFetchInMemoryState(false);
|
41 |
1
| cache1_ = PojoCacheFactory.createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), toStart);
|
42 |
1
| cache1_.getCache().getConfiguration().setFetchInMemoryState(false);
|
43 |
1
| cache_.start();
|
44 |
1
| cache1_.start();
|
45 |
| } |
46 |
| |
47 |
1
| protected void tearDown() throws Exception
|
48 |
| { |
49 |
1
| super.tearDown();
|
50 |
1
| cache_.stop();
|
51 |
1
| cache1_.stop();
|
52 |
| } |
53 |
| |
54 |
1
| public void testSimpleRepl()
|
55 |
| { |
56 |
1
| List list = new ArrayList();
|
57 |
1
| list.add("1");
|
58 |
1
| list.add("2");
|
59 |
| |
60 |
1
| cache_.attach("list", list);
|
61 |
| |
62 |
| |
63 |
1
| list = (List) cache_.find("list");
|
64 |
| |
65 |
| |
66 |
1
| try {
|
67 |
1
| cache_.getCache().put(Fqn.fromString("test"), "1", list);
|
68 |
0
| fail("Should have a non-serializable exception on list: " +list);
|
69 |
| } catch (Exception ex) |
70 |
| { |
71 |
| |
72 |
| } |
73 |
| |
74 |
| |
75 |
1
| list = (List) cache_.detach("list");
|
76 |
| |
77 |
| |
78 |
1
| cache_.getCache().put(Fqn.fromString("test"), "1", list);
|
79 |
| |
80 |
1
| ArrayList l1 = (ArrayList) cache1_.getCache().get(Fqn.fromString("test"), "1");
|
81 |
1
| System.out.println(" list : " + l1);
|
82 |
| } |
83 |
| |
84 |
1
| public static Test suite() throws Exception
|
85 |
| { |
86 |
1
| return new TestSuite(CachedListImplTest.class);
|
87 |
| } |
88 |
| |
89 |
0
| public static void main(String[] args) throws Exception
|
90 |
| { |
91 |
0
| junit.textui.TestRunner.run(suite());
|
92 |
| } |
93 |
| |
94 |
| } |
95 |
| |