View Javadoc

1   /*
2    * $Id: HiddenTest.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.HashMap;
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 HiddenTest extends AbstractUITagTest {
33  
34      public void testSimple() throws Exception {
35          TestAction testAction = (TestAction) action;
36          testAction.setFoo("bar");
37  
38          HiddenTag tag = new HiddenTag();
39          tag.setPageContext(pageContext);
40          tag.setLabel("mylabel");
41          tag.setName("myname");
42          tag.setValue("%{foo}");
43  
44          tag.doStartTag();
45          tag.doEndTag();
46  
47          verify(TextFieldTag.class.getResource("Hidden-1.txt"));
48      }
49  
50      /***
51       * Initialize a map of {@link org.apache.struts2.views.jsp.AbstractUITagTest.PropertyHolder} for generic tag
52       * property testing. Will be used when calling {@link #verifyGenericProperties(org.apache.struts2.views.jsp.ui.AbstractUITag,
53       * String, String[])} as properties to verify.<p/> This implementation extends testdata from AbstractUITag.
54       *
55       * @return A Map of PropertyHolders values bound to {@link org.apache.struts2.views.jsp.AbstractUITagTest.PropertyHolder#getName()}
56       *         as key.
57       */
58      protected Map initializedGenericTagTestProperties() {
59          Map result = new HashMap();
60          new PropertyHolder("name", "someName").addToMap(result);
61          new PropertyHolder("value", "someValue").addToMap(result);
62          new PropertyHolder("cssClass", "cssClass1", "class=\"cssClass1\"").addToMap(result);
63          new PropertyHolder("cssStyle", "cssStyle1", "style=\"cssStyle1\"").addToMap(result);
64          new PropertyHolder("id", "someId").addToMap(result);
65          return result;
66      }
67  
68      public void testGenericSimple() throws Exception {
69          HiddenTag tag = new HiddenTag();
70          verifyGenericProperties(tag, "simple", null);
71      }
72  
73      public void testGenericXhtml() throws Exception {
74          HiddenTag tag = new HiddenTag();
75          verifyGenericProperties(tag, "xhtml", null);
76      }
77  
78      public void testGenericAjax() throws Exception {
79          HiddenTag tag = new HiddenTag();
80          verifyGenericProperties(tag, "ajax", null);
81      }
82  
83  }