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 TemplateTest 34 extends BaseTurbineTest 35 { 36 private static TemplateService ts = null; 37 38 public TemplateTest(String name) 39 throws Exception 40 { 41 super(name, "/conf/test/TemplateService.properties"); 42 43 ts = (TemplateService) TurbineServices.getInstance().getService(TemplateService.SERVICE_NAME); 44 } 45 46 public static Test suite() 47 { 48 return new TestSuite(TemplateTest.class); 49 } 50 51 public void testTemplateDefaults() 52 { 53 assertEquals("Default LayoutTemplate failed", TemplateService.DEFAULT_TEMPLATE_VALUE, ts.getDefaultLayoutTemplate()); 54 } 55 56 public void testVelocityDefaults() 57 { 58 assertEquals("Default LayoutTemplate failed", "Default.vm", ts.getDefaultLayoutTemplateName("foo.vm")); 59 } 60 61 public void testNonExistingTemplate() 62 throws Exception 63 { 64 String templateName = "DoesNotExistPage.vm"; 69 assertEquals("LayoutTemplate translation failed", "Default.vm", ts.getLayoutTemplateName(templateName)); 70 assertEquals("ScreenTemplate translation failed", null, ts.getScreenTemplateName(templateName)); 71 } 72 73 public void testNonExistingSublevelTemplate() 74 throws Exception 75 { 76 String templateName = "this,template,DoesNotExistPage.vm"; 81 assertEquals("LayoutTemplate translation failed", "Default.vm", ts.getLayoutTemplateName(templateName)); 82 assertEquals("ScreenTemplate translation failed", null, ts.getScreenTemplateName(templateName)); 83 } 84 85 public void testExistingTemplate() 86 throws Exception 87 { 88 String templateName = "ExistPage.vm"; 93 assertEquals("LayoutTemplate translation failed", "Default.vm", ts.getLayoutTemplateName(templateName)); 94 assertEquals("ScreenTemplate translation failed", "ExistPage.vm", ts.getScreenTemplateName(templateName)); 95 } 96 97 public void testExistingSublevelTemplate() 98 throws Exception 99 { 100 String templateName = "existing,Page.vm"; 106 assertEquals("LayoutTemplate translation failed", "Default.vm", ts.getLayoutTemplateName(templateName)); 107 assertEquals("ScreenTemplate translation failed", "existing/Page.vm", ts.getScreenTemplateName(templateName)); 108 } 109 110 public void testExistingLayoutTemplate() 111 throws Exception 112 { 113 String templateName = "ExistPageWithLayout.vm"; 118 assertEquals("LayoutTemplate translation failed", "ExistPageWithLayout.vm", ts.getLayoutTemplateName(templateName)); 119 assertEquals("ScreenTemplate translation failed", "ExistPageWithLayout.vm", ts.getScreenTemplateName(templateName)); 120 } 121 122 public void testExistingSublevelLayoutTemplate() 123 throws Exception 124 { 125 String templateName = "existing,ExistSublevelPageWithLayout.vm"; 130 assertEquals("LayoutTemplate translation failed", "existing/ExistSublevelPageWithLayout.vm", ts.getLayoutTemplateName(templateName)); 131 assertEquals("ScreenTemplate translation failed", "existing/ExistSublevelPageWithLayout.vm", ts.getScreenTemplateName(templateName)); 132 } 133 134 public void testExistingDefaultLayoutTemplate() 135 throws Exception 136 { 137 String templateName = "existing,ExistPageWithLayout.vm"; 142 assertEquals("LayoutTemplate translation failed", "Default.vm", ts.getLayoutTemplateName(templateName)); 143 assertEquals("ScreenTemplate translation failed", "existing/ExistPageWithLayout.vm", ts.getScreenTemplateName(templateName)); 144 } 145 } 146 147 | Popular Tags |