    001    package org.apache.turbine.services.template;
    002
    003
    004    /*
    005     * Licensed to the Apache Software Foundation (ASF) under one
    006     * or more contributor license agreements.  See the NOTICE file
    007     * distributed with this work for additional information
    008     * regarding copyright ownership.  The ASF licenses this file
    009     * to you under the Apache License, Version 2.0 (the
    010     * "License"); you may not use this file except in compliance
    011     * with the License.  You may obtain a copy of the License at
    012     *
    013     *   http://www.apache.org/licenses/LICENSE-2.0
    014     *
    015     * Unless required by applicable law or agreed to in writing,
    016     * software distributed under the License is distributed on an
    017     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    018     * KIND, either express or implied.  See the License for the
    019     * specific language governing permissions and limitations
    020     * under the License.
    021     */
    022
    023
    024    import org.apache.turbine.services.TurbineServices;
    025    import org.apache.turbine.test.BaseTestCase;
    026    import org.apache.turbine.util.TurbineConfig;
    027
    028    /**
    029     * Tests all the various defaults for the Template Service.
    030     *
    031     * @author <a href="hps@intermeta.de">Henning P. Schmiedehausen</a>
    032     * @version $Id: DefaultsTest.java 615328 2008-01-25 20:25:05Z tv $
    033     */
    034    public class DefaultsTest
    035        extends BaseTestCase
    036    {
    037        private static TurbineConfig tc = null;
    038        private static TemplateService ts = null;
    039
    040        public DefaultsTest(String name)
    041                throws Exception
    042        {
    043            super(name);
    044            tc = new TurbineConfig(".", "/conf/test/TemplateService.properties");
    045            tc.initialize();
    046
    047            ts = (TemplateService) TurbineServices.getInstance().getService(TemplateService.SERVICE_NAME);
    048        }
    049
    050        public void testDefaults()
    051        {
    052            // Test if the caching property was loaded correctly.
    053            assertEquals("isCaching failed!",             ts.isCaching(), false);
    054
    055            // Test if the default values for Template and Extension were loaded correctly
    056            assertEquals("Default Extension failed",      ts.getDefaultExtension(), "");
    057            assertEquals("Default Template failed",       ts.getDefaultTemplate(), TemplateService.DEFAULT_TEMPLATE_VALUE);
    058        }
    059
    060        public void testTemplateDefaults()
    061        {
    062            // Test if the Default-Values for the Screen, Layout and Navigation classes and the Layout Template are correct.
    063            assertEquals("Default Page failed",           TemplateService.DEFAULT_TEMPLATE_VALUE, ts.getDefaultPage());
    064            assertEquals("Default Screen failed",         TemplateService.DEFAULT_TEMPLATE_VALUE, ts.getDefaultScreen());
    065            assertEquals("Default Layout failed",         TemplateService.DEFAULT_TEMPLATE_VALUE, ts.getDefaultLayout());
    066            assertEquals("Default Navigation failed",     TemplateService.DEFAULT_TEMPLATE_VALUE, ts.getDefaultNavigation());
    067            assertEquals("Default LayoutTemplate failed", TemplateService.DEFAULT_TEMPLATE_VALUE, ts.getDefaultLayoutTemplate());
    068        }
    069
    070        public void testVelocityDefaults()
    071        {
    072            // Test if all the Velocity based Defaults for Page, Screen, Layout, Navigation and Layout Template
    073            assertEquals("Default Page failed",           "VelocityPage",       ts.getDefaultPageName("foo.vm"));
    074            assertEquals("Default Screen failed",         "VelocityScreen",     ts.getDefaultScreenName("foo.vm"));
    075            assertEquals("Default Layout failed",         "VelocityOnlyLayout", ts.getDefaultLayoutName("foo.vm"));
    076            assertEquals("Default Navigation failed",     "VelocityNavigation", ts.getDefaultNavigationName("foo.vm"));
    077            assertEquals("Default LayoutTemplate failed", "Default.vm",         ts.getDefaultLayoutTemplateName("foo.vm"));
    078        }
    079    }
    080