01: /*
02: * $Id: TextareaTest.java 471756 2006-11-06 15:01:43Z husted $
03: *
04: * Licensed to the Apache Software Foundation (ASF) under one
05: * or more contributor license agreements. See the NOTICE file
06: * distributed with this work for additional information
07: * regarding copyright ownership. The ASF licenses this file
08: * to you under the Apache License, Version 2.0 (the
09: * "License"); you may not use this file except in compliance
10: * with the License. You may obtain a copy of the License at
11: *
12: * http://www.apache.org/licenses/LICENSE-2.0
13: *
14: * Unless required by applicable law or agreed to in writing,
15: * software distributed under the License is distributed on an
16: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17: * KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations
19: * under the License.
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: public class TextareaTest extends AbstractUITagTest {
31:
32: public void testSimple() throws Exception {
33: TestAction testAction = (TestAction) action;
34: testAction.setFoo("bar");
35:
36: TextareaTag tag = new TextareaTag();
37: tag.setPageContext(pageContext);
38: tag.setLabel("mylabel");
39: tag.setName("myname");
40: tag.setValue("%{foo}");
41: tag.setRows("30");
42: tag.setCols("20");
43: tag.setTitle("mytitle");
44: tag.setDisabled("true");
45: tag.setTabindex("5");
46: tag.setOnchange("alert('goodbye');");
47: tag.setOnclick("alert('onclick');");
48: tag.setId("the_id");
49: tag.setOnkeyup("alert('hello');");
50: tag.setReadonly("true");
51:
52: tag.doStartTag();
53: tag.doEndTag();
54:
55: verify(TextareaTag.class.getResource("Textarea-1.txt"));
56: }
57:
58: /**
59: * Initialize a map of {@link org.apache.struts2.views.jsp.AbstractUITagTest.PropertyHolder} for generic tag
60: * property testing. Will be used when calling {@link #verifyGenericProperties(org.apache.struts2.views.jsp.ui.AbstractUITag,
61: * String, String[])} as properties to verify.<p/> This implementation extends testdata from AbstractUITag.
62: *
63: * @return A Map of PropertyHolders values bound to {@link org.apache.struts2.views.jsp.AbstractUITagTest.PropertyHolder#getName()}
64: * as key.
65: */
66: protected Map initializedGenericTagTestProperties() {
67: Map result = super .initializedGenericTagTestProperties();
68: new PropertyHolder("cols", "10").addToMap(result);
69: new PropertyHolder("rows", "11").addToMap(result);
70: new PropertyHolder("readonly", "true", "readonly=\"readonly\"")
71: .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: }
|