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