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 import java.io.File;
23
24 import javax.servlet.ServletConfig;
25 import javax.servlet.ServletContext;
26
27 import junit.framework.Test;
28 import junit.framework.TestSuite;
29
30 import org.apache.turbine.Turbine;
31 import org.apache.turbine.test.BaseTestCase;
32 import org.apache.turbine.util.TurbineConfig;
33 import org.apache.turbine.util.TurbineXmlConfig;
34
35 /***
36 * This testcase verifies that TurbineConfig can be used to startup Turbine in a non
37 * servlet environment properly.
38 *
39 * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
40 * @version $Id: TurbineConfigTest.java 534527 2007-05-02 16:10:59Z tv $
41 */
42 public class TurbineConfigTest
43 extends BaseTestCase
44 {
45 private static TurbineConfig tc = null;
46 private static TurbineXmlConfig txc = null;
47
48 public TurbineConfigTest(String name)
49 throws Exception
50 {
51 super(name);
52 }
53
54 public static Test suite()
55 {
56 return new TestSuite(TurbineConfigTest.class);
57 }
58
59 public void testTurbineConfigWithPropertiesFile() throws Exception
60 {
61 String value = new File("/conf/test/TemplateService.properties").getPath();
62 tc = new TurbineConfig(".", value);
63
64 ServletConfig config = (ServletConfig) tc;
65 ServletContext context = config.getServletContext();
66
67 String confFile= Turbine.findInitParameter(context, config,
68 TurbineConfig.PROPERTIES_PATH_KEY,
69 null);
70 assertEquals(value, confFile);
71 }
72
73 public void testTurbineXmlConfigWithConfigurationFile() throws Exception
74 {
75 String value = new File("/conf/test/TurbineConfiguration.xml").getPath();
76 txc = new TurbineXmlConfig(".", value);
77
78 ServletConfig config = (ServletConfig) txc;
79 ServletContext context = config.getServletContext();
80
81 String confFile= Turbine.findInitParameter(context, config,
82 TurbineConfig.CONFIGURATION_PATH_KEY,
83 null);
84 assertEquals(value, confFile);
85 }
86 }