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