Clover coverage report -
Coverage timestamp: Wed Jan 31 2007 15:38:53 EST
file stats: LOC: 88   Methods: 5
NCLOC: 60   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
MRUConfigurationTest.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 MRUConfiguration.
 17    *
 18    * @author Daniel Huang (dhuang@jboss.org)
 19    * @version $Revision: 1.5 $
 20    */
 21    public class MRUConfigurationTest extends TestCase
 22    {
 23    MRUConfiguration config = null;
 24   
 25  3 public void setUp() throws Exception
 26    {
 27  3 super.setUp();
 28  3 config = new MRUConfiguration();
 29    }
 30   
 31  3 public void tearDown() throws Exception
 32    {
 33  3 super.tearDown();
 34    }
 35   
 36  1 public void testXMLParsing() throws Exception
 37    {
 38  1 String xml =
 39    "<region name=\"/org/jboss/data\">\n" +
 40    "<attribute name=\"maxNodes\">5000</attribute>\n" +
 41    "</region>";
 42  1 Element element = XmlHelper.stringToElement(xml);
 43   
 44  1 XmlConfigurationParser.parseEvictionPolicyConfig(element, config);
 45   
 46  1 assertEquals(5000, config.getMaxNodes());
 47    }
 48   
 49  1 public void testXMLParsing2() throws Exception
 50    {
 51  1 String xml = "<region name=\"/Test/\">\n" +
 52    "<attribute name=\"maxNodes\">10000</attribute>\n" +
 53    "</region>";
 54  1 Element element = XmlHelper.stringToElement(xml);
 55   
 56  1 XmlConfigurationParser.parseEvictionPolicyConfig(element, config);
 57   
 58  1 assertEquals(10000, config.getMaxNodes());
 59    }
 60   
 61  1 public void testXMLParsing3() throws Exception
 62    {
 63  1 String xml = "<region name=\"/Test/\">\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, maxNodes is required", caught);
 76   
 77  1 xml = "<region name=\"/Test/\">\n" +
 78    "<attribute name=\"maxNodes\">10000</attribute>\n" +
 79    "</region>";
 80   
 81  1 element = XmlHelper.stringToElement(xml);
 82   
 83  1 XmlConfigurationParser.parseEvictionPolicyConfig(element, config);
 84   
 85  1 assertEquals(10000, config.getMaxNodes());
 86    }
 87   
 88    }