package uk.co.cosmic_solutions.mdtest2.infinispan.test; import org.infinispan.Cache; import org.infinispan.config.Configuration; import org.infinispan.context.Flag; import org.infinispan.eviction.EvictionStrategy; import org.infinispan.eviction.EvictionThreadPolicy; import org.infinispan.loaders.decorators.AsyncStoreConfig; import org.infinispan.loaders.jdbm.JdbmCacheStoreConfig; import org.infinispan.manager.DefaultCacheManager; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import java.io.File; /** * Created by IntelliJ IDEA. * User: nardonep * Date: 03-Aug-2010 * Time: 07:42:07 */ public class InfinispanTest3 { private static DefaultCacheManager defaultCacheManager; @BeforeClass public static void setup(){ Configuration c=new Configuration(); c.setCacheMode(Configuration.CacheMode.LOCAL); defaultCacheManager=new DefaultCacheManager(c); defaultCacheManager.defineConfiguration("OK",c); defaultCacheManager.defineConfiguration("BADWITHOUTCL",c); Configuration ccl=new Configuration(); JdbmCacheStoreConfig cacheStoreConfig = new JdbmCacheStoreConfig(); File dir = new File("C:\\TEMP\\InfinispanTest3\\BADWITHOUTCL\\"); dir.mkdirs(); for(File f : dir.listFiles()){ f.delete(); } cacheStoreConfig.setLocation(dir.getAbsolutePath()); ccl.getCacheLoaderManagerConfig().addCacheLoaderConfig(cacheStoreConfig); defaultCacheManager.defineConfiguration("BADWITHCL",ccl); } @Test public void testOK(){ runTest("OK",false); } @Test public void testBADWITHOUTCLt(){ runTest("BADWITHOUTCL",true); } @Test public void testBADWITHCL(){ runTest("BADWITHCL",true); } private void runTest(String n,boolean skip) { Cache testCache=defaultCacheManager.getCache(n); try { testCache.getAdvancedCache().put("34","4567"); if(skip){ testCache.getAdvancedCache().withFlags(Flag.SKIP_LOCKING).remove("34"); }else{ testCache.getAdvancedCache().remove("34"); } } catch (Exception e) { throw new RuntimeException(e); } } }