KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > cache > eviction > FIFOConfigurationTest


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 JavaDoc;
14
15 /**
16  * Unit test for FIFOConfiguration.
17  *
18  * @author Daniel Huang (dhuang@jboss.org)
19  * @version $Revision: 1.7 $
20  */

21 public class FIFOConfigurationTest extends TestCase
22 {
23
24    public void testXMLParse() throws Exception JavaDoc
25    {
26       FIFOConfiguration config = new FIFOConfiguration();
27       String JavaDoc xml = "<region name=\"abc\">" +
28             "<attribute name=\"maxNodes\">1000</attribute>" +
29             "</region>";
30
31       Element JavaDoc 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 JavaDoc
40    {
41       FIFOConfiguration config = new FIFOConfiguration();
42       String JavaDoc xml = "<region name=\"abc\">" +
43             "</region>";
44
45       Element JavaDoc 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 JavaDoc
60    {
61       FIFOConfiguration config = new FIFOConfiguration();
62       String JavaDoc xml = "<region>" +
63             "<attribute name=\"maxNodes\">1000</attribute>" +
64             "</region>";
65
66       Element JavaDoc 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