1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package info.magnolia.templating.jsp.cms;
35
36 import static org.hamcrest.CoreMatchers.containsString;
37 import static org.junit.Assert.*;
38
39 import info.magnolia.cms.core.MgnlNodeType;
40 import info.magnolia.rendering.template.configured.ConfiguredAreaDefinition;
41 import info.magnolia.rendering.template.configured.ConfiguredTemplateDefinition;
42 import info.magnolia.templating.jsp.AbstractTagTestCase;
43
44 import javax.jcr.Node;
45
46 import org.junit.Before;
47 import org.junit.Test;
48
49 import com.meterware.httpunit.GetMethodWebRequest;
50 import com.meterware.httpunit.WebRequest;
51 import com.meterware.httpunit.WebResponse;
52
53
54
55
56 public class AreaBarTagTest extends AbstractTagTestCase {
57
58 private String jspUrl;
59
60 @Override
61 @Before
62 public void setUp() throws Exception {
63 super.setUp();
64 String jspPath = getClass().getName().replace('.', '/') + ".jsp";
65 jspUrl = "http://localhost" + CONTEXT + "/" + jspPath;
66
67 ConfiguredTemplateDefinition renderableDefinition = new ConfiguredTemplateDefinition();
68 ConfiguredAreaDefinition areaDefinition = new ConfiguredAreaDefinition();
69 renderableDefinition.addArea("stage", areaDefinition);
70 setRenderableDefinition(renderableDefinition);
71 }
72
73
74 @Test
75 public void testRenderSimpleBarWithoutAreaNode() throws Exception {
76
77 final WebRequest request = new GetMethodWebRequest(jspUrl);
78 final WebResponse response = runner.getResponse(request);
79
80
81 final String responseStr = response.getText();
82
83
84 assertNotNull(responseStr);
85 assertThat(responseStr, containsString("<!-- cms:area content=\"website:/foo/bar/paragraphs/1/stage\" name=\"stage\" availableComponents=\"\" type=\"list\" " +
86 "label=\"Stage\" inherit=\"false\" optional=\"false\" showAddButton=\"true\" showNewComponentArea=\"true\" -->"));
87 }
88
89 @Test
90 public void testRenderSimpleBar() throws Exception {
91
92 Node paragraph1 = getSession().getNode("/foo/bar/paragraphs/1");
93
94 paragraph1.addNode("stage", MgnlNodeType.NT_AREA);
95
96 final WebRequest request = new GetMethodWebRequest(jspUrl);
97 final WebResponse response = runner.getResponse(request);
98
99
100 final String responseStr = response.getText();
101
102
103 assertNotNull(responseStr);
104 assertThat(responseStr, containsString("<!-- cms:area content=\"website:/foo/bar/paragraphs/1/stage\" name=\"stage\" availableComponents=\"\" type=\"list\" " +
105 "label=\"Stage\" inherit=\"false\" optional=\"false\" showAddButton=\"true\" showNewComponentArea=\"true\" -->"));
106
107 }
108
109 }