1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.apache.struts2.views.jsp.ui;
23
24 import java.util.HashMap;
25 import java.util.Map;
26
27 import org.apache.struts2.TestAction;
28 import org.apache.struts2.views.jsp.AbstractUITagTest;
29
30
31 /***
32 */
33 public class HiddenTest extends AbstractUITagTest {
34
35 public void testSimple() throws Exception {
36 TestAction testAction = (TestAction) action;
37 testAction.setFoo("bar");
38
39 HiddenTag tag = new HiddenTag();
40 tag.setPageContext(pageContext);
41 tag.setLabel("mylabel");
42 tag.setName("myname");
43 tag.setValue("%{foo}");
44
45 tag.doStartTag();
46 tag.doEndTag();
47
48 verify(TextFieldTag.class.getResource("Hidden-1.txt"));
49 }
50
51 public void testDisabled() throws Exception {
52 TestAction testAction = (TestAction) action;
53 testAction.setFoo("bar");
54
55 HiddenTag tag = new HiddenTag();
56 tag.setPageContext(pageContext);
57 tag.setLabel("mylabel");
58 tag.setName("myname");
59 tag.setValue("%{foo}");
60 tag.setDisabled("true");
61
62 tag.doStartTag();
63 tag.doEndTag();
64
65 verify(TextFieldTag.class.getResource("Hidden-2.txt"));
66 }
67
68 /***
69 * Initialize a map of {@link org.apache.struts2.views.jsp.AbstractUITagTest.PropertyHolder} for generic tag
70 * property testing. Will be used when calling {@link #verifyGenericProperties(org.apache.struts2.views.jsp.ui.AbstractUITag,
71 * String, String[])} as properties to verify.<p/> This implementation extends testdata from AbstractUITag.
72 *
73 * @return A Map of PropertyHolders values bound to {@link org.apache.struts2.views.jsp.AbstractUITagTest.PropertyHolder#getName()}
74 * as key.
75 */
76 protected Map initializedGenericTagTestProperties() {
77 Map result = new HashMap();
78 new PropertyHolder("name", "someName").addToMap(result);
79 new PropertyHolder("value", "someValue").addToMap(result);
80 new PropertyHolder("cssClass", "cssClass1", "class=\"cssClass1\"").addToMap(result);
81 new PropertyHolder("cssStyle", "cssStyle1", "style=\"cssStyle1\"").addToMap(result);
82 new PropertyHolder("id", "someId").addToMap(result);
83 return result;
84 }
85
86 public void testGenericSimple() throws Exception {
87 HiddenTag tag = new HiddenTag();
88 verifyGenericProperties(tag, "simple", null);
89 }
90
91 public void testGenericXhtml() throws Exception {
92 HiddenTag tag = new HiddenTag();
93 verifyGenericProperties(tag, "xhtml", null);
94 }
95 }