1 package org.apache.turbine;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 import org.apache.commons.configuration.Configuration;
25 import org.apache.turbine.test.BaseTestCase;
26 import org.apache.turbine.util.TurbineConfig;
27 import org.apache.turbine.util.TurbineXmlConfig;
28
29
30
31
32
33
34
35
36 public class ConfigurationTest extends BaseTestCase
37 {
38 public static final String SERVICE_PREFIX = "services.";
39
40
41
42
43
44 public static final String CLASSNAME_SUFFIX = ".classname";
45
46 private static TurbineConfig tc = null;
47 private static TurbineXmlConfig txc = null;
48
49 public ConfigurationTest(String name) throws Exception
50 {
51 super(name);
52 }
53
54 public void testCreateTurbineWithConfigurationXML() throws Exception
55 {
56 txc = new TurbineXmlConfig(".", "/conf/test/TurbineConfiguration.xml");
57
58 try
59 {
60 txc.initialize();
61
62 Configuration configuration = Turbine.getConfiguration();
63 assertNotNull("No Configuration Object found!", configuration);
64 assertFalse("Make sure we have values", configuration.isEmpty());
65
66
67 String key = "module.cache";
68 assertEquals("Read a config value " + key + ", received:" + configuration.getString(key), "true", configuration.getString(key));
69
70
71 key = "scheduledjob.cache.size";
72 assertEquals("Read a config value " + key + ", received:" + configuration.getString(key), "10", configuration.getString(key));
73 }
74 catch (Exception e)
75 {
76 throw e;
77 }
78 finally
79 {
80 txc.dispose();
81 }
82 }
83
84 public void testCreateTurbineWithConfiguration() throws Exception
85 {
86 tc = new TurbineConfig(".", "/conf/test/TemplateService.properties");
87
88 try
89 {
90 tc.initialize();
91
92 Configuration configuration = Turbine.getConfiguration();
93 assertNotNull("No Configuration Object found!", configuration);
94 assertFalse("Make sure we have values", configuration.isEmpty());
95
96 String key = "scheduledjob.cache.size";
97 assertEquals("Read a config value " + key + ", received:" + configuration.getString(key), "10", configuration.getString(key));
98 }
99 catch (Exception e)
100 {
101 throw e;
102 }
103 finally
104 {
105 tc.dispose();
106 }
107 }
108
109 }