1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.myfaces.view.facelets;
21
22 import javax.faces.component.UIOutput;
23 import javax.faces.component.UIViewRoot;
24 import javax.faces.component.html.HtmlOutputText;
25
26 import org.apache.myfaces.renderkit.html.HtmlTextRenderer;
27 import org.apache.myfaces.view.facelets.util.FastWriter;
28 import org.apache.myfaces.test.mock.MockResponseWriter;
29 import org.junit.Test;
30
31 public class TagTestCase extends FaceletTestCase {
32
33 @Override
34 protected void setupComponents() throws Exception
35 {
36 application.addComponent(UIViewRoot.COMPONENT_TYPE,
37 UIViewRoot.class.getName());
38 application.addComponent(HtmlOutputText.COMPONENT_TYPE,
39 HtmlOutputText.class.getName());
40
41 }
42
43 @Override
44 protected void setupConvertersAndValidators() throws Exception
45 {
46 }
47
48 @Override
49 protected void setupRenderers() throws Exception
50 {
51 renderKit.addRenderer(UIOutput.COMPONENT_FAMILY,
52 "javax.faces.Text", new HtmlTextRenderer());
53 }
54
55 @Test
56 public void testTagBody() throws Exception {
57 request.setAttribute("name", "Mr. Hookom");
58 UIViewRoot root = facesContext.getViewRoot();
59 vdl.buildView(facesContext, root,"userTag.xhtml");
60 FastWriter fw = new FastWriter();
61 MockResponseWriter mrw = new MockResponseWriter(fw);
62 facesContext.setResponseWriter(mrw);
63 root.encodeAll(facesContext);
64
65 }
66
67 @Test
68 public void testConditionalInsert() throws Exception {
69 UIViewRoot root = facesContext.getViewRoot();
70 vdl.buildView(facesContext, root,"userTagConditional.xhtml");
71 FastWriter fw = new FastWriter();
72 MockResponseWriter mrw = new MockResponseWriter(fw);
73 facesContext.setResponseWriter(mrw);
74 root.encodeAll(facesContext);
75
76 }
77
78 }