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 FIFOConfigurationTest extends TestCase 22 { 23 24 public void testXMLParse() throws Exception 25 { 26 FIFOConfiguration config = new FIFOConfiguration(); 27 String xml = "<region name=\"abc\">" + 28 "<attribute name=\"maxNodes\">1000</attribute>" + 29 "</region>"; 30 31 Element element = XmlHelper.stringToElement(xml); 32 33 XmlConfigurationParser.parseEvictionPolicyConfig(element, config); 34 35 assertEquals(1000, config.getMaxNodes()); 36 37 } 38 39 public void testXMLParse2() throws Exception 40 { 41 FIFOConfiguration config = new FIFOConfiguration(); 42 String xml = "<region name=\"abc\">" + 43 "</region>"; 44 45 Element element = XmlHelper.stringToElement(xml); 46 47 try 48 { 49 XmlConfigurationParser.parseEvictionPolicyConfig(element, config); 50 } 51 catch (ConfigurationException ce) 52 { 53 assertTrue("Configure Exception properly thrown", true); 54 return; 55 } 56 fail("Invalid region FIFO configuration did not cause ConfigureException to be thrown"); 57 } 58 59 public void testXMLParse3() throws Exception 60 { 61 FIFOConfiguration config = new FIFOConfiguration(); 62 String xml = "<region>" + 63 "<attribute name=\"maxNodes\">1000</attribute>" + 64 "</region>"; 65 66 Element element = XmlHelper.stringToElement(xml); 67 68 try 69 { 70 XmlConfigurationParser.parseEvictionPolicyConfig(element, config); 71 } 72 catch (ConfigurationException ce) 73 { 74 assertTrue("Configure Exception properly thrown", true); 75 } 76 } 77 } 78 | Popular Tags |