1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| package org.jboss.cache.eviction; |
8 |
| |
9 |
| import junit.framework.TestCase; |
10 |
| import org.jboss.cache.xml.XmlHelper; |
11 |
| import org.jboss.cache.config.ConfigurationException; |
12 |
| import org.jboss.cache.factories.XmlConfigurationParser; |
13 |
| import org.w3c.dom.Element; |
14 |
| |
15 |
| |
16 |
| |
17 |
| |
18 |
| |
19 |
| public class ElementSizeConfigurationTest extends TestCase |
20 |
| { |
21 |
1
| public void testXMLParse1() throws Exception
|
22 |
| { |
23 |
1
| ElementSizeConfiguration config = new ElementSizeConfiguration();
|
24 |
1
| String xml = "<region name=\"abc\">" +
|
25 |
| "<attribute name=\"maxNodes\">1000</attribute>" + |
26 |
| "<attribute name=\"maxElementsPerNode\">100</attribute>" + |
27 |
| "</region>"; |
28 |
| |
29 |
1
| Element element = XmlHelper.stringToElement(xml);
|
30 |
1
| XmlConfigurationParser.parseEvictionPolicyConfig(element, config);
|
31 |
| |
32 |
1
| assertEquals(100, config.getMaxElementsPerNode());
|
33 |
1
| assertEquals(1000, config.getMaxNodes());
|
34 |
| } |
35 |
| |
36 |
| |
37 |
1
| public void testXMLParse2() throws Exception
|
38 |
| { |
39 |
1
| ElementSizeConfiguration config = new ElementSizeConfiguration();
|
40 |
1
| String xml = "<region name=\"abc\">" +
|
41 |
| "<attribute name=\"maxNodes\">1000</attribute>" + |
42 |
| "</region>"; |
43 |
| |
44 |
1
| Element element = XmlHelper.stringToElement(xml);
|
45 |
1
| try
|
46 |
| { |
47 |
1
| XmlConfigurationParser.parseEvictionPolicyConfig(element, config);
|
48 |
| } |
49 |
| catch (ConfigurationException ce) |
50 |
| { |
51 |
1
| assertTrue("Configure exception properly thrown", true);
|
52 |
1
| return;
|
53 |
| } |
54 |
| |
55 |
0
| fail("Invalid region Element Size configuration did not cause ConfigureException to be thrown with empty maxElementsPerNode attribute");
|
56 |
| } |
57 |
| |
58 |
| |
59 |
1
| public void testXMLParse3() throws Exception
|
60 |
| { |
61 |
1
| ElementSizeConfiguration config = new ElementSizeConfiguration();
|
62 |
1
| String xml = "<region name=\"abc\">" +
|
63 |
| "<attribute name=\"maxElementsPerNode\">100</attribute>" + |
64 |
| "</region>"; |
65 |
| |
66 |
1
| Element element = XmlHelper.stringToElement(xml);
|
67 |
| |
68 |
1
| XmlConfigurationParser.parseEvictionPolicyConfig(element, config);
|
69 |
| |
70 |
1
| assertEquals(100, config.getMaxElementsPerNode());
|
71 |
1
| assertEquals(0, config.getMaxNodes());
|
72 |
| } |
73 |
| |
74 |
| } |