1
2
3
4 package org.melati.template.test;
5
6 import java.util.Enumeration;
7
8 import org.melati.Melati;
9 import org.melati.MelatiConfig;
10 import org.melati.poem.test.PoemTestCase;
11 import org.melati.template.Template;
12 import org.melati.template.TemplateContext;
13 import org.melati.template.TemplateEngine;
14 import org.melati.util.MelatiStringWriter;
15
16
17
18
19
20
21 public abstract class TemplateEngineSpec extends PoemTestCase {
22
23 protected TemplateEngine templateEngine = null;
24
25
26
27
28 public TemplateEngineSpec(String name) {
29 super(name);
30 }
31
32
33
34
35
36 protected void setUp() throws Exception {
37 super.setUp();
38 setTemplateEngine();
39 }
40
41
42
43
44
45 protected void tearDown() throws Exception {
46 super.tearDown();
47 }
48
49
50 abstract protected void setTemplateEngine();
51
52
53
54 public void testInit() throws Exception {
55 MelatiConfig mc = new MelatiConfig();
56 templateEngine.init(mc);
57
58 }
59
60
61
62
63 public void testGetTemplateContext() throws Exception {
64 MelatiConfig mc = new MelatiConfig();
65 templateEngine.init(mc);
66 Melati melati = new Melati(mc,new MelatiStringWriter());
67 templateEngine.getTemplateContext(melati);
68 }
69
70
71
72
73 public abstract void testGetName();
74
75
76
77
78 public abstract void testTemplateExtension();
79
80
81
82
83 public void testGetRoots() {
84
85 }
86
87
88
89
90 public void testAddRoot() {
91 Enumeration<String> en = templateEngine.getRoots();
92 int counter = 0;
93 while (en.hasMoreElements()) {
94 en.nextElement();
95 counter++;
96 }
97 assertEquals(1, counter);
98 templateEngine.addRoot("root");
99 en = templateEngine.getRoots();
100 counter = 0;
101 while (en.hasMoreElements()) {
102 en.nextElement();
103 counter++;
104 }
105 assertEquals(2, counter);
106 }
107
108
109
110
111 public void testTemplate() {
112
113 }
114
115
116
117
118 public void testGetTemplateName() {
119
120 }
121
122
123
124
125
126 public void testExpandTemplateMelatiWriterStringTemplateContext() throws Exception {
127
128 }
129
130
131
132
133
134 public void testExpandTemplateMelatiWriterTemplateTemplateContext() throws Exception {
135
136 }
137
138
139
140
141
142 public void testExpandedTemplate() throws Exception {
143 MelatiConfig mc = new MelatiConfig();
144 templateEngine.init(mc);
145 Melati melati = new Melati(mc,new MelatiStringWriter());
146 TemplateContext templateContext = templateEngine.getTemplateContext(melati);
147 Template template = templateEngine.template("org/melati/template/test/Templated" +
148 templateEngine.templateExtension());
149 assertEquals("Hi, this is from a template.", templateEngine.expandedTemplate(template, templateContext));
150 }
151
152
153
154
155 public void testGetStringWriter() {
156
157 }
158
159
160
161
162 public void testGetEngine() {
163
164 }
165
166 }