1 package org.apache.turbine; 2 3 56 57 import java.util.HashMap ; 58 import java.util.Map ; 59 60 import junit.framework.Test; 61 import junit.framework.TestCase; 62 import junit.framework.TestSuite; 63 64 71 public class TurbineTest 72 extends TestCase 73 implements TurbineConstants 74 { 75 78 public TurbineTest(String testName) 79 { 80 super(testName); 81 } 82 83 86 public static Test suite() 87 { 88 return new TestSuite(TurbineTest.class); 89 } 90 91 94 public void setUp() 95 { 96 } 98 99 102 public void tearDown() 103 { 104 } 106 107 110 public void testServletConfig() 111 { 112 try 113 { 114 Map initParams = new HashMap (1); 115 TurbineConfig config = new TurbineConfig(".", initParams); 116 117 config.setAttribute("foo", "bar"); 119 assertEquals("bar", (String ) config.getAttribute("foo")); 120 121 String testRoot = "/test"; 123 String expectedLoggingRoot = "/initParams/logs"; 124 initParams.put(LOGGING_ROOT, expectedLoggingRoot); 125 String loggingRoot = Turbine.findInitParameter(config, config, 126 LOGGING_ROOT, 127 testRoot); 128 assertNotNull("Turbine.findInitParameter() returned null when " + 129 "supplied with a non-null default", loggingRoot); 130 assertEquals(expectedLoggingRoot, loggingRoot); 131 initParams.remove(LOGGING_ROOT); 132 String loggingRootKey = CONFIG_NAMESPACE + '.' + LOGGING_ROOT; 137 initParams.put(loggingRootKey, expectedLoggingRoot); 138 loggingRoot = Turbine.findInitParameter(config, config, 139 LOGGING_ROOT, testRoot); 140 assertEquals(expectedLoggingRoot, loggingRoot); 141 initParams.remove(loggingRootKey); 142 loggingRoot = Turbine.findInitParameter(config, config, 143 LOGGING_ROOT, testRoot); 144 assertEquals("Turbine.findInitParameter() returned an incorrect " + 145 "default value", "/test", loggingRoot); 146 } 147 catch (Exception e) 148 { 149 e.printStackTrace(); 150 fail(e.getMessage()); 151 } 152 } 153 } 154 | Popular Tags |