Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 7 package org.jboss.cache.passivation; 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.util.Properties ; 18 19 26 public class PassivationToJDBCCacheLoaderTest extends PassivationTestsBase 27 { 28 29 30 protected CacheLoaderConfig getCacheLoaderConfig() throws Exception 31 { 32 String xml = " <config>\n" + 33 " \n" + 34 " <passivation>true</passivation>\n" + 35 " <preload></preload>\n" + 36 "\n" + 37 " <cacheloader>\n" + 38 " <class>org.jboss.cache.loader.JDBCCacheLoader</class>\n" + 39 " <properties>\n" + 40 getJDBCProps() + 41 " </properties>\n" + 42 " <async>false</async>\n" + 43 " <fetchPersistentState>false</fetchPersistentState>\n" + 44 " <ignoreModifications>false</ignoreModifications>\n" + 45 " </cacheloader>\n" + 46 " \n" + 47 " </config>"; 48 Element element = XmlHelper.stringToElement(xml); 49 return XmlConfigurationParser.parseCacheLoaderConfig(element); 50 } 51 52 53 protected String getJDBCProps() throws Exception 54 { 55 Properties prop = new Properties (); 56 try 57 { 58 prop.load(this.getClass().getClassLoader().getResourceAsStream("cache-jdbc.properties")); 59 } 60 catch (Exception e) 61 { 62 System.out.println("Error loading jdbc properties "); 63 } 64 return "cache.jdbc.driver =" + prop.getProperty("cache.jdbc.driver") + "\n" + 65 "cache.jdbc.url=" + prop.getProperty("cache.jdbc.url") + "\n" + 66 "cache.jdbc.user=" + prop.getProperty("cache.jdbc.user") + "\n" + 67 "cache.jdbc.password=" + prop.getProperty("cache.jdbc.password") + "\n" + 68 "cache.jdbc.node.type=" + prop.getProperty("cache.jdbc.node.type"); 69 } 70 71 protected void configureCache() throws Exception 72 { 73 cache.getConfiguration().setCacheLoaderConfig(getCacheLoaderConfig()); 74 } 75 76 public static Test suite() 77 { 78 return new TestSuite(PassivationToJDBCCacheLoaderTest.class); 79 } 80 81 public static void main(String [] args) 82 { 83 junit.textui.TestRunner.run(suite()); 84 } 85 } 86
| Popular Tags
|