KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > turbine > TurbineConfigTest


1 package org.apache.turbine;
2
3 /*
4  * Copyright 2001-2004 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License")
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 import java.io.File JavaDoc;
20
21 import javax.servlet.ServletConfig JavaDoc;
22 import javax.servlet.ServletContext JavaDoc;
23
24 import junit.framework.Test;
25 import junit.framework.TestSuite;
26
27 import org.apache.turbine.Turbine;
28 import org.apache.turbine.test.BaseTestCase;
29 import org.apache.turbine.util.TurbineConfig;
30 import org.apache.turbine.util.TurbineXmlConfig;
31
32 /**
33  * This testcase verifies that TurbineConfig can be used to startup Turbine in a non
34  * servlet environment properly.
35  *
36  * @author <a HREF="mailto:epugh@upstate.com">Eric Pugh</a>
37  * @version $Id: TurbineConfigTest.java,v 1.3.2.2 2004/05/20 03:30:06 seade Exp $
38  */

39 public class TurbineConfigTest
40     extends BaseTestCase
41 {
42     private static TurbineConfig tc = null;
43     private static TurbineXmlConfig txc = null;
44
45     public TurbineConfigTest(String JavaDoc name)
46             throws Exception JavaDoc
47     {
48         super(name);
49     }
50
51     public static Test suite()
52     {
53         return new TestSuite(TurbineConfigTest.class);
54     }
55
56     public void testTurbineConfigWithPropertiesFile() throws Exception JavaDoc
57     {
58         String JavaDoc value = new File JavaDoc("/conf/test/TemplateService.properties").getPath();
59         tc = new TurbineConfig(".", value);
60
61         ServletConfig JavaDoc config = (ServletConfig JavaDoc) tc;
62         ServletContext JavaDoc context = config.getServletContext();
63
64         String JavaDoc confFile= Turbine.findInitParameter(context, config,
65                 TurbineConfig.PROPERTIES_PATH_KEY,
66                 null);
67         assertEquals(value, confFile);
68     }
69     
70     public void testTurbineXmlConfigWithConfigurationFile() throws Exception JavaDoc
71     {
72         String JavaDoc value = new File JavaDoc("/conf/test/TurbineConfiguration.xml").getPath();
73             txc = new TurbineXmlConfig(".", value);
74             
75         ServletConfig JavaDoc config = (ServletConfig JavaDoc) txc;
76         ServletContext JavaDoc context = config.getServletContext();
77             
78             String JavaDoc confFile= Turbine.findInitParameter(context, config,
79                     TurbineConfig.CONFIGURATION_PATH_KEY,
80                     null);
81         assertEquals(value, confFile);
82         }
83 }
84
Popular Tags