Clover coverage report -
Coverage timestamp: Thu Jul 5 2007 20:02:32 EDT
file stats: LOC: 85   Methods: 5
NCLOC: 62   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    import org.jboss.cache.config.CacheLoaderConfig;
 12    import org.jboss.cache.factories.XmlConfigurationParser;
 13    import org.jboss.cache.xml.XmlHelper;
 14    import org.w3c.dom.Element;
 15   
 16    import java.util.Properties;
 17   
 18    /**
 19    * Tests passivation using JDBC Cache Loader.
 20    * This test has MySQL hard-coded. To run it, run MySQL first: mysqld -u=root
 21    *
 22    * @author <a href="mailto:{hmesha@novell.com}">{Hany Mesha}</a>
 23    * @version $Id: PassivationToJDBCCacheLoaderTest.java,v 1.4 2007/05/23 10:28:48 msurtani Exp $
 24    */
 25    public class PassivationToJDBCCacheLoaderTest extends PassivationTestsBase
 26    {
 27   
 28   
 29  45 protected CacheLoaderConfig getCacheLoaderConfig() throws Exception
 30    {
 31  45 String xml = " <config>\n" +
 32    " \n" +
 33    " <passivation>true</passivation>\n" +
 34    " <preload></preload>\n" +
 35    "\n" +
 36    " <cacheloader>\n" +
 37    " <class>org.jboss.cache.loader.JDBCCacheLoader</class>\n" +
 38    " <properties>\n" +
 39    getJDBCProps() +
 40    " </properties>\n" +
 41    " <async>false</async>\n" +
 42    " <fetchPersistentState>false</fetchPersistentState>\n" +
 43    " <ignoreModifications>false</ignoreModifications>\n" +
 44    " </cacheloader>\n" +
 45    " \n" +
 46    " </config>";
 47  45 Element element = XmlHelper.stringToElement(xml);
 48  45 return XmlConfigurationParser.parseCacheLoaderConfig(element);
 49    }
 50   
 51   
 52  45 protected String getJDBCProps() throws Exception
 53    {
 54  45 Properties prop = new Properties();
 55  45 try
 56    {
 57  45 prop.load(this.getClass().getClassLoader().getResourceAsStream("cache-jdbc.properties"));
 58    }
 59    catch (Exception e)
 60    {
 61  0 System.out.println("Error loading jdbc properties ");
 62    }
 63  45 return "cache.jdbc.driver =" + prop.getProperty("cache.jdbc.driver") + "\n" +
 64    "cache.jdbc.url=" + prop.getProperty("cache.jdbc.url") + "\n" +
 65    "cache.jdbc.user=" + prop.getProperty("cache.jdbc.user") + "\n" +
 66    "cache.jdbc.password=" + prop.getProperty("cache.jdbc.password") + "\n" +
 67    "cache.jdbc.node.type=" + prop.getProperty("cache.jdbc.node.type") + "\n" +
 68    "cache.jdbc.sql-concat=" + prop.getProperty("cache.jdbc.sql-concat");
 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    }