01: /*
02: * $Id: HiddenTest.java 471756 2006-11-06 15:01:43Z husted $
03: *
04: * Licensed to the Apache Software Foundation (ASF) under one
05: * or more contributor license agreements. See the NOTICE file
06: * distributed with this work for additional information
07: * regarding copyright ownership. The ASF licenses this file
08: * to you under the Apache License, Version 2.0 (the
09: * "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: public class HiddenTest extends AbstractUITagTest {
32:
33: public void testSimple() throws Exception {
34: TestAction testAction = (TestAction) action;
35: testAction.setFoo("bar");
36:
37: HiddenTag tag = new HiddenTag();
38: tag.setPageContext(pageContext);
39: tag.setLabel("mylabel");
40: tag.setName("myname");
41: tag.setValue("%{foo}");
42:
43: tag.doStartTag();
44: tag.doEndTag();
45:
46: verify(TextFieldTag.class.getResource("Hidden-1.txt"));
47: }
48:
49: /**
50: * Initialize a map of {@link org.apache.struts2.views.jsp.AbstractUITagTest.PropertyHolder} for generic tag
51: * property testing. Will be used when calling {@link #verifyGenericProperties(org.apache.struts2.views.jsp.ui.AbstractUITag,
52: * String, String[])} as properties to verify.<p/> This implementation extends testdata from AbstractUITag.
53: *
54: * @return A Map of PropertyHolders values bound to {@link org.apache.struts2.views.jsp.AbstractUITagTest.PropertyHolder#getName()}
55: * as key.
56: */
57: protected Map initializedGenericTagTestProperties() {
58: Map result = new HashMap();
59: new PropertyHolder("name", "someName").addToMap(result);
60: new PropertyHolder("value", "someValue").addToMap(result);
61: new PropertyHolder("cssClass", "cssClass1",
62: "class=\"cssClass1\"").addToMap(result);
63: new PropertyHolder("cssStyle", "cssStyle1",
64: "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:
79: public void testGenericAjax() throws Exception {
80: HiddenTag tag = new HiddenTag();
81: verifyGenericProperties(tag, "ajax", null);
82: }
83:
84: }
|