View Javadoc

1   /*
2    * $Id: TextareaTest.java 439747 2006-09-03 09:22:46Z mrdon $
3    *
4    * Copyright 2006 The Apache Software Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
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  }