1   package org.apache.turbine.services.template;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "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
35      extends BaseTurbineTest
36  {
37  	private TemplateService ts = null;
38  
39      public DefaultsTest(String name)
40              throws Exception
41      {
42          super(name, "/conf/test/TemplateService.properties");
43  
44          ts = (TemplateService) TurbineServices.getInstance().getService(TemplateService.SERVICE_NAME);
45      }
46  
47      public static Test suite()
48      {
49          return new TestSuite(DefaultsTest.class);
50      }
51  
52      public void testDefaults()
53      {
54          // Test if the caching property was loaded correctly.
55          assertEquals("isCaching failed!",             ts.isCaching(), false);
56  
57          // Test if the default values for Template and Extension were loaded correctly
58          assertEquals("Default Extension failed",      ts.getDefaultExtension(), "");
59          assertEquals("Default Template failed",       ts.getDefaultTemplate(), TemplateService.DEFAULT_TEMPLATE_VALUE);
60      }
61  
62      public void testTemplateDefaults()
63      {
64          // Test if the Default-Values for the Screen, Layout and Navigation classes and the Layout Template are correct.
65          assertEquals("Default Page failed",           TemplateService.DEFAULT_TEMPLATE_VALUE, ts.getDefaultPage());
66          assertEquals("Default Screen failed",         TemplateService.DEFAULT_TEMPLATE_VALUE, ts.getDefaultScreen());
67          assertEquals("Default Layout failed",         TemplateService.DEFAULT_TEMPLATE_VALUE, ts.getDefaultLayout());
68          assertEquals("Default Navigation failed",     TemplateService.DEFAULT_TEMPLATE_VALUE, ts.getDefaultNavigation());
69          assertEquals("Default LayoutTemplate failed", TemplateService.DEFAULT_TEMPLATE_VALUE, ts.getDefaultLayoutTemplate());
70      }
71  
72      public void testVelocityDefaults()
73      {
74          // Test if all the Velocity based Defaults for Page, Screen, Layout, Navigation and Layout Template
75          assertEquals("Default Page failed",           "VelocityPage",       ts.getDefaultPageName("foo.vm"));
76          assertEquals("Default Screen failed",         "VelocityScreen",     ts.getDefaultScreenName("foo.vm"));
77          assertEquals("Default Layout failed",         "VelocityOnlyLayout", ts.getDefaultLayoutName("foo.vm"));
78          assertEquals("Default Navigation failed",     "VelocityNavigation", ts.getDefaultNavigationName("foo.vm"));
79          assertEquals("Default LayoutTemplate failed", "Default.vm",         ts.getDefaultLayoutTemplateName("foo.vm"));
80      }
81  }
82