1 package org.apache.turbine.services.template; 2 3 18 19 import junit.framework.Test; 20 import junit.framework.TestSuite; 21 22 import org.apache.turbine.services.TurbineServices; 23 import org.apache.turbine.test.BaseTurbineTest; 24 25 32 33 public class ClassTest 34 extends BaseTurbineTest 35 { 36 private TemplateService ts = null; 37 38 public ClassTest(String name) 39 throws Exception 40 { 41 super(name, "/conf/test/TemplateService.properties"); 42 ts = (TemplateService) TurbineServices.getInstance().getService(TemplateService.SERVICE_NAME); 43 } 44 45 public static Test suite() 46 { 47 return new TestSuite(ClassTest.class); 48 } 49 50 public void testTemplateDefaults() 51 { 52 assertEquals("Default Page failed", TemplateService.DEFAULT_TEMPLATE_VALUE, ts.getDefaultPage()); 54 assertEquals("Default Screen failed", TemplateService.DEFAULT_TEMPLATE_VALUE, ts.getDefaultScreen()); 55 assertEquals("Default Layout failed", TemplateService.DEFAULT_TEMPLATE_VALUE, ts.getDefaultLayout()); 56 assertEquals("Default Navigation failed", TemplateService.DEFAULT_TEMPLATE_VALUE, ts.getDefaultNavigation()); 57 } 58 59 public void testVelocityDefaults() 60 { 61 assertEquals("Default Page failed", "VelocityPage", ts.getDefaultPageName("foo.vm")); 63 assertEquals("Default Screen failed", "VelocityScreen", ts.getDefaultScreenName("foo.vm")); 64 assertEquals("Default Layout failed", "VelocityOnlyLayout", ts.getDefaultLayoutName("foo.vm")); 65 assertEquals("Default Navigation failed", "VelocityNavigation", ts.getDefaultNavigationName("foo.vm")); 66 } 67 68 70 public void testNonExistingTemplate() 71 throws Exception 72 { 73 String templateName = "DoesNotExistPage.vm"; 78 assertEquals("Screen translation failed", "VelocityScreen", ts.getScreenName(templateName)); 79 assertEquals("Layout translation failed", "VelocityOnlyLayout", ts.getLayoutName(templateName)); 80 assertEquals("Navigation translation failed", "VelocityNavigation", ts.getNavigationName(templateName)); 81 } 82 83 public void testNonExistingSublevelTemplate() 84 throws Exception 85 { 86 String templateName = "this,template,DoesNotExistPage.vm"; 90 assertEquals("Screen translation failed", "VelocityScreen", ts.getScreenName(templateName)); 91 assertEquals("Layout translation failed", "VelocityOnlyLayout", ts.getLayoutName(templateName)); 92 assertEquals("Navigation translation failed", "VelocityNavigation", ts.getNavigationName(templateName)); 93 } 94 95 public void testExistingTemplate() 96 throws Exception 97 { 98 String templateName = "ExistPage.vm"; 101 assertEquals("Screen translation failed", "VelocityScreen", ts.getScreenName(templateName)); 102 assertEquals("Layout translation failed", "VelocityOnlyLayout", ts.getLayoutName(templateName)); 103 assertEquals("Navigation translation failed", "VelocityNavigation", ts.getNavigationName(templateName)); 104 } 105 106 public void testExistingSublevelTemplate() 107 throws Exception 108 { 109 String templateName = "existing,Page.vm"; 112 assertEquals("Screen translation failed", "VelocityScreen", ts.getScreenName(templateName)); 113 assertEquals("Layout translation failed", "VelocityOnlyLayout", ts.getLayoutName(templateName)); 114 assertEquals("Navigation translation failed", "VelocityNavigation", ts.getNavigationName(templateName)); 115 } 116 117 119 public void testExistingClass() 120 throws Exception 121 { 122 String templateName = "ExistPageWithClass.vm"; 127 assertEquals("Screen translation failed", "ExistPageWithClass", ts.getScreenName(templateName)); 128 assertEquals("Layout translation failed", "ExistPageWithClass", ts.getLayoutName(templateName)); 129 assertEquals("Navigation translation failed", "ExistPageWithClass", ts.getNavigationName(templateName)); 130 } 131 132 public void testExistingSublevelClass() 133 throws Exception 134 { 135 String templateName = "existing,PageWithClass.vm"; 141 assertEquals("Screen translation failed", "existing.PageWithClass", ts.getScreenName(templateName)); 142 assertEquals("Layout translation failed", "existing.PageWithClass", ts.getLayoutName(templateName)); 143 assertEquals("Navigation translation failed", "existing.PageWithClass", ts.getNavigationName(templateName)); 144 } 145 146 public void testDefaultClass() 147 throws Exception 148 { 149 String templateName = "existing,dflt,PageWithClass.vm"; 153 assertEquals("Screen translation failed", "existing.dflt.Default", ts.getScreenName(templateName)); 154 assertEquals("Layout translation failed", "existing.dflt.Default", ts.getLayoutName(templateName)); 155 assertEquals("Navigation translation failed", "existing.dflt.Default", ts.getNavigationName(templateName)); 156 } 157 158 public void testDefaultSublevelClass() 159 throws Exception 160 { 161 String templateName = "existing,dflt,onelevel,twolevel,threelevel,PageWithClass.vm"; 165 assertEquals("Screen translation failed", "existing.dflt.Default", ts.getScreenName(templateName)); 166 assertEquals("Layout translation failed", "existing.dflt.Default", ts.getLayoutName(templateName)); 167 assertEquals("Navigation translation failed", "existing.dflt.Default", ts.getNavigationName(templateName)); 168 } 169 170 public void testIgnoreExistingClass() 171 throws Exception 172 { 173 String templateName = "sublevel,ExistPageWithClass.vm"; 178 assertEquals("Screen translation failed", "VelocityScreen", ts.getScreenName(templateName)); 179 assertEquals("Layout translation failed", "VelocityOnlyLayout", ts.getLayoutName(templateName)); 180 assertEquals("Navigation translation failed", "VelocityNavigation", ts.getNavigationName(templateName)); 181 } 182 183 184 } 185 | Popular Tags |