View Javadoc

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