1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.myfaces.renderkit.html;
20
21 import java.io.StringWriter;
22
23 import javax.el.ExpressionFactory;
24 import javax.faces.application.ViewHandler;
25 import javax.faces.component.UIViewRoot;
26
27 import junit.framework.Assert;
28
29 import org.apache.myfaces.test.mock.MockResponseWriter;
30 import org.apache.myfaces.view.facelets.ELExpressionCacheMode;
31 import org.apache.myfaces.view.facelets.FaceletTestCase;
32 import org.apache.myfaces.view.facelets.impl.FaceletCompositionContextImpl;
33 import org.junit.Test;
34
35 public class HtmlRolePassedThroughTestCase extends FaceletTestCase
36 {
37
38 @Override
39 protected void setUpServletObjects() throws Exception
40 {
41 super.setUpServletObjects();
42 }
43
44 @Override
45 protected ExpressionFactory createExpressionFactory()
46 {
47 return new org.apache.el.ExpressionFactoryImpl();
48 }
49
50 @Test
51 public void testRole() throws Exception
52 {
53 UIViewRoot root = facesContext.getViewRoot();
54 vdl.buildView(facesContext, root, "role.xhtml");
55
56 StringWriter sw = new StringWriter();
57 MockResponseWriter mrw = new MockResponseWriter(sw);
58 facesContext.setResponseWriter(mrw);
59
60 root.encodeAll(facesContext);
61 sw.flush();
62
63
64
65 Assert.assertTrue(sw.toString().contains("value=\"user name\" role=\"new presentation\""));
66 Assert.assertTrue(sw.toString().contains("id=\"helloForm:link\" role=\"new presentation\""));
67 Assert.assertTrue(sw.toString().contains("<table role=\"new presentation\">"));
68 Assert.assertTrue(sw.toString().contains("value=\"one\" role=\"new presentation\""));
69
70 Assert.assertTrue(sw.toString().contains("id=\"helloForm:data\" role=\"new presentation\""));
71 Assert.assertTrue(sw.toString().contains("id=\"helloForm:graphic\" role=\"new presentation\""));
72 Assert.assertTrue(sw.toString().contains("type=\"file\" role=\"new presentation\""));
73 Assert.assertTrue(sw.toString().contains("name=\"helloForm:area\" role=\"new presentation\""));
74
75 Assert.assertTrue(sw.toString().contains("id=\"helloForm:outputFormat\" role=\"new presentation\""));
76 Assert.assertTrue(sw.toString().contains("id=\"helloForm:outputLabel\" role=\"new presentation\""));
77 Assert.assertTrue(sw.toString().contains("name=\"helloForm:outputLink\" role=\"new presentation\""));
78 Assert.assertTrue(sw.toString().contains("id=\"helloForm:outputText\" role=\"new presentation\""));
79
80
81
82 Assert.assertTrue(sw.toString().contains("name=\"helloForm:selectManyListbox\" multiple=\"multiple\" size=\"0\" role=\"new presentation\""));
83 Assert.assertTrue(sw.toString().contains("name=\"helloForm:selectManyMenu\" multiple=\"multiple\" size=\"1\" role=\"new presentation\""));
84
85 Assert.assertTrue(sw.toString().contains("name=\"helloForm:selectOneListbox\" size=\"0\" role=\"new presentation\""));
86 Assert.assertTrue(sw.toString().contains("name=\"helloForm:selectOneMenu\" size=\"1\" role=\"new presentation\""));
87
88
89 }
90 }