1 package org.apache.turbine.services.template;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertFalse;
26
27
28 import org.apache.turbine.services.TurbineServices;
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
37
38
39
40
41 public class DefaultsTest
42 extends BaseTestCase
43 {
44 private static TurbineConfig tc = null;
45 private static TemplateService ts = null;
46
47
48 @BeforeClass
49 public static void setUp() throws Exception {
50 tc = new TurbineConfig(".", "/conf/test/TemplateService.properties");
51 tc.initialize();
52
53 ts = (TemplateService) TurbineServices.getInstance().getService(TemplateService.SERVICE_NAME);
54 }
55
56 @AfterClass
57 public static void destroy() throws Exception {
58 ts.shutdown();
59 tc.dispose();
60 }
61
62 @Test
63 public void testDefaults()
64 {
65
66 assertFalse("isCaching failed!", ts.isCaching());
67
68
69 assertEquals("Default Extension failed", ts.getDefaultExtension(), "");
70 assertEquals("Default Template failed", ts.getDefaultTemplate(), TemplateService.DEFAULT_TEMPLATE_VALUE);
71 }
72
73 @Test
74 public void testTemplateDefaults()
75 {
76
77 assertEquals("Default Page failed", TemplateService.DEFAULT_TEMPLATE_VALUE, ts.getDefaultPage());
78 assertEquals("Default Screen failed", TemplateService.DEFAULT_TEMPLATE_VALUE, ts.getDefaultScreen());
79 assertEquals("Default Layout failed", TemplateService.DEFAULT_TEMPLATE_VALUE, ts.getDefaultLayout());
80 assertEquals("Default Navigation failed", TemplateService.DEFAULT_TEMPLATE_VALUE, ts.getDefaultNavigation());
81 assertEquals("Default LayoutTemplate failed", TemplateService.DEFAULT_TEMPLATE_VALUE, ts.getDefaultLayoutTemplate());
82 }
83
84 @Test
85 public void testVelocityDefaults()
86 {
87
88 assertEquals("Default Page failed", "VelocityPage", ts.getDefaultPageName("foo.vm"));
89 assertEquals("Default Screen failed", "VelocityScreen", ts.getDefaultScreenName("foo.vm"));
90 assertEquals("Default Layout failed", "VelocityOnlyLayout", ts.getDefaultLayoutName("foo.vm"));
91 assertEquals("Default Navigation failed", "VelocityNavigation", ts.getDefaultNavigationName("foo.vm"));
92 assertEquals("Default LayoutTemplate failed", "Default.vm", ts.getDefaultLayoutTemplateName("foo.vm"));
93 }
94 }
95