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