1 16 17 package org.apache.commons.configuration; 18 19 import junit.framework.TestCase; 20 21 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 XMLPropertiesConfiguration conf = new XMLPropertiesConfiguration("test.properties.xml"); 43 44 conf.addProperty("key4", "value4"); 46 conf.clearProperty("key2"); 47 conf.setHeader("Description of the new property list"); 48 49 conf.save("target/test2.properties.xml"); 51 52 XMLPropertiesConfiguration conf2 = new XMLPropertiesConfiguration("target/test2.properties.xml"); 54 55 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 } 64 | Popular Tags |