01: /*
02: * Copyright 2007 The Kuali Foundation
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: // Created on Apr 27, 2006
17: package org.kuali.rice.config;
18:
19: import java.io.IOException;
20: import java.util.ArrayList;
21: import java.util.List;
22: import java.util.Map;
23: import java.util.Properties;
24:
25: import junit.framework.TestCase;
26:
27: import org.junit.Test;
28:
29: public class BaseConfigTest extends TestCase {
30: private static final class SimpleConfig extends BaseConfig {
31: private Properties baseProps;
32: private Map baseObjects;
33:
34: public SimpleConfig(List<String> fileLocs,
35: Properties baseProps, Map baseObjects) {
36: super (fileLocs);
37: this .baseProps = baseProps;
38: this .baseObjects = baseObjects;
39: }
40:
41: public Properties getBaseProperties() {
42: return this .baseProps;
43: }
44:
45: public Map getBaseObjects() {
46: return this .baseObjects;
47: }
48: }
49:
50: /**
51: * Tests the hierarchical override capabilities.
52: */
53: @Test
54: public void testBaseConfig() throws IOException {
55: Properties base = new Properties();
56: base.setProperty("foo", "base:foo");
57: base.setProperty("boo", "base:boo");
58: List<String> configs = new ArrayList<String>(1);
59: configs.add("classpath:org/kuali/rice/config/config-1.xml");
60: SimpleConfig sc = new SimpleConfig(configs, base, null);
61: sc.parseConfig();
62: assertEquals("base:boo", sc.getProperty("boo"));
63: assertEquals("config-1:foo base:boo", sc.getProperty("foo"));
64: assertEquals("config-2:bar config-1:baz", sc.getProperty("bar"));
65: assertEquals("config-2:blah base:boo", sc.getProperty("blah"));
66: }
67: }
|