01: package org.apache.turbine.services.template;
02:
03: /*
04: * Copyright 2001-2005 The Apache Software Foundation.
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License")
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
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 junit.framework.Test;
20: import junit.framework.TestSuite;
21:
22: import org.apache.turbine.services.TurbineServices;
23: import org.apache.turbine.test.BaseTurbineTest;
24:
25: /**
26: * Tests all the various defaults for the Template Service.
27: *
28: * @author <a href="hps@intermeta.de">Henning P. Schmiedehausen</a>
29: * @version $Id: DefaultsTest.java 264148 2005-08-29 14:21:04Z henning $
30: */
31: public class DefaultsTest extends BaseTurbineTest {
32: private TemplateService ts = null;
33:
34: public DefaultsTest(String name) throws Exception {
35: super (name, "/conf/test/TemplateService.properties");
36:
37: ts = (TemplateService) TurbineServices.getInstance()
38: .getService(TemplateService.SERVICE_NAME);
39: }
40:
41: public static Test suite() {
42: return new TestSuite(DefaultsTest.class);
43: }
44:
45: public void testDefaults() {
46: // Test if the caching property was loaded correctly.
47: assertEquals("isCaching failed!", ts.isCaching(), false);
48:
49: // Test if the default values for Template and Extension were loaded correctly
50: assertEquals("Default Extension failed", ts
51: .getDefaultExtension(), "");
52: assertEquals("Default Template failed",
53: ts.getDefaultTemplate(),
54: TemplateService.DEFAULT_TEMPLATE_VALUE);
55: }
56:
57: public void testTemplateDefaults() {
58: // Test if the Default-Values for the Screen, Layout and Navigation classes and the Layout Template are correct.
59: assertEquals("Default Page failed",
60: TemplateService.DEFAULT_TEMPLATE_VALUE, ts
61: .getDefaultPage());
62: assertEquals("Default Screen failed",
63: TemplateService.DEFAULT_TEMPLATE_VALUE, ts
64: .getDefaultScreen());
65: assertEquals("Default Layout failed",
66: TemplateService.DEFAULT_TEMPLATE_VALUE, ts
67: .getDefaultLayout());
68: assertEquals("Default Navigation failed",
69: TemplateService.DEFAULT_TEMPLATE_VALUE, ts
70: .getDefaultNavigation());
71: assertEquals("Default LayoutTemplate failed",
72: TemplateService.DEFAULT_TEMPLATE_VALUE, ts
73: .getDefaultLayoutTemplate());
74: }
75:
76: public void testVelocityDefaults() {
77: // Test if all the Velocity based Defaults for Page, Screen, Layout, Navigation and Layout Template
78: assertEquals("Default Page failed", "VelocityPage", ts
79: .getDefaultPageName("foo.vm"));
80: assertEquals("Default Screen failed", "VelocityScreen", ts
81: .getDefaultScreenName("foo.vm"));
82: assertEquals("Default Layout failed", "VelocityOnlyLayout", ts
83: .getDefaultLayoutName("foo.vm"));
84: assertEquals("Default Navigation failed", "VelocityNavigation",
85: ts.getDefaultNavigationName("foo.vm"));
86: assertEquals("Default LayoutTemplate failed", "Default.vm", ts
87: .getDefaultLayoutTemplateName("foo.vm"));
88: }
89: }
|