Clover coverage report -
Coverage timestamp: Wed Jan 31 2007 15:38:53 EST
file stats: LOC: 88   Methods: 3
NCLOC: 62   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
LRUConfigurationTest.java - 100% 100% 100%
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.eviction;
 8   
 9    import junit.framework.TestCase;
 10    import org.jboss.cache.config.ConfigurationException;
 11    import org.jboss.cache.factories.XmlConfigurationParser;
 12    import org.jboss.cache.xml.XmlHelper;
 13    import org.w3c.dom.Element;
 14   
 15    /**
 16    * Unit tests for LRUConfiguration.
 17    *
 18    * @author Daniel Huang (dhuang@jboss.org)
 19    * @version $Revision: 1.5 $
 20    */
 21    public class LRUConfigurationTest extends TestCase
 22    {
 23   
 24  1 public void testXMLParsing() throws Exception
 25    {
 26  1 LRUConfiguration config = new LRUConfiguration();
 27  1 String xml =
 28    "<region name=\"/org/jboss/data\">\n" +
 29    "<attribute name=\"maxNodes\">5000</attribute>\n" +
 30    "<attribute name=\"timeToLiveSeconds\">1000</attribute>\n" +
 31    "</region>";
 32   
 33  1 Element element = XmlHelper.stringToElement(xml);
 34   
 35  1 XmlConfigurationParser.parseEvictionPolicyConfig(element, config);
 36   
 37  1 assertEquals(5000, config.getMaxNodes());
 38  1 assertEquals(1000, config.getTimeToLiveSeconds());
 39    }
 40   
 41  1 public void testXMLParsing2() throws Exception
 42    {
 43  1 LRUConfiguration config = new LRUConfiguration();
 44  1 String xml = "<region name=\"/maxAgeTest/\">\n" +
 45    "<attribute name=\"maxNodes\">10000</attribute>\n" +
 46    "<attribute name=\"timeToLiveSeconds\">8</attribute>\n" +
 47    "<attribute name=\"maxAgeSeconds\">10</attribute>\n" +
 48    "</region>";
 49  1 Element element = XmlHelper.stringToElement(xml);
 50   
 51  1 XmlConfigurationParser.parseEvictionPolicyConfig(element, config);
 52   
 53  1 assertEquals(10000, config.getMaxNodes());
 54  1 assertEquals(8, config.getTimeToLiveSeconds());
 55  1 assertEquals(10, config.getMaxAgeSeconds());
 56    }
 57   
 58  1 public void testXMLParsing3() throws Exception
 59    {
 60  1 LRUConfiguration config = new LRUConfiguration();
 61  1 String xml = "<region name=\"/maxAgeTest/\">\n" +
 62    "<attribute name=\"maxNodes\">10000</attribute>\n" +
 63    "<attribute name=\"maxAgeSeconds\">10</attribute>\n" +
 64    "</region>";
 65  1 Element element = XmlHelper.stringToElement(xml);
 66  1 boolean caught = false;
 67  1 try
 68    {
 69  1 XmlConfigurationParser.parseEvictionPolicyConfig(element, config);
 70    }
 71    catch (ConfigurationException ce)
 72    {
 73  1 caught = true;
 74    }
 75  1 assertTrue("Configure exception should have been caught", caught);
 76   
 77  1 xml = "<region name=\"/maxAgeTest/\">\n" +
 78    "<attribute name=\"timeToLiveSeconds\">8</attribute>\n" +
 79    "<attribute name=\"maxAgeSeconds\">10</attribute>\n" +
 80    "</region>";
 81   
 82  1 element = XmlHelper.stringToElement(xml);
 83   
 84  1 XmlConfigurationParser.parseEvictionPolicyConfig(element, config);
 85   
 86  1 assertEquals(0, config.getMaxNodes());
 87    }
 88    }