View Javadoc

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