01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package org.apache.commons.configuration;
19:
20: import junit.framework.Test;
21: import junit.framework.TestCase;
22: import junit.framework.TestSuite;
23:
24: /**
25: * @author <a href="mailto:ricardo.gladwell@btinternet.com">Ricardo Gladwell</a>
26: */
27: public class TestConfigurationMap extends TestCase {
28:
29: ConfigurationMap map;
30:
31: String[] properties = { "booleanProperty", "doubleProperty",
32: "floatProperty", "intProperty", "longProperty",
33: "shortProperty", "stringProperty" };
34:
35: Object[] values = { Boolean.TRUE, new Double(Double.MAX_VALUE),
36: new Float(Float.MAX_VALUE), new Integer(Integer.MAX_VALUE),
37: new Long(Long.MAX_VALUE), new Short(Short.MAX_VALUE),
38: "This is a string" };
39:
40: /**
41: * Construct a new instance of this test case.
42: * @param name Name of the test case
43: */
44: public TestConfigurationMap(String name) {
45: super (name);
46: }
47:
48: /**
49: * Set up instance variables required by this test case.
50: */
51: public void setUp() throws Exception {
52: BaseConfiguration configuration = new BaseConfiguration();
53: for (int i = 0; i < properties.length; i++)
54: configuration.setProperty(properties[i], values[i]);
55: map = new ConfigurationMap(configuration);
56: }
57:
58: /**
59: * Return the tests included in this test suite.
60: */
61: public static Test suite() {
62: return (new TestSuite(TestConfigurationMap.class));
63: }
64:
65: /**
66: * Tear down instance variables required by this test case.
67: */
68: public void tearDown() {
69: map = null;
70: }
71:
72: /**
73: * Class under test for Object put(Object, Object)
74: */
75: public void testPut() {
76: for (int i = 0; i < properties.length; i++) {
77: Object object = map.put(properties[i], values[i]);
78: assertNotNull("Returned null from put.", object);
79: assertEquals("Returned wrong result.", values[i], object);
80: object = map.get(properties[i]);
81: assertNotNull("Returned null from get.", object);
82: assertEquals("Returned wrong result.", values[i], object);
83: }
84: }
85:
86: }
|