1 package org.apache.turbine.services.template;
2
3
4 /*
5 * Licensed to the Apache Software Foundation (ASF) under one
6 * or more contributor license agreements. See the NOTICE file
7 * distributed with this work for additional information
8 * regarding copyright ownership. The ASF licenses this file
9 * to you under the Apache License, Version 2.0 (the
10 * "License"); you may not use this file except in compliance
11 * with the License. You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing,
16 * software distributed under the License is distributed on an
17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 * KIND, either express or implied. See the License for the
19 * specific language governing permissions and limitations
20 * under the License.
21 */
22
23
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertNotNull;
26
27 import org.apache.turbine.services.TurbineServices;
28 import org.apache.turbine.services.velocity.VelocityService;
29 import org.apache.turbine.test.BaseTestCase;
30 import org.apache.turbine.util.TurbineConfig;
31 import org.junit.AfterClass;
32 import org.junit.BeforeClass;
33 import org.junit.Test;
34
35 /**
36 * Tests startup of the Template Service and registration of the
37 * Velocity Service.
38 *
39 * @author <a href="hps@intermeta.de">Henning P. Schmiedehausen</a>
40 * @version $Id: InitTest.java 1606111 2014-06-27 14:46:47Z gk $
41 */
42
43 public class InitTest
44 extends BaseTestCase
45 {
46 private static TurbineConfig tc = null;
47 private static TemplateService ts = null;
48
49
50 @BeforeClass
51 public static void setUp() throws Exception
52 {
53 tc = new TurbineConfig(".", "/conf/test/TemplateService.properties");
54 tc.initialize();
55
56 ts = (TemplateService) TurbineServices.getInstance().getService(TemplateService.SERVICE_NAME);
57 }
58
59 @AfterClass
60 public static void tearDown() throws Exception
61 {
62 if (tc != null)
63 {
64 tc.dispose();
65 }
66 }
67
68 @Test public void testService()
69 throws Exception
70 {
71
72 // Can we start the service?
73 assertNotNull("Could not load Service!", ts);
74
75 // Did we register the Velocity Service correctly for "vm" templates?
76 VelocityService vs = (VelocityService) TurbineServices
77 .getInstance().getService(VelocityService.SERVICE_NAME);
78
79 TemplateEngineService tes = ts.getTemplateEngineService("foo.vm");
80
81 assertEquals("Template Service did not return Velocity Service for .vm Templates", vs, tes);
82 }
83 }