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 * Reset Component Test.
32 *
33 */
34 public class ResetTest extends AbstractUITagTest {
35
36 public void testDefaultValues() throws Exception {
37 TestAction testAction = (TestAction) action;
38 testAction.setFoo("bar");
39
40 ResetTag tag = new ResetTag();
41 tag.setPageContext(pageContext);
42 tag.setLabel("mylabel");
43 tag.setName("myname");
44 tag.setTitle("mytitle");
45
46 tag.doStartTag();
47 tag.doEndTag();
48
49 verify(TextFieldTag.class.getResource("Reset-2.txt"));
50 }
51
52 public void testSimple() throws Exception {
53 TestAction testAction = (TestAction) action;
54 testAction.setFoo("bar");
55
56 ResetTag tag = new ResetTag();
57 tag.setPageContext(pageContext);
58 tag.setLabel("mylabel");
59 tag.setAlign("left");
60 tag.setName("myname");
61 tag.setValue("%{foo}");
62
63 tag.doStartTag();
64 tag.doEndTag();
65
66 verify(TextFieldTag.class.getResource("Reset-1.txt"));
67 }
68
69 public void testButtonSimple() throws Exception {
70 TestAction testAction = (TestAction) action;
71 testAction.setFoo("bar");
72
73 ResetTag tag = new ResetTag();
74 tag.setPageContext(pageContext);
75 tag.setType("button");
76 tag.setName("myname");
77 tag.setValue("%{foo}");
78
79 tag.doStartTag();
80 tag.doEndTag();
81
82 verify(TextFieldTag.class.getResource("Reset-3.txt"));
83 }
84
85 public void testButtonWithLabel() throws Exception {
86 TestAction testAction = (TestAction) action;
87 testAction.setFoo("bar");
88
89 ResetTag tag = new ResetTag();
90 tag.setPageContext(pageContext);
91 tag.setLabel("mylabel");
92 tag.setType("button");
93 tag.setAlign("left");
94 tag.setName("myname");
95 tag.setValue("%{foo}");
96
97 tag.doStartTag();
98 tag.doEndTag();
99
100 verify(TextFieldTag.class.getResource("Reset-4.txt"));
101 }
102
103 /***
104 * Initialize a map of {@link org.apache.struts2.views.jsp.AbstractUITagTest.PropertyHolder} for generic tag
105 * property testing. Will be used when calling {@link #verifyGenericProperties(AbstractUITag,
106 * String, String[])} as properties to verify.<p/> This implementation extends testdata from AbstractUITag.
107 *
108 * @return A Map of PropertyHolders values bound to {@link org.apache.struts2.views.jsp.AbstractUITagTest.PropertyHolder#getName()}
109 * as key.
110 */
111 protected Map initializedGenericTagTestProperties() {
112 Map result = new HashMap();
113 new PropertyHolder("title", "someTitle").addToMap(result);
114 new PropertyHolder("cssClass", "cssClass1", "class=\"cssClass1\"").addToMap(result);
115 new PropertyHolder("cssStyle", "cssStyle1", "style=\"cssStyle1\"").addToMap(result);
116 new PropertyHolder("name", "someName").addToMap(result);
117 new PropertyHolder("value", "someValue").addToMap(result);
118 return result;
119 }
120
121 public void testGenericSimple() throws Exception {
122 ResetTag tag = new ResetTag();
123 verifyGenericProperties(tag, "simple", null);
124 }
125
126 public void testGenericXhtml() throws Exception {
127 ResetTag tag = new ResetTag();
128 verifyGenericProperties(tag, "xhtml", null);
129 }
130 }