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