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