View Javadoc

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