1 package org.apache.turbine; 2 3 18 19 import java.io.File ; 20 21 import javax.servlet.ServletConfig ; 22 import javax.servlet.ServletContext ; 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 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 name) 46 throws Exception 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 57 { 58 String value = new File ("/conf/test/TemplateService.properties").getPath(); 59 tc = new TurbineConfig(".", value); 60 61 ServletConfig config = (ServletConfig ) tc; 62 ServletContext context = config.getServletContext(); 63 64 String confFile= Turbine.findInitParameter(context, config, 65 TurbineConfig.PROPERTIES_PATH_KEY, 66 null); 67 assertEquals(value, confFile); 68 } 69 70 public void testTurbineXmlConfigWithConfigurationFile() throws Exception 71 { 72 String value = new File ("/conf/test/TurbineConfiguration.xml").getPath(); 73 txc = new TurbineXmlConfig(".", value); 74 75 ServletConfig config = (ServletConfig ) txc; 76 ServletContext context = config.getServletContext(); 77 78 String confFile= Turbine.findInitParameter(context, config, 79 TurbineConfig.CONFIGURATION_PATH_KEY, 80 null); 81 assertEquals(value, confFile); 82 } 83 } 84 | Popular Tags |