KickJava   Java API By Example, From Geeks To Geeks.

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


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
11 import org.jboss.cache.factories.XmlConfigurationParser;
12 import org.jboss.cache.xml.XmlHelper;
13 import org.w3c.dom.Element JavaDoc;
14
15 /**
16  * LFU Configuration test.
17  *
18  * @author Daniel Huang (dhuang@jboss.org)
19  * @version $Revision: 1.5 $
20  */

21 public class LFUConfigurationTest extends TestCase
22 {
23
24    public void testXMLParsing() throws Exception JavaDoc
25    {
26       LFUConfiguration config = new LFUConfiguration();
27       String JavaDoc xml =
28             "<region name=\"abc\">" +
29                   "<attribute name=\"minNodes\">10</attribute>" +
30                   "<attribute name=\"maxNodes\">20</attribute>" +
31                   "</region>";
32
33       Element JavaDoc 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 JavaDoc
42    {
43       LFUConfiguration config = new LFUConfiguration();
44       String JavaDoc xml =
45             "<region name=\"abc\">" +
46                   "<attribute name=\"minNodes\">10</attribute>" +
47                   "</region>";
48       Element JavaDoc 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 JavaDoc
57    {
58       LFUConfiguration config = new LFUConfiguration();
59       String JavaDoc xml =
60             "<region name=\"abc\">" +
61                   "<attribute name=\"maxNodes\">20</attribute>" +
62                   "</region>";
63       Element JavaDoc 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