1 16 17 package org.apache.commons.configuration; 18 19 import junit.framework.Test; 20 import junit.framework.TestCase; 21 import junit.framework.TestSuite; 22 23 26 public class TestConfigurationMap extends TestCase 27 { 28 29 ConfigurationMap map; 30 31 String [] properties = { 32 "booleanProperty", 33 "doubleProperty", 34 "floatProperty", 35 "intProperty", 36 "longProperty", 37 "shortProperty", 38 "stringProperty" 39 }; 40 41 Object [] values = { 42 Boolean.TRUE, 43 new Double (Double.MAX_VALUE), 44 new Float (Float.MAX_VALUE), 45 new Integer (Integer.MAX_VALUE), 46 new Long (Long.MAX_VALUE), 47 new Short (Short.MAX_VALUE), 48 "This is a string" 49 }; 50 51 55 public TestConfigurationMap(String name) 56 { 57 super(name); 58 } 59 60 63 public void setUp() throws Exception 64 { 65 BaseConfiguration configuration = new BaseConfiguration(); 66 for(int i = 0; i < properties.length ; i++) 67 configuration.setProperty(properties[i], values[i]); 68 map = new ConfigurationMap(configuration); 69 } 70 71 74 public static Test suite() 75 { 76 return (new TestSuite(TestConfigurationMap.class)); 77 } 78 79 82 public void tearDown() 83 { 84 map = null; 85 } 86 87 90 public void testPut() 91 { 92 for(int i = 0; i < properties.length; i++) { 93 Object object = map.put(properties[i], values[i]); 94 assertNotNull("Returned null from put.",object); 95 assertEquals("Returned wrong result.",values[i],object); 96 object = map.get(properties[i]); 97 assertNotNull("Returned null from get.",object); 98 assertEquals("Returned wrong result.",values[i],object); 99 } 100 } 101 102 } 103 | Popular Tags |