1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.myfaces.view.facelets.tag.jsf.html;
20
21 import java.io.StringWriter;
22
23 import javax.faces.component.UIComponent;
24 import javax.faces.component.UIViewRoot;
25
26 import org.apache.myfaces.test.mock.MockResponseWriter;
27 import org.apache.myfaces.view.facelets.FaceletTestCase;
28 import org.junit.Assert;
29 import org.junit.Test;
30
31 public class HtmlOutputScriptTestCase extends FaceletTestCase
32 {
33 @Test
34 public void testSimpleOutputScript() throws Exception
35 {
36 UIViewRoot root = facesContext.getViewRoot();
37 vdl.buildView(facesContext, root, "testSimpleOutputScript.xhtml");
38
39 UIComponent head = root.findComponent("head");
40 Assert.assertNotNull(head);
41 UIComponent body = root.findComponent("body");
42 Assert.assertNotNull(body);
43
44 StringWriter sw = new StringWriter();
45 MockResponseWriter mrw = new MockResponseWriter(sw);
46 facesContext.setResponseWriter(mrw);
47
48 root.encodeAll(facesContext);
49 sw.flush();
50
51 }
52
53 @Test
54 public void testSimpleTargetHeadOutputScript() throws Exception
55 {
56 UIViewRoot root = facesContext.getViewRoot();
57 vdl.buildView(facesContext, root, "testSimpleTargetHeadOutputScript.xhtml");
58
59 UIComponent head = root.findComponent("head");
60 Assert.assertNotNull(head);
61 UIComponent body = root.findComponent("body");
62 Assert.assertNotNull(body);
63
64 StringWriter sw = new StringWriter();
65 MockResponseWriter mrw = new MockResponseWriter(sw);
66 facesContext.setResponseWriter(mrw);
67
68 root.encodeAll(facesContext);
69 sw.flush();
70
71 }
72
73 @Test
74 public void testMultipleTargetHeadOutputScript() throws Exception
75 {
76 UIViewRoot root = facesContext.getViewRoot();
77 vdl.buildView(facesContext, root, "testMultipleTargetHeadOutputScript.xhtml");
78
79 UIComponent head = root.findComponent("head");
80 Assert.assertNotNull(head);
81 UIComponent body = root.findComponent("body");
82 Assert.assertNotNull(body);
83
84 StringWriter sw = new StringWriter();
85 MockResponseWriter mrw = new MockResponseWriter(sw);
86 facesContext.setResponseWriter(mrw);
87
88 root.encodeAll(facesContext);
89 sw.flush();
90
91 }
92 }