1   package org.melati.template.test;
2   
3   import org.melati.MelatiConfig;
4   import org.melati.template.TemplateEngineException;
5   import org.melati.template.velocity.VelocityTemplateEngine;
6   import org.melati.util.MelatiBugMelatiException;
7   import org.melati.util.MelatiException;
8   
9   
10  /**
11   * Run all the tests against velocity.
12   * 
13   * @author timp
14   * @since 21-May-2006
15   *
16   */
17  public class HTMLMarkupLanguageVelocityTest extends HTMLMarkupLanguageSpec {
18  
19    /**
20     * 
21     */
22    public HTMLMarkupLanguageVelocityTest() {
23      super();
24    }
25    
26    /** 
27     * {@inheritDoc}
28     * @see org.melati.template.test.MarkupLanguageSpec#setUp()
29     */
30    protected void setUp() throws Exception {
31      super.setUp();
32    }
33  
34    protected void melatiConfig() throws MelatiException {
35      mc = new MelatiConfig();
36      mc.setTemplateEngine(new VelocityTemplateEngine());
37    }
38  
39    /**
40     * Test that a syntax error in a WM templet is handled by Velocity.
41     */
42    public void testSyntaxErrorInWMTemplet() throws Exception { 
43      Object templated = new TemplatedWithWMSyntaxError();
44      try { 
45        ml.rendered(templated);
46        fail("Should have bombed");
47      } catch (MelatiBugMelatiException e) { 
48        assertTrue(e.getCause().getMessage().startsWith("Encountered"));
49        e = null;
50      } catch (TemplateEngineException e) { // If a bad .vm file is found instead,
51                                            // due to auto creation of .vm from .wm files
52        assertTrue(e.getCause().getMessage().startsWith("Encountered"));
53        e = null;
54      }
55    }
56    
57  }