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