1 52 53 package freemarker.testcase; 54 55 import freemarker.template.SimpleHash; 56 import freemarker.template.SimpleScalar; 57 import freemarker.template.SimpleSequence; 58 59 64 public class TestVariables extends AbstractTestCase { 65 66 67 public TestVariables(String aTestname) { 68 super( aTestname ); 69 } 70 71 74 public void setUp() { 75 setUpFiles( "test-variables.html" ); 76 77 root.put("message", new SimpleScalar("Hello, world!")); 78 79 SimpleSequence cModel1 = new SimpleSequence(); 80 SimpleHash cModel2 = new SimpleHash(); 81 SimpleHash cModel3 = new SimpleHash(); 82 SimpleHash cModel4 = new SimpleHash(); 83 84 cModel1.add( "one" ); 85 cModel1.add( "two" ); 86 cModel1.add( "three" ); 87 cModel1.add( "four" ); 88 cModel1.add( "five" ); 89 90 cModel2.put( "output", new SimpleScalar( "My message." )); 91 cModel2.put( "key", cModel1 ); 92 cModel3.put( "value", cModel2 ); 93 cModel4.put( "mykey", "key" ); 94 cModel4.put( "_test", "out" ); 95 96 root.put( "list", cModel1 ); 97 root.put( "hash", cModel2 ); 98 root.put( "hash2", cModel3 ); 99 root.put( "items", cModel4 ); 100 } 101 102 103 105 public static void main( String [] argc ) throws Exception { 106 AbstractTestCase cTest = new TestVariables( "test-variables.html" ); 107 cTest.run(); 108 } 109 } 110 | Popular Tags |