1 7 package org.jboss.cache.eviction; 8 9 import junit.framework.TestCase; 10 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 LFUConfigurationTest extends TestCase 22 { 23 24 public void testXMLParsing() throws Exception 25 { 26 LFUConfiguration config = new LFUConfiguration(); 27 String xml = 28 "<region name=\"abc\">" + 29 "<attribute name=\"minNodes\">10</attribute>" + 30 "<attribute name=\"maxNodes\">20</attribute>" + 31 "</region>"; 32 33 Element element = XmlHelper.stringToElement(xml); 34 35 XmlConfigurationParser.parseEvictionPolicyConfig(element, config); 36 37 assertEquals(10, config.getMinNodes()); 38 assertEquals(20, config.getMaxNodes()); 39 } 40 41 public void testXMLParsing2() throws Exception 42 { 43 LFUConfiguration config = new LFUConfiguration(); 44 String xml = 45 "<region name=\"abc\">" + 46 "<attribute name=\"minNodes\">10</attribute>" + 47 "</region>"; 48 Element element = XmlHelper.stringToElement(xml); 49 50 XmlConfigurationParser.parseEvictionPolicyConfig(element, config); 51 52 assertEquals(10, config.getMinNodes()); 53 assertEquals(0, config.getMaxNodes()); 54 } 55 56 public void testXMLParsing3() throws Exception 57 { 58 LFUConfiguration config = new LFUConfiguration(); 59 String xml = 60 "<region name=\"abc\">" + 61 "<attribute name=\"maxNodes\">20</attribute>" + 62 "</region>"; 63 Element element = XmlHelper.stringToElement(xml); 64 65 XmlConfigurationParser.parseEvictionPolicyConfig(element, config); 66 67 assertEquals(0, config.getMinNodes()); 68 assertEquals(20, config.getMaxNodes()); 69 70 } 71 } 72 | Popular Tags |