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