Clover coverage report -
Coverage timestamp: Wed Jan 31 2007 15:38:53 EST
file stats: LOC: 85   Methods: 5
NCLOC: 61   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
PassivationToJDBCCacheLoaderTest.java - 81.8% 80% 81.2%
coverage coverage
 1    /*
 2    * JBoss, the OpenSource J2EE webOS
 3    *
 4    * Distributable under LGPL license.
 5    * See terms of license at gnu.org.
 6    */
 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    /**
 20    * Tests passivation using JDBC Cache Loader.
 21    * This test has MySQL hard-coded. To run it, run MySQL first: mysqld -u=root
 22    *
 23    * @author <a href="mailto:{hmesha@novell.com}">{Hany Mesha}</a>
 24    * @version $Id: PassivationToJDBCCacheLoaderTest.java,v 1.2 2006/10/25 04:50:20 bstansberry Exp $
 25    */
 26    public class PassivationToJDBCCacheLoaderTest extends PassivationTestsBase
 27    {
 28   
 29   
 30  45 protected CacheLoaderConfig getCacheLoaderConfig() throws Exception
 31    {
 32  45 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  45 Element element = XmlHelper.stringToElement(xml);
 49  45 return XmlConfigurationParser.parseCacheLoaderConfig(element);
 50    }
 51   
 52   
 53  45 protected String getJDBCProps() throws Exception
 54    {
 55  45 Properties prop = new Properties();
 56  45 try
 57    {
 58  45 prop.load(this.getClass().getClassLoader().getResourceAsStream("cache-jdbc.properties"));
 59    }
 60    catch (Exception e)
 61    {
 62  0 System.out.println("Error loading jdbc properties ");
 63    }
 64  45 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  45 protected void configureCache() throws Exception
 72    {
 73  45 cache.getConfiguration().setCacheLoaderConfig(getCacheLoaderConfig());
 74    }
 75   
 76  1 public static Test suite()
 77    {
 78  1 return new TestSuite(PassivationToJDBCCacheLoaderTest.class);
 79    }
 80   
 81  0 public static void main(String[] args)
 82    {
 83  0 junit.textui.TestRunner.run(suite());
 84    }
 85    }