KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > cache > test > standAloneAop > CollectionProxyAopTest


1 /*
2  *
3  * JBoss, the OpenSource J2EE webOS
4  *
5  * Distributable under LGPL license.
6  * See terms of license at gnu.org.
7  */

8
9 package org.jboss.test.cache.test.standAloneAop;
10
11 import junit.framework.Test;
12 import junit.framework.TestCase;
13 import junit.framework.TestSuite;
14 import org.jboss.cache.CacheException;
15 import org.jboss.cache.PropertyConfigurator;
16 import org.jboss.cache.TreeCache;
17 import org.jboss.cache.aop.TreeCacheAop;
18 import org.jboss.cache.lock.IsolationLevel;
19 import org.jboss.cache.lock.LockStrategyFactory;
20 import org.jboss.cache.transaction.DummyTransactionManager;
21
22 import javax.naming.Context JavaDoc;
23 import java.util.ArrayList JavaDoc;
24 import java.util.Properties JavaDoc;
25 import java.util.Random JavaDoc;
26
27
28 /**
29  * Test out the Collection proxy generation.
30  *
31  * @version $Revision: 1.1 $
32  * @author<a HREF="mailto:bwang@jboss.org">Ben Wang</a> December 2004
33  */

34 public class CollectionProxyAopTest extends TestCase
35 {
36    static TreeCacheAop cache_;
37    int cachingMode_ = TreeCache.LOCAL;
38
39    public CollectionProxyAopTest(String JavaDoc name)
40    {
41       super(name);
42    }
43
44    public void setUp() throws Exception JavaDoc
45    {
46       super.setUp();
47       initCaches(TreeCache.LOCAL);
48
49       log("LocalConcurrentTestCase: cacheMode=TRANSIENT, one cache");
50    }
51
52    public void tearDown() throws Exception JavaDoc
53    {
54       super.tearDown();
55       destroyCaches();
56    }
57
58    void initCaches(int caching_mode) throws Exception JavaDoc
59    {
60       cachingMode_ = caching_mode;
61       cache_ = new TreeCacheAop();
62       PropertyConfigurator config = new PropertyConfigurator();
63       config.configure(cache_, "META-INF/local-aop-eviction-service.xml"); // read in generic local xml
64
cache_.createService();
65       cache_.startService();
66    }
67
68    void destroyCaches() throws Exception JavaDoc
69    {
70       cache_.stopService();
71       cache_ = null;
72    }
73
74    public void testListSubClass() throws Exception JavaDoc
75    {
76       String JavaDoc node = "/aop/list";
77       MyList list = new MyList();
78       list.add("Ben");
79       cache_.putObject(node, list);
80    }
81
82    public static Test suite() throws Exception JavaDoc
83    {
84       return new TestSuite(CollectionProxyAopTest.class);
85    }
86
87    private static void log(String JavaDoc str)
88    {
89       System.out.println("Thread: " + Thread.currentThread() + ": " + str);
90 // System.out.println(str);
91
}
92
93    public static class MyList extends ArrayList JavaDoc
94    {
95       public MyList()
96       {
97          super();
98       }
99       // Just a place holder to test out the proxy generation
100
}
101 }
102
Popular Tags