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