01: package org.apache.turbine.services.template;
02:
03: /*
04: * Licensed to the Apache Software Foundation (ASF) under one
05: * or more contributor license agreements. See the NOTICE file
06: * distributed with this work for additional information
07: * regarding copyright ownership. The ASF licenses this file
08: * to you under the Apache License, Version 2.0 (the
09: * "License"); you may not use this file except in compliance
10: * with the License. You may obtain a copy of the License at
11: *
12: * http://www.apache.org/licenses/LICENSE-2.0
13: *
14: * Unless required by applicable law or agreed to in writing,
15: * software distributed under the License is distributed on an
16: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17: * KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations
19: * under the License.
20: */
21:
22: import junit.framework.Test;
23: import junit.framework.TestSuite;
24:
25: import org.apache.turbine.services.TurbineServices;
26: import org.apache.turbine.test.BaseTurbineTest;
27:
28: /**
29: * Tests all the various defaults for the Template Service.
30: *
31: * @author <a href="hps@intermeta.de">Henning P. Schmiedehausen</a>
32: * @version $Id: DefaultsTest.java 534527 2007-05-02 16:10:59Z tv $
33: */
34: public class DefaultsTest extends BaseTurbineTest {
35: private TemplateService ts = null;
36:
37: public DefaultsTest(String name) throws Exception {
38: super (name, "/conf/test/TemplateService.properties");
39:
40: ts = (TemplateService) TurbineServices.getInstance()
41: .getService(TemplateService.SERVICE_NAME);
42: }
43:
44: public static Test suite() {
45: return new TestSuite(DefaultsTest.class);
46: }
47:
48: public void testDefaults() {
49: // Test if the caching property was loaded correctly.
50: assertEquals("isCaching failed!", ts.isCaching(), false);
51:
52: // Test if the default values for Template and Extension were loaded correctly
53: assertEquals("Default Extension failed", ts
54: .getDefaultExtension(), "");
55: assertEquals("Default Template failed",
56: ts.getDefaultTemplate(),
57: TemplateService.DEFAULT_TEMPLATE_VALUE);
58: }
59:
60: public void testTemplateDefaults() {
61: // Test if the Default-Values for the Screen, Layout and Navigation classes and the Layout Template are correct.
62: assertEquals("Default Page failed",
63: TemplateService.DEFAULT_TEMPLATE_VALUE, ts
64: .getDefaultPage());
65: assertEquals("Default Screen failed",
66: TemplateService.DEFAULT_TEMPLATE_VALUE, ts
67: .getDefaultScreen());
68: assertEquals("Default Layout failed",
69: TemplateService.DEFAULT_TEMPLATE_VALUE, ts
70: .getDefaultLayout());
71: assertEquals("Default Navigation failed",
72: TemplateService.DEFAULT_TEMPLATE_VALUE, ts
73: .getDefaultNavigation());
74: assertEquals("Default LayoutTemplate failed",
75: TemplateService.DEFAULT_TEMPLATE_VALUE, ts
76: .getDefaultLayoutTemplate());
77: }
78:
79: public void testVelocityDefaults() {
80: // Test if all the Velocity based Defaults for Page, Screen, Layout, Navigation and Layout Template
81: assertEquals("Default Page failed", "VelocityPage", ts
82: .getDefaultPageName("foo.vm"));
83: assertEquals("Default Screen failed", "VelocityScreen", ts
84: .getDefaultScreenName("foo.vm"));
85: assertEquals("Default Layout failed", "VelocityOnlyLayout", ts
86: .getDefaultLayoutName("foo.vm"));
87: assertEquals("Default Navigation failed", "VelocityNavigation",
88: ts.getDefaultNavigationName("foo.vm"));
89: assertEquals("Default LayoutTemplate failed", "Default.vm", ts
90: .getDefaultLayoutTemplateName("foo.vm"));
91: }
92: }
|