1 18 package net.sf.uitags.util; 19 20 import net.sf.uitags.util.Template; 21 import junit.framework.TestCase; 22 23 29 public class TemplateTest extends TestCase { 30 31 34 private Template tpl; 35 36 41 public static void main(String [] args) { 42 junit.textui.TestRunner.run(TemplateTest.class); 43 } 44 45 46 protected void setUp() throws Exception { 47 super.setUp(); 48 this.tpl = Template.forName("test.vm"); 49 } 50 51 52 protected void tearDown() throws Exception { 53 super.tearDown(); 54 this.tpl = null; 55 } 56 57 60 public void testEval() { 61 assertEquals("Simple $template loaded!", this.tpl.evalToString().trim()); 62 assertEquals(this.tpl.eval().toString(), this.tpl.evalToString()); 63 } 64 65 68 public void testMap() { 69 this.tpl.map("template", "'String' mapped template"); 70 assertEquals(this.tpl.evalToString().trim(), 71 "Simple 'String' mapped template loaded!"); 72 73 this.tpl.map("template", new Object () { 74 public String toString() { 75 return "'Object' mapped template"; 76 } 77 }); 78 assertEquals(this.tpl.evalToString().trim(), 79 "Simple 'Object' mapped template loaded!"); 80 } 81 } 82 | Popular Tags |