Clover coverage report -
Coverage timestamp: Wed Jan 31 2007 15:38:53 EST
file stats: LOC: 74   Methods: 3
NCLOC: 50   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ElementSizeConfigurationTest.java - 95% 100% 95.7%
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.eviction;
 8   
 9    import junit.framework.TestCase;
 10    import org.jboss.cache.xml.XmlHelper;
 11    import org.jboss.cache.config.ConfigurationException;
 12    import org.jboss.cache.factories.XmlConfigurationParser;
 13    import org.w3c.dom.Element;
 14   
 15    /**
 16    * @author Daniel Huang
 17    * @version $Revision: 1.3 $
 18    */
 19    public class ElementSizeConfigurationTest extends TestCase
 20    {
 21  1 public void testXMLParse1() throws Exception
 22    {
 23  1 ElementSizeConfiguration config = new ElementSizeConfiguration();
 24  1 String xml = "<region name=\"abc\">" +
 25    "<attribute name=\"maxNodes\">1000</attribute>" +
 26    "<attribute name=\"maxElementsPerNode\">100</attribute>" +
 27    "</region>";
 28   
 29  1 Element element = XmlHelper.stringToElement(xml);
 30  1 XmlConfigurationParser.parseEvictionPolicyConfig(element, config);
 31   
 32  1 assertEquals(100, config.getMaxElementsPerNode());
 33  1 assertEquals(1000, config.getMaxNodes());
 34    }
 35   
 36   
 37  1 public void testXMLParse2() throws Exception
 38    {
 39  1 ElementSizeConfiguration config = new ElementSizeConfiguration();
 40  1 String xml = "<region name=\"abc\">" +
 41    "<attribute name=\"maxNodes\">1000</attribute>" +
 42    "</region>";
 43   
 44  1 Element element = XmlHelper.stringToElement(xml);
 45  1 try
 46    {
 47  1 XmlConfigurationParser.parseEvictionPolicyConfig(element, config);
 48    }
 49    catch (ConfigurationException ce)
 50    {
 51  1 assertTrue("Configure exception properly thrown", true);
 52  1 return;
 53    }
 54   
 55  0 fail("Invalid region Element Size configuration did not cause ConfigureException to be thrown with empty maxElementsPerNode attribute");
 56    }
 57   
 58   
 59  1 public void testXMLParse3() throws Exception
 60    {
 61  1 ElementSizeConfiguration config = new ElementSizeConfiguration();
 62  1 String xml = "<region name=\"abc\">" +
 63    "<attribute name=\"maxElementsPerNode\">100</attribute>" +
 64    "</region>";
 65   
 66  1 Element element = XmlHelper.stringToElement(xml);
 67   
 68  1 XmlConfigurationParser.parseEvictionPolicyConfig(element, config);
 69   
 70  1 assertEquals(100, config.getMaxElementsPerNode());
 71  1 assertEquals(0, config.getMaxNodes());
 72    }
 73   
 74    }