1 package org.melati.template.test;
2
3 import org.melati.MelatiConfig;
4 import org.melati.template.webmacro.WebmacroTemplateEngine;
5 import org.melati.util.MelatiException;
6 import org.melati.poem.AccessPoemException;
7 import org.melati.poem.Capability;
8
9
10
11
12
13
14
15
16 public class WMLMarkupLanguageWebmacroTest extends WMLMarkupLanguageSpec {
17
18
19
20
21
22 public WMLMarkupLanguageWebmacroTest(String arg0) {
23 super(arg0);
24 }
25
26
27
28 public WMLMarkupLanguageWebmacroTest() {
29 super();
30 }
31
32
33
34
35
36
37 protected void setUp() throws Exception {
38 super.setUp();
39 }
40 protected void melatiConfig() throws MelatiException {
41 mc = new MelatiConfig();
42 if(mc.getTemplateEngine().getName() != "webmacro") {
43 mc.setTemplateEngine(new WebmacroTemplateEngine());
44 }
45 }
46
47
48
49
50
51
52 public void testGetName() {
53 assertEquals("wml", ml.getName());
54 assertEquals("wml_attr", aml.getName());
55 }
56
57
58
59
60
61
62
63
64 public void testRenderedAccessPoemException() throws Exception {
65
66 assertEquals("java.lang.Exception",aml.rendered(new Exception()));
67
68 AccessPoemException ape = new AccessPoemException(
69 getDb().getUserTable().guestUser(), new Capability("Cool"));
70 System.err.println(ml.rendered(ape));
71 assertTrue(ml.rendered(ape).indexOf(
72 "org.melati.poem.AccessPoemException: " +
73 "You need the capability Cool but " +
74 "your access token _guest_ doesn't confer it") != -1);
75
76 ape = new AccessPoemException();
77 assertEquals("", aml.rendered(ape));
78
79 assertTrue(m.getWriter().toString().indexOf("[Access denied to [UNRENDERABLE EXCEPTION!]") != -1);
80 ape = new AccessPoemException(
81 getDb().getUserTable().guestUser(), new Capability("Cool"));
82 assertEquals("", aml.rendered(ape));
83
84
85
86 assertTrue(m.getWriter().toString().indexOf("[Access denied to _guest_]") != -1);
87
88 }
89
90
91 }