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