001: /*
002: * $Id: ResetTest.java 471756 2006-11-06 15:01:43Z husted $
003: *
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021: package org.apache.struts2.views.jsp.ui;
022:
023: import java.util.HashMap;
024: import java.util.Map;
025:
026: import org.apache.struts2.TestAction;
027: import org.apache.struts2.views.jsp.AbstractUITagTest;
028:
029: /**
030: * Reset Component Test.
031: *
032: */
033: public class ResetTest extends AbstractUITagTest {
034:
035: public void testDefaultValues() throws Exception {
036: TestAction testAction = (TestAction) action;
037: testAction.setFoo("bar");
038:
039: ResetTag tag = new ResetTag();
040: tag.setPageContext(pageContext);
041: tag.setLabel("mylabel");
042: tag.setName("myname");
043: tag.setTitle("mytitle");
044:
045: tag.doStartTag();
046: tag.doEndTag();
047:
048: verify(TextFieldTag.class.getResource("Reset-2.txt"));
049: }
050:
051: public void testSimple() throws Exception {
052: TestAction testAction = (TestAction) action;
053: testAction.setFoo("bar");
054:
055: ResetTag tag = new ResetTag();
056: tag.setPageContext(pageContext);
057: tag.setLabel("mylabel");
058: tag.setAlign("left");
059: tag.setName("myname");
060: tag.setValue("%{foo}");
061:
062: tag.doStartTag();
063: tag.doEndTag();
064:
065: verify(TextFieldTag.class.getResource("Reset-1.txt"));
066: }
067:
068: public void testButtonSimple() throws Exception {
069: TestAction testAction = (TestAction) action;
070: testAction.setFoo("bar");
071:
072: ResetTag tag = new ResetTag();
073: tag.setPageContext(pageContext);
074: tag.setType("button");
075: tag.setName("myname");
076: tag.setValue("%{foo}");
077:
078: tag.doStartTag();
079: tag.doEndTag();
080:
081: verify(TextFieldTag.class.getResource("Reset-3.txt"));
082: }
083:
084: public void testButtonWithLabel() throws Exception {
085: TestAction testAction = (TestAction) action;
086: testAction.setFoo("bar");
087:
088: ResetTag tag = new ResetTag();
089: tag.setPageContext(pageContext);
090: tag.setLabel("mylabel");
091: tag.setType("button");
092: tag.setAlign("left");
093: tag.setName("myname");
094: tag.setValue("%{foo}");
095:
096: tag.doStartTag();
097: tag.doEndTag();
098:
099: verify(TextFieldTag.class.getResource("Reset-4.txt"));
100: }
101:
102: /**
103: * Initialize a map of {@link org.apache.struts2.views.jsp.AbstractUITagTest.PropertyHolder} for generic tag
104: * property testing. Will be used when calling {@link #verifyGenericProperties(AbstractUITag,
105: * String, String[])} as properties to verify.<p/> This implementation extends testdata from AbstractUITag.
106: *
107: * @return A Map of PropertyHolders values bound to {@link org.apache.struts2.views.jsp.AbstractUITagTest.PropertyHolder#getName()}
108: * as key.
109: */
110: protected Map initializedGenericTagTestProperties() {
111: Map result = new HashMap();
112: new PropertyHolder("title", "someTitle").addToMap(result);
113: new PropertyHolder("cssClass", "cssClass1",
114: "class=\"cssClass1\"").addToMap(result);
115: new PropertyHolder("cssStyle", "cssStyle1",
116: "style=\"cssStyle1\"").addToMap(result);
117: new PropertyHolder("name", "someName").addToMap(result);
118: new PropertyHolder("value", "someValue").addToMap(result);
119: return result;
120: }
121:
122: public void testGenericSimple() throws Exception {
123: ResetTag tag = new ResetTag();
124: verifyGenericProperties(tag, "simple", null);
125: }
126:
127: public void testGenericXhtml() throws Exception {
128: ResetTag tag = new ResetTag();
129: verifyGenericProperties(tag, "xhtml", null);
130: }
131:
132: public void testGenericAjax() throws Exception {
133: ResetTag tag = new ResetTag();
134: verifyGenericProperties(tag, "ajax", null);
135: }
136:
137: }
|