1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.rice.core.config;
18
19 import java.io.IOException;
20 import java.util.ArrayList;
21 import java.util.List;
22 import java.util.Properties;
23
24 import junit.framework.TestCase;
25
26 import org.junit.Test;
27 import org.kuali.rice.core.config.SimpleConfig;
28
29 public class BaseConfigTest extends TestCase {
30
31
32
33 @Test public void testBaseConfig() throws IOException {
34 Properties base = new Properties();
35 base.setProperty("foo", "base:foo");
36 base.setProperty("boo", "base:boo");
37 List<String> configs = new ArrayList<String>(1);
38 configs.add("classpath:org/kuali/rice/core/config/config-1.xml");
39 Config sc = new JAXBConfigImpl(configs, base);
40 sc.parseConfig();
41 assertEquals("base:boo", sc.getProperty("boo"));
42 assertEquals("config-1:foo base:boo", sc.getProperty("foo"));
43 assertEquals("config-2:bar config-1:baz", sc.getProperty("bar"));
44 assertEquals("config-2:blah base:boo", sc.getProperty("blah"));
45 assertEquals("config-2:quux", sc.getProperty("quux"));
46
47 String r1 = sc.getProperty("random1");
48 String r2 = sc.getProperty("random2");
49 String r3 = sc.getProperty("random3");
50
51 assertNotNull(r1);
52 assertNotNull(r2);
53 assertNotNull(r3);
54
55 assertTrue(between(100, 199, Integer.parseInt(r1)));
56 assertTrue(between(200, 299, Integer.parseInt(r2)));
57 assertTrue(between(300, 399, Integer.parseInt(r3)));
58 }
59
60 protected boolean between(int min, int max, int val) {
61 return val >= min && val <= max;
62 }
63 }