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.services.velocity.VelocityService;
026 import org.apache.turbine.test.BaseTestCase;
027 import org.apache.turbine.util.TurbineConfig;
028
029 /**
030 * Tests startup of the Template Service and registration of the
031 * Velocity Service.
032 *
033 * @author <a href="hps@intermeta.de">Henning P. Schmiedehausen</a>
034 * @version $Id: InitTest.java 615328 2008-01-25 20:25:05Z tv $
035 */
036
037 public class InitTest
038 extends BaseTestCase
039 {
040 private static TurbineConfig tc = null;
041 private static TemplateService ts = null;
042
043 public InitTest(String name)
044 throws Exception
045 {
046 super(name);
047 tc = new TurbineConfig(".", "/conf/test/TemplateService.properties");
048 tc.initialize();
049
050 ts = (TemplateService) TurbineServices.getInstance().getService(TemplateService.SERVICE_NAME);
051 }
052
053
054 public void testService()
055 throws Exception
056 {
057
058 // Can we start the service?
059 assertNotNull("Could not load Service!", ts);
060
061 // Did we register the Velocity Service correctly for "vm" templates?
062 VelocityService vs = (VelocityService) TurbineServices
063 .getInstance().getService(VelocityService.SERVICE_NAME);
064
065 TemplateEngineService tes = ts.getTemplateEngineService("foo.vm");
066
067 assertEquals("Template Service did not return Velocity Service for .vm Templates", vs, tes);
068 }
069 }