01: package org.apache.turbine.services.template;
02:
03: /*
04: * Copyright 2001-2005 The Apache Software Foundation.
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License")
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
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.services.template.TemplateEngineService;
24: import org.apache.turbine.services.template.TemplateService;
25: import org.apache.turbine.services.velocity.VelocityService;
26: import org.apache.turbine.test.BaseTestCase;
27: import org.apache.turbine.util.TurbineConfig;
28:
29: /**
30: * Tests startup of the Template Service and registration of the
31: * Velocity Service.
32: *
33: * @author <a href="hps@intermeta.de">Henning P. Schmiedehausen</a>
34: * @version $Id: InitTest.java 264148 2005-08-29 14:21:04Z henning $
35: */
36:
37: public class InitTest extends BaseTestCase {
38: private static TurbineConfig tc = null;
39: private static TemplateService ts = null;
40:
41: public InitTest(String name) throws Exception {
42: super (name);
43: tc = new TurbineConfig(".",
44: "/conf/test/TemplateService.properties");
45: tc.initialize();
46:
47: ts = (TemplateService) TurbineServices.getInstance()
48: .getService(TemplateService.SERVICE_NAME);
49: }
50:
51: public static Test suite() {
52: return new TestSuite(InitTest.class);
53: }
54:
55: public void testService() throws Exception {
56:
57: // Can we start the service?
58: assertNotNull("Could not load Service!", ts);
59:
60: // Did we register the Velocity Service correctly for "vm" templates?
61: VelocityService vs = (VelocityService) TurbineServices
62: .getInstance().getService(VelocityService.SERVICE_NAME);
63:
64: TemplateEngineService tes = ts
65: .getTemplateEngineService("foo.vm");
66:
67: assertEquals(
68: "Template Service did not return Velocity Service for .vm Templates",
69: vs, tes);
70: }
71: }
|