1 package org.jboss.cache.passivation; 2 3 import junit.framework.Test; 4 import junit.framework.TestSuite; 5 import org.jboss.cache.config.CacheLoaderConfig; 6 import org.jboss.cache.factories.XmlConfigurationParser; 7 import org.jboss.cache.xml.XmlHelper; 8 import org.w3c.dom.Element ; 9 10 16 public class PassivationToFileCacheLoaderTest extends PassivationTestsBase 17 { 18 19 20 protected void configureCache() throws Exception 21 { 22 23 String tmp_location = null; 24 String OS = System.getProperty("os.name").toLowerCase(); 25 if (OS.contains("win") || OS.contains("nt")) 26 { 27 tmp_location = System.getProperty("java.io.tmpdir", "c:\\tmp"); 28 } 29 else 30 { 31 tmp_location = System.getProperty("jva.io.tmpdir", "/tmp"); 32 } 33 34 cache.getConfiguration().setCacheLoaderConfig(getCacheLoaderConfig(tmp_location)); 35 } 36 37 protected CacheLoaderConfig getCacheLoaderConfig(String loc) throws Exception 38 { 39 String xml = " <config>\n" + 40 " \n" + 41 " <passivation>true</passivation>\n" + 42 " <preload></preload>\n" + 43 "\n" + 44 " <cacheloader>\n" + 45 " <class>org.jboss.cache.loader.FileCacheLoader</class>\n" + 46 " <properties>\n" + 47 " </properties>\n" + 48 " <async>false</async>\n" + 49 " <fetchPersistentState>false</fetchPersistentState>\n" + 50 " <ignoreModifications>false</ignoreModifications>\n" + 51 " </cacheloader>\n" + 52 " \n" + 53 " </config>"; 54 Element element = XmlHelper.stringToElement(xml); 55 return XmlConfigurationParser.parseCacheLoaderConfig(element); 56 } 57 58 59 public static Test suite() 60 { 61 return new TestSuite(PassivationToFileCacheLoaderTest.class); 62 } 63 64 65 public static void main(String [] args) 66 { 67 junit.textui.TestRunner.run(suite()); 68 } 69 70 } 71 | Popular Tags |