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.services.template.TemplateEngineService;
27: import org.apache.turbine.services.template.TemplateService;
28: import org.apache.turbine.services.velocity.VelocityService;
29: import org.apache.turbine.test.BaseTestCase;
30: import org.apache.turbine.util.TurbineConfig;
31:
32: /**
33: * Tests startup of the Template Service and registration of the
34: * Velocity Service.
35: *
36: * @author <a href="hps@intermeta.de">Henning P. Schmiedehausen</a>
37: * @version $Id: InitTest.java 534527 2007-05-02 16:10:59Z tv $
38: */
39:
40: public class InitTest extends BaseTestCase {
41: private static TurbineConfig tc = null;
42: private static TemplateService ts = null;
43:
44: public InitTest(String name) throws Exception {
45: super (name);
46: tc = new TurbineConfig(".",
47: "/conf/test/TemplateService.properties");
48: tc.initialize();
49:
50: ts = (TemplateService) TurbineServices.getInstance()
51: .getService(TemplateService.SERVICE_NAME);
52: }
53:
54: public static Test suite() {
55: return new TestSuite(InitTest.class);
56: }
57:
58: public void testService() throws Exception {
59:
60: // Can we start the service?
61: assertNotNull("Could not load Service!", ts);
62:
63: // Did we register the Velocity Service correctly for "vm" templates?
64: VelocityService vs = (VelocityService) TurbineServices
65: .getInstance().getService(VelocityService.SERVICE_NAME);
66:
67: TemplateEngineService tes = ts
68: .getTemplateEngineService("foo.vm");
69:
70: assertEquals(
71: "Template Service did not return Velocity Service for .vm Templates",
72: vs, tes);
73: }
74: }
|