KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > turbine > services > template > DefaultsTest


1 package org.apache.turbine.services.template;
2
3 /*
4  * Copyright 2001-2004 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License")
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
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,v 1.4.2.3 2004/08/14 20:57:58 henning Exp $
30  */

31 public class DefaultsTest
32     extends BaseTurbineTest
33 {
34     private TemplateService ts = null;
35         
36     public DefaultsTest(String JavaDoc name)
37             throws Exception JavaDoc
38     {
39         super(name, "/conf/test/TemplateService.properties");
40
41         ts = (TemplateService) TurbineServices.getInstance().getService(TemplateService.SERVICE_NAME);
42     }
43
44     public static Test suite()
45     {
46         return new TestSuite(DefaultsTest.class);
47     }
48
49     public void testDefaults()
50     {
51         // Test if the caching property was loaded correctly.
52
assertEquals("isCaching failed!", ts.isCaching(), false);
53
54         // Test if the default values for Template and Extension were loaded correctly
55
assertEquals("Default Extension failed", ts.getDefaultExtension(), "");
56         assertEquals("Default Template failed", ts.getDefaultTemplate(), TemplateService.DEFAULT_TEMPLATE_VALUE);
57     }
58
59     public void testTemplateDefaults()
60     {
61         // Test if the Default-Values for the Screen, Layout and Navigation classes and the Layout Template are correct.
62
assertEquals("Default Page failed", TemplateService.DEFAULT_TEMPLATE_VALUE, ts.getDefaultPage());
63         assertEquals("Default Screen failed", TemplateService.DEFAULT_TEMPLATE_VALUE, ts.getDefaultScreen());
64         assertEquals("Default Layout failed", TemplateService.DEFAULT_TEMPLATE_VALUE, ts.getDefaultLayout());
65         assertEquals("Default Navigation failed", TemplateService.DEFAULT_TEMPLATE_VALUE, ts.getDefaultNavigation());
66         assertEquals("Default LayoutTemplate failed", TemplateService.DEFAULT_TEMPLATE_VALUE, ts.getDefaultLayoutTemplate());
67     }
68
69     public void testVelocityDefaults()
70     {
71         // Test if all the Velocity based Defaults for Page, Screen, Layout, Navigation and Layout Template
72
assertEquals("Default Page failed", "VelocityPage", ts.getDefaultPageName("foo.vm"));
73         assertEquals("Default Screen failed", "VelocityScreen", ts.getDefaultScreenName("foo.vm"));
74         assertEquals("Default Layout failed", "VelocityOnlyLayout", ts.getDefaultLayoutName("foo.vm"));
75         assertEquals("Default Navigation failed", "VelocityNavigation", ts.getDefaultNavigationName("foo.vm"));
76         assertEquals("Default LayoutTemplate failed", "Default.vm", ts.getDefaultLayoutTemplateName("foo.vm"));
77     }
78 }
79
80
Popular Tags