1 7 package org.jboss.cache.loader; 8 9 import junit.framework.Test; 10 import junit.framework.TestSuite; 11 12 import org.jboss.cache.config.CacheLoaderConfig; 13 import org.jboss.cache.factories.XmlConfigurationParser; 14 import org.jboss.cache.xml.XmlHelper; 15 import org.w3c.dom.Element ; 16 17 import java.io.File ; 18 19 24 public class ChainingCacheLoaderBasicTest extends CacheLoaderTestsBase 25 { 26 private String loc1 = System.getProperty("java.io.tmpdir", ".") + File.separator + "JBossCache-ChainingCacheLoaderBasicTest-1"; 27 private String loc2 = System.getProperty("java.io.tmpdir", ".") + File.separator + "JBossCache-ChainingCacheLoaderBasicTest-2"; 28 29 public ChainingCacheLoaderBasicTest() 30 { 31 File dir1 = new File (loc1); 32 File dir2 = new File (loc2); 33 34 if (!dir1.exists()) dir1.mkdirs(); 35 if (!dir2.exists()) dir2.mkdirs(); 36 } 37 38 protected void configureCache() throws Exception 39 { 40 cache.getConfiguration().setCacheLoaderConfig(getCacheLoaderConfig(loc1, loc2)); 41 } 42 43 protected CacheLoaderConfig getCacheLoaderConfig(String loc1, String loc2) throws Exception 44 { 45 String xml = "<config>\n" + 46 "<passivation>false</passivation>\n" + 47 "<preload></preload>\n" + 48 "<cacheloader>\n" + 49 "<class>org.jboss.cache.loader.FileCacheLoader</class>\n" + 50 "<properties>" + 51 " location=" + loc1 + "\n" + 52 "</properties>\n" + 53 "<async>false</async>\n" + 54 "<fetchPersistentState>true</fetchPersistentState>\n" + 55 "</cacheloader>\n" + 56 "<cacheloader>\n" + 57 "<class>org.jboss.cache.loader.FileCacheLoader</class>\n" + 58 "<properties>" + 59 " location=" + loc2 + "\n" + 60 "</properties>\n" + 61 "<async>false</async>\n" + 62 "<fetchPersistentState>false</fetchPersistentState>\n" + 63 "</cacheloader>\n" + 64 "</config>"; 65 Element element = XmlHelper.stringToElement(xml); 66 return XmlConfigurationParser.parseCacheLoaderConfig(element); 67 } 68 69 public static Test suite() 70 { 71 return new TestSuite(ChainingCacheLoaderBasicTest.class); 72 } 73 74 75 public static void main(String [] args) 76 { 77 junit.textui.TestRunner.run(suite()); 78 } 79 } 80 | Popular Tags |