1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.configuration2;
18
19 import static org.junit.jupiter.api.Assertions.assertEquals;
20 import static org.junit.jupiter.api.Assertions.assertTrue;
21
22 import org.junit.jupiter.api.Test;
23
24
25
26
27 public abstract class BaseNonStringProperties {
28
29 protected NonStringTestHolder nonStringTestHolder = new NonStringTestHolder();
30
31 protected Configuration conf;
32
33 @Test
34 public void testBoolean() throws Exception {
35 nonStringTestHolder.testBoolean();
36 }
37
38 @Test
39 public void testBooleanArrayValue() throws Exception {
40 final boolean booleanValue = conf.getBoolean("test.boolean");
41 assertTrue(booleanValue);
42 assertEquals(2, conf.getList("test.boolean.array").size());
43 }
44
45 @Test
46 public void testBooleanDefaultValue() throws Exception {
47 nonStringTestHolder.testBooleanDefaultValue();
48 }
49
50 @Test
51 public void testByte() throws Exception {
52 nonStringTestHolder.testByte();
53 }
54
55 @Test
56 public void testByteArrayValue() throws Exception {
57 final byte testValue = 10;
58 final byte byteValue = conf.getByte("test.byte");
59 assertEquals(testValue, byteValue);
60 assertEquals(2, conf.getList("test.byte.array").size());
61 }
62
63 @Test
64 public void testDouble() throws Exception {
65 nonStringTestHolder.testDouble();
66 }
67
68 @Test
69 public void testDoubleArrayValue() throws Exception {
70 final double testValue = 10.25;
71 final double doubleValue = conf.getDouble("test.double");
72 assertEquals(testValue, doubleValue, 0.01);
73 assertEquals(2, conf.getList("test.double.array").size());
74 }
75
76 @Test
77 public void testDoubleDefaultValue() throws Exception {
78 nonStringTestHolder.testDoubleDefaultValue();
79 }
80
81 @Test
82 public void testFloat() throws Exception {
83 nonStringTestHolder.testFloat();
84 }
85
86 @Test
87 public void testFloatArrayValue() throws Exception {
88 final float testValue = (float) 20.25;
89 final float floatValue = conf.getFloat("test.float");
90 assertEquals(testValue, floatValue, 0.01);
91 assertEquals(2, conf.getList("test.float.array").size());
92 }
93
94 @Test
95 public void testFloatDefaultValue() throws Exception {
96 nonStringTestHolder.testFloatDefaultValue();
97
98 }
99
100 @Test
101 public void testInteger() throws Exception {
102 nonStringTestHolder.testInteger();
103 }
104
105 @Test
106 public void testIntegerArrayValue() throws Exception {
107 final int intValue = conf.getInt("test.integer");
108 assertEquals(10, intValue);
109 assertEquals(2, conf.getList("test.integer.array").size());
110 }
111
112 @Test
113 public void testIntegerDefaultValue() throws Exception {
114 nonStringTestHolder.testIntegerDefaultValue();
115 }
116
117 @Test
118 public void testIsEmpty() throws Exception {
119 nonStringTestHolder.testIsEmpty();
120 }
121
122 @Test
123 public void testListMissing() throws Exception {
124 nonStringTestHolder.testListMissing();
125 }
126
127 @Test
128 public void testLong() throws Exception {
129 nonStringTestHolder.testLong();
130 }
131
132 @Test
133 public void testLongArrayValue() throws Exception {
134 final long longValue = conf.getLong("test.long");
135 assertEquals(1000000, longValue);
136 assertEquals(2, conf.getList("test.long.array").size());
137 }
138
139 @Test
140 public void testLongDefaultValue() throws Exception {
141 nonStringTestHolder.testLongDefaultValue();
142 }
143
144 @Test
145 public void testShort() throws Exception {
146 nonStringTestHolder.testShort();
147 }
148
149 @Test
150 public void testShortArrayValue() throws Exception {
151 final short shortValue = conf.getShort("test.short");
152 assertEquals(1, shortValue);
153 assertEquals(2, conf.getList("test.short.array").size());
154 }
155
156 @Test
157 public void testShortDefaultValue() throws Exception {
158 nonStringTestHolder.testShortDefaultValue();
159 }
160
161 @Test
162 public void testSubset() throws Exception {
163 nonStringTestHolder.testSubset();
164 }
165 }