KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > cache > pojo > collection > CachedListImplTest


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.pojo.PojoCache;
9 import org.jboss.cache.pojo.PojoCacheFactory;
10 import org.jboss.cache.Fqn;
11
12 import java.util.List JavaDoc;
13 import java.util.ArrayList JavaDoc;
14
15 /**
16  * List implementation testing.
17  *
18  * @author Ben Wang
19  */

20
21 public class CachedListImplTest extends TestCase
22 {
23    Log log = LogFactory.getLog(CachedListImplTest.class);
24    PojoCache cache_, cache1_;
25
26    public CachedListImplTest(String JavaDoc name)
27    {
28       super(name);
29    }
30
31
32    protected void setUp() throws Exception JavaDoc
33    {
34       super.setUp();
35       log.info("setUp() ....");
36       String JavaDoc configFile = "META-INF/replSync-service.xml";
37       boolean toStart = true;
38       cache_ = PojoCacheFactory.createCache(configFile, toStart);
39
40       cache1_ = PojoCacheFactory.createCache(configFile, toStart);
41    }
42
43    protected void tearDown() throws Exception JavaDoc
44    {
45       super.tearDown();
46       cache_.stop();
47       cache1_.stop();
48    }
49
50    public void testSimpleRepl()
51    {
52       List JavaDoc list = new ArrayList JavaDoc();
53       list.add("1");
54       list.add("2");
55
56       cache_.attach("list", list);
57
58       // proxy now
59
list = (List JavaDoc)cache_.find("list");
60
61       // test repl
62
cache_.getCache().put(Fqn.fromString("test"), "1", list);
63
64       ArrayList JavaDoc l1 = (ArrayList JavaDoc)cache1_.getCache().get(Fqn.fromString("test"), "1");
65       System.out.println(" list : " +l1);
66    }
67
68    public static Test suite() throws Exception JavaDoc
69    {
70       return new TestSuite(CachedListImplTest.class);
71    }
72
73    public static void main(String JavaDoc[] args) throws Exception JavaDoc
74    {
75       junit.textui.TestRunner.run(suite());
76    }
77
78 }
79
80
Popular Tags