1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| package org.jboss.cache.interceptors; |
8 |
| |
9 |
| import junit.framework.TestCase; |
10 |
| import org.jboss.cache.Cache; |
11 |
| import org.jboss.cache.CacheSPI; |
12 |
| import org.jboss.cache.DefaultCacheFactory; |
13 |
| import org.jboss.cache.config.Configuration; |
14 |
| |
15 |
| |
16 |
| |
17 |
| |
18 |
| |
19 |
| |
20 |
| public class InterceptorCacheReferenceTest extends TestCase |
21 |
| { |
22 |
1
| public void testPessLocking() throws Exception
|
23 |
| { |
24 |
1
| Configuration c = new Configuration();
|
25 |
1
| c.setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
|
26 |
1
| Cache cache = DefaultCacheFactory.getInstance().createCache(c);
|
27 |
| |
28 |
1
| assertInterceptorsHaveSameCache((CacheSPI) cache);
|
29 |
| |
30 |
1
| cache.stop();
|
31 |
| } |
32 |
| |
33 |
1
| public void testOptLocking() throws Exception
|
34 |
| { |
35 |
1
| Configuration c = new Configuration();
|
36 |
1
| c.setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC);
|
37 |
1
| Cache cache = DefaultCacheFactory.getInstance().createCache(c);
|
38 |
| |
39 |
1
| assertInterceptorsHaveSameCache((CacheSPI) cache);
|
40 |
| |
41 |
1
| cache.stop();
|
42 |
| } |
43 |
| |
44 |
2
| private void assertInterceptorsHaveSameCache(CacheSPI c) throws Exception
|
45 |
| { |
46 |
2
| for (Interceptor i : c.getInterceptorChain())
|
47 |
| { |
48 |
16
| System.out.println("Testing " + i);
|
49 |
16
| assertSame(c, i.cache);
|
50 |
| } |
51 |
| } |
52 |
| } |