1 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 21 public class MRUConfigurationTest extends TestCase 22 { 23 MRUConfiguration config = null; 24 25 public void setUp() throws Exception 26 { 27 super.setUp(); 28 config = new MRUConfiguration(); 29 } 30 31 public void tearDown() throws Exception 32 { 33 super.tearDown(); 34 } 35 36 public void testXMLParsing() throws Exception 37 { 38 String xml = 39 "<region name=\"/org/jboss/data\">\n" + 40 "<attribute name=\"maxNodes\">5000</attribute>\n" + 41 "</region>"; 42 Element element = XmlHelper.stringToElement(xml); 43 44 XmlConfigurationParser.parseEvictionPolicyConfig(element, config); 45 46 assertEquals(5000, config.getMaxNodes()); 47 } 48 49 public void testXMLParsing2() throws Exception 50 { 51 String xml = "<region name=\"/Test/\">\n" + 52 "<attribute name=\"maxNodes\">10000</attribute>\n" + 53 "</region>"; 54 Element element = XmlHelper.stringToElement(xml); 55 56 XmlConfigurationParser.parseEvictionPolicyConfig(element, config); 57 58 assertEquals(10000, config.getMaxNodes()); 59 } 60 61 public void testXMLParsing3() throws Exception 62 { 63 String xml = "<region name=\"/Test/\">\n" + 64 "</region>"; 65 Element element = XmlHelper.stringToElement(xml); 66 boolean caught = false; 67 try 68 { 69 XmlConfigurationParser.parseEvictionPolicyConfig(element, config); 70 } 71 catch (ConfigurationException ce) 72 { 73 caught = true; 74 } 75 assertTrue("Configure exception should have been caught, maxNodes is required", caught); 76 77 xml = "<region name=\"/Test/\">\n" + 78 "<attribute name=\"maxNodes\">10000</attribute>\n" + 79 "</region>"; 80 81 element = XmlHelper.stringToElement(xml); 82 83 XmlConfigurationParser.parseEvictionPolicyConfig(element, config); 84 85 assertEquals(10000, config.getMaxNodes()); 86 } 87 88 } 89 | Popular Tags |