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 import static org.junit.Assert.assertEquals;
24
25 import java.io.File;
26
27 import javax.servlet.ServletConfig;
28 import javax.servlet.ServletContext;
29
30 import org.apache.turbine.test.BaseTestCase;
31 import org.apache.turbine.util.TurbineConfig;
32 import org.apache.turbine.util.TurbineXmlConfig;
33 import org.junit.Test;
34
35
36
37
38
39
40
41
42 public class TurbineConfigTest
43 extends BaseTestCase
44 {
45 private static TurbineConfig tc = null;
46 private static TurbineXmlConfig txc = null;
47
48 @Test
49 public void testTurbineConfigWithPropertiesFile() throws Exception
50 {
51 String value = new File("/conf/test/TemplateService.properties").getPath();
52 tc = new TurbineConfig(".", value);
53 Turbine turbine = new Turbine();
54
55 ServletConfig config = tc;
56 ServletContext context = config.getServletContext();
57
58 String confFile= turbine.findInitParameter(context, config,
59 TurbineConfig.PROPERTIES_PATH_KEY,
60 null);
61 assertEquals(value, confFile);
62 }
63 @Test
64 public void testTurbineXmlConfigWithConfigurationFile() throws Exception
65 {
66 String value = new File("/conf/test/TurbineConfiguration.xml").getPath();
67 txc = new TurbineXmlConfig(".", value);
68 Turbine turbine = new Turbine();
69
70 ServletConfig config = txc;
71 ServletContext context = config.getServletContext();
72
73 String confFile= turbine.findInitParameter(context, config,
74 TurbineConfig.CONFIGURATION_PATH_KEY,
75 null);
76 assertEquals(value, confFile);
77 }
78 }