001 package org.apache.turbine; 002 003 004 /* 005 * Licensed to the Apache Software Foundation (ASF) under one 006 * or more contributor license agreements. See the NOTICE file 007 * distributed with this work for additional information 008 * regarding copyright ownership. The ASF licenses this file 009 * to you under the Apache License, Version 2.0 (the 010 * "License"); you may not use this file except in compliance 011 * with the License. You may obtain a copy of the License at 012 * 013 * http://www.apache.org/licenses/LICENSE-2.0 014 * 015 * Unless required by applicable law or agreed to in writing, 016 * software distributed under the License is distributed on an 017 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 018 * KIND, either express or implied. See the License for the 019 * specific language governing permissions and limitations 020 * under the License. 021 */ 022 023 024 import java.io.File; 025 026 import javax.servlet.ServletConfig; 027 import javax.servlet.ServletContext; 028 029 import org.apache.turbine.test.BaseTestCase; 030 import org.apache.turbine.util.TurbineConfig; 031 import org.apache.turbine.util.TurbineXmlConfig; 032 033 /** 034 * This testcase verifies that TurbineConfig can be used to startup Turbine in a non 035 * servlet environment properly. 036 * 037 * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a> 038 * @version $Id: TurbineConfigTest.java 615328 2008-01-25 20:25:05Z tv $ 039 */ 040 public class TurbineConfigTest 041 extends BaseTestCase 042 { 043 private static TurbineConfig tc = null; 044 private static TurbineXmlConfig txc = null; 045 046 public TurbineConfigTest(String name) 047 throws Exception 048 { 049 super(name); 050 } 051 052 public void testTurbineConfigWithPropertiesFile() throws Exception 053 { 054 String value = new File("/conf/test/TemplateService.properties").getPath(); 055 tc = new TurbineConfig(".", value); 056 057 ServletConfig config = (ServletConfig) tc; 058 ServletContext context = config.getServletContext(); 059 060 String confFile= Turbine.findInitParameter(context, config, 061 TurbineConfig.PROPERTIES_PATH_KEY, 062 null); 063 assertEquals(value, confFile); 064 } 065 066 public void testTurbineXmlConfigWithConfigurationFile() throws Exception 067 { 068 String value = new File("/conf/test/TurbineConfiguration.xml").getPath(); 069 txc = new TurbineXmlConfig(".", value); 070 071 ServletConfig config = (ServletConfig) txc; 072 ServletContext context = config.getServletContext(); 073 074 String confFile= Turbine.findInitParameter(context, config, 075 TurbineConfig.CONFIGURATION_PATH_KEY, 076 null); 077 assertEquals(value, confFile); 078 } 079 }