1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.configuration;
18
19 import junit.framework.TestCase;
20
21 /***
22 * @author Emmanuel Bourg
23 * @version $Revision: 155408 $, $Date: 2005-02-26 13:56:39 +0100 (Sa, 26 Feb 2005) $
24 */
25 public class TestXMLPropertiesConfiguration extends TestCase
26 {
27 public void testLoad() throws Exception
28 {
29 XMLPropertiesConfiguration conf = new XMLPropertiesConfiguration("test.properties.xml");
30
31 assertEquals("header", "Description of the property list", conf.getHeader());
32
33 assertFalse("The configuration is empty", conf.isEmpty());
34 assertEquals("'key1' property", "value1", conf.getProperty("key1"));
35 assertEquals("'key2' property", "value2", conf.getProperty("key2"));
36 assertEquals("'key3' property", "value3", conf.getProperty("key3"));
37 }
38
39 public void testSave() throws Exception
40 {
41
42 XMLPropertiesConfiguration conf = new XMLPropertiesConfiguration("test.properties.xml");
43
44
45 conf.addProperty("key4", "value4");
46 conf.clearProperty("key2");
47 conf.setHeader("Description of the new property list");
48
49
50 conf.save("target/test2.properties.xml");
51
52
53 XMLPropertiesConfiguration conf2 = new XMLPropertiesConfiguration("target/test2.properties.xml");
54
55
56 assertEquals("header", "Description of the new property list", conf2.getHeader());
57
58 assertFalse("The configuration is empty", conf2.isEmpty());
59 assertEquals("'key1' property", "value1", conf2.getProperty("key1"));
60 assertEquals("'key3' property", "value3", conf2.getProperty("key3"));
61 assertEquals("'key4' property", "value4", conf2.getProperty("key4"));
62 }
63 }