1 7 package org.jboss.cache.loader; 8 9 import junit.framework.TestCase; 10 import org.apache.commons.logging.Log; 11 import org.apache.commons.logging.LogFactory; 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 22 public abstract class AbstractCacheLoaderTestBase extends TestCase 23 { 24 25 protected final Log log = LogFactory.getLog(getClass()); 26 27 public AbstractCacheLoaderTestBase(String name) 28 { 29 super(name); 30 } 31 32 public AbstractCacheLoaderTestBase() 33 { 34 } 35 36 protected void setUp() throws Exception 37 { 38 log.debug(""); 39 log.debug("test " + getName()); 40 } 41 42 43 protected CacheLoaderConfig getSingleCacheLoaderConfig(String preload, String cacheloaderClass, String properties, boolean async, boolean fetchPersistentState, boolean shared) throws Exception 44 { 45 return getSingleCacheLoaderConfig(preload, cacheloaderClass, properties, async, fetchPersistentState, shared, false); 46 } 47 48 protected CacheLoaderConfig getSingleCacheLoaderConfig(String preload, String cacheloaderClass, String properties, boolean async, boolean fetchPersistentState, boolean shared, boolean purgeOnStartup) throws Exception 49 { 50 return getSingleCacheLoaderConfig(false, preload, cacheloaderClass, properties, async, fetchPersistentState, shared, purgeOnStartup); 51 } 52 53 protected CacheLoaderConfig getSingleCacheLoaderConfig(boolean passivation, String preload, String cacheloaderClass, String properties, boolean async, boolean fetchPersistentState, boolean shared, boolean purgeOnStartup) throws Exception 54 { 55 String xml = "<config>\n" + 56 "<passivation>" + passivation + "</passivation>\n" + 57 "<preload>" + preload + "</preload>\n" + 58 "<cacheloader>\n" + 59 "<class>" + cacheloaderClass + "</class>\n" + 60 "<properties>" + properties + "</properties>\n" + 61 "<async>" + async + "</async>\n" + 62 "<shared>" + shared + "</shared>\n" + 63 "<fetchPersistentState>" + fetchPersistentState + "</fetchPersistentState>\n" + 64 "<purgeOnStartup>" + purgeOnStartup + "</purgeOnStartup>\n" + 65 "</cacheloader>\n" + 66 "</config>"; 67 Element element = XmlHelper.stringToElement(xml); 68 return XmlConfigurationParser.parseCacheLoaderConfig(element); 69 } 70 } 71 | Popular Tags |