Clover coverage report -
Coverage timestamp: Thu Jul 5 2007 20:02:32 EDT
file stats: LOC: 82   Methods: 5
NCLOC: 60   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ChainingCacheLoaderBasicTest.java 50% 78.6% 80% 73.9%
coverage coverage
 1    /*
 2    * JBoss, Home of Professional Open Source
 3    *
 4    * Distributable under LGPL license.
 5    * See terms of license at gnu.org.
 6    */
 7    package org.jboss.cache.loader;
 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.misc.TestingUtil;
 14    import org.jboss.cache.xml.XmlHelper;
 15    import org.w3c.dom.Element;
 16   
 17    import java.io.File;
 18   
 19    /**
 20    * Tests basic functionality of a chaining cache loader with 2 different loaders
 21    *
 22    * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik@jboss.org)</a>
 23    */
 24    public class ChainingCacheLoaderBasicTest extends CacheLoaderTestsBase
 25    {
 26    private String loc1 = System.getProperty("java.io.tmpdir", ".") + File.separator + "JBossCache-ChainingCacheLoaderBasicTest-1";
 27    private String loc2 = System.getProperty("java.io.tmpdir", ".") + File.separator + "JBossCache-ChainingCacheLoaderBasicTest-2";
 28   
 29  61 public ChainingCacheLoaderBasicTest()
 30    {
 31  61 File dir1 = new File(loc1);
 32  61 File dir2 = new File(loc2);
 33   
 34  0 if (!dir1.exists()) dir1.mkdirs();
 35  0 if (!dir2.exists()) dir2.mkdirs();
 36    }
 37   
 38  61 protected void configureCache() throws Exception
 39    {
 40  61 cache.getConfiguration().setCacheLoaderConfig(getCacheLoaderConfig(loc1, loc2));
 41  61 TestingUtil.recursiveFileRemove(loc1);
 42  61 TestingUtil.recursiveFileRemove(loc2);
 43   
 44    }
 45   
 46  61 protected CacheLoaderConfig getCacheLoaderConfig(String loc1, String loc2) throws Exception
 47    {
 48  61 String xml = "<config>\n" +
 49    "<passivation>false</passivation>\n" +
 50    "<preload></preload>\n" +
 51    "<cacheloader>\n" +
 52    "<class>org.jboss.cache.loader.FileCacheLoader</class>\n" +
 53    "<properties>" +
 54    " location=" + loc1 + "\n" +
 55    "</properties>\n" +
 56    "<async>false</async>\n" +
 57    "<fetchPersistentState>true</fetchPersistentState>\n" +
 58    "</cacheloader>\n" +
 59    "<cacheloader>\n" +
 60    "<class>org.jboss.cache.loader.FileCacheLoader</class>\n" +
 61    "<properties>" +
 62    " location=" + loc2 + "\n" +
 63    "</properties>\n" +
 64    "<async>false</async>\n" +
 65    "<fetchPersistentState>false</fetchPersistentState>\n" +
 66    "</cacheloader>\n" +
 67    "</config>";
 68  61 Element element = XmlHelper.stringToElement(xml);
 69  61 return XmlConfigurationParser.parseCacheLoaderConfig(element);
 70    }
 71   
 72  1 public static Test suite()
 73    {
 74  1 return new TestSuite(ChainingCacheLoaderBasicTest.class);
 75    }
 76   
 77   
 78  0 public static void main(String[] args)
 79    {
 80  0 junit.textui.TestRunner.run(suite());
 81    }
 82    }