View Javadoc

1   /*
2    * $Id: TextareaTest.java 651946 2008-04-27 13:41:38Z apetrelli $
3    *
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "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  
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  }