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