1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.configuration;
19
20 import static org.junit.Assert.assertEquals;
21 import static org.junit.Assert.assertNotNull;
22
23 import org.junit.After;
24 import org.junit.Before;
25 import org.junit.Test;
26
27
28
29
30 public class TestConfigurationMap
31 {
32
33 ConfigurationMap map;
34
35 String[] properties = {
36 "booleanProperty",
37 "doubleProperty",
38 "floatProperty",
39 "intProperty",
40 "longProperty",
41 "shortProperty",
42 "stringProperty"
43 };
44
45 Object[] values = {
46 Boolean.TRUE,
47 new Double(Double.MAX_VALUE),
48 new Float(Float.MAX_VALUE),
49 new Integer(Integer.MAX_VALUE),
50 new Long(Long.MAX_VALUE),
51 new Short(Short.MAX_VALUE),
52 "This is a string"
53 };
54
55
56
57
58 @Before
59 public void setUp() throws Exception
60 {
61 BaseConfiguration configuration = new BaseConfiguration();
62 for(int i = 0; i < properties.length ; i++)
63 configuration.setProperty(properties[i], values[i]);
64 map = new ConfigurationMap(configuration);
65 }
66
67
68
69
70 @After
71 public void tearDown()
72 {
73 map = null;
74 }
75
76
77
78
79 @Test
80 public void testPut()
81 {
82 for(int i = 0; i < properties.length; i++) {
83 Object object = map.put(properties[i], values[i]);
84 assertNotNull("Returned null from put.",object);
85 assertEquals("Returned wrong result.",values[i],object);
86 object = map.get(properties[i]);
87 assertNotNull("Returned null from get.",object);
88 assertEquals("Returned wrong result.",values[i],object);
89 }
90 }
91
92 }