001: package org.apache.commons.configuration;
002:
003: /*
004: * Licensed to the Apache Software Foundation (ASF) under one or more
005: * contributor license agreements. See the NOTICE file distributed with
006: * this work for additional information regarding copyright ownership.
007: * The ASF licenses this file to You under the Apache License, Version 2.0
008: * (the "License"); you may not use this file except in compliance with
009: * the License. You may obtain a copy of the License at
010: *
011: * http://www.apache.org/licenses/LICENSE-2.0
012: *
013: * Unless required by applicable law or agreed to in writing, software
014: * distributed under the License is distributed on an "AS IS" BASIS,
015: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016: * See the License for the specific language governing permissions and
017: * limitations under the License.
018: */
019:
020: import junit.framework.TestCase;
021:
022: /**
023: * Test if non-string properties are handled correctly.
024: *
025: * @version $Id: BaseNonStringProperties.java 439648 2006-09-02 20:42:10Z oheger $
026: */
027: public abstract class BaseNonStringProperties extends TestCase {
028:
029: protected NonStringTestHolder nonStringTestHolder = new NonStringTestHolder();
030:
031: public abstract void setUp() throws Exception;
032:
033: public Configuration conf = null;
034:
035: public void testBoolean() throws Exception {
036: nonStringTestHolder.testBoolean();
037: }
038:
039: public void testBooleanDefaultValue() throws Exception {
040: nonStringTestHolder.testBooleanDefaultValue();
041: }
042:
043: public void testBooleanArrayValue() throws Exception {
044: boolean booleanValue = conf.getBoolean("test.boolean");
045: assertEquals(true, booleanValue);
046: assertEquals(2, conf.getList("test.boolean.array").size());
047: }
048:
049: public void testByte() throws Exception {
050: nonStringTestHolder.testByte();
051: }
052:
053: public void testByteArrayValue() throws Exception {
054: byte testValue = 10;
055: byte byteValue = conf.getByte("test.byte");
056: assertEquals(testValue, byteValue);
057: assertEquals(2, conf.getList("test.byte.array").size());
058: }
059:
060: public void testDouble() throws Exception {
061: nonStringTestHolder.testDouble();
062: }
063:
064: public void testDoubleDefaultValue() throws Exception {
065: nonStringTestHolder.testDoubleDefaultValue();
066: }
067:
068: public void testDoubleArrayValue() throws Exception {
069: double testValue = 10.25;
070: double doubleValue = conf.getDouble("test.double");
071: assertEquals(testValue, doubleValue, 0.01);
072: assertEquals(2, conf.getList("test.double.array").size());
073: }
074:
075: public void testFloat() throws Exception {
076: nonStringTestHolder.testFloat();
077: }
078:
079: public void testFloatDefaultValue() throws Exception {
080: nonStringTestHolder.testFloatDefaultValue();
081:
082: }
083:
084: public void testFloatArrayValue() throws Exception {
085: float testValue = (float) 20.25;
086: float floatValue = conf.getFloat("test.float");
087: assertEquals(testValue, floatValue, 0.01);
088: assertEquals(2, conf.getList("test.float.array").size());
089: }
090:
091: public void testInteger() throws Exception {
092: nonStringTestHolder.testInteger();
093: }
094:
095: public void testIntegerDefaultValue() throws Exception {
096: nonStringTestHolder.testIntegerDefaultValue();
097: }
098:
099: public void testIntegerArrayValue() throws Exception {
100: int intValue = conf.getInt("test.integer");
101: assertEquals(10, intValue);
102: assertEquals(2, conf.getList("test.integer.array").size());
103: }
104:
105: public void testLong() throws Exception {
106: nonStringTestHolder.testLong();
107: }
108:
109: public void testLongDefaultValue() throws Exception {
110: nonStringTestHolder.testLongDefaultValue();
111: }
112:
113: public void testLongArrayValue() throws Exception {
114: long longValue = conf.getLong("test.long");
115: assertEquals(1000000, longValue);
116: assertEquals(2, conf.getList("test.long.array").size());
117: }
118:
119: public void testShort() throws Exception {
120: nonStringTestHolder.testShort();
121: }
122:
123: public void testShortDefaultValue() throws Exception {
124: nonStringTestHolder.testShortDefaultValue();
125: }
126:
127: public void testShortArrayValue() throws Exception {
128: short shortValue = conf.getShort("test.short");
129: assertEquals(1, shortValue);
130: assertEquals(2, conf.getList("test.short.array").size());
131: }
132:
133: public void testListMissing() throws Exception {
134: nonStringTestHolder.testListMissing();
135: }
136:
137: public void testSubset() throws Exception {
138: nonStringTestHolder.testSubset();
139: }
140:
141: public void testIsEmpty() throws Exception {
142: nonStringTestHolder.testIsEmpty();
143: }
144: }
|