1 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.config.Configuration; 13 import org.jboss.cache.factories.DefaultCacheFactory; 14 15 20 public class InterceptorCacheReferenceTest extends TestCase 21 { 22 public void testPessLocking() throws Exception 23 { 24 Configuration c = new Configuration(); 25 c.setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC); 26 Cache cache = DefaultCacheFactory.getInstance().createCache(c); 27 28 assertInterceptorsHaveSameCache((CacheSPI) cache); 29 30 cache.stop(); 31 } 32 33 public void testOptLocking() throws Exception 34 { 35 Configuration c = new Configuration(); 36 c.setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC); 37 Cache cache = DefaultCacheFactory.getInstance().createCache(c); 38 39 assertInterceptorsHaveSameCache((CacheSPI) cache); 40 41 cache.stop(); 42 } 43 44 private void assertInterceptorsHaveSameCache(CacheSPI c) throws Exception 45 { 46 for (Interceptor i : c.getInterceptorChain()) 47 { 48 System.out.println("Testing " + i); 49 assertSame(c, i.cache); 50 } 51 } 52 } 53 | Popular Tags |