001: /*
002: * Copyright (c) 2002-2006 by OpenSymphony
003: * All rights reserved.
004: */
005: package com.opensymphony.webwork.views.jsp.ui;
006:
007: import com.opensymphony.webwork.TestAction;
008: import com.opensymphony.webwork.views.jsp.AbstractUITagTest;
009:
010: import java.util.HashMap;
011: import java.util.Map;
012:
013: /**
014: * Reset Component Test.
015: *
016: * @author Rene Gielen
017: */
018: public class ResetTest extends AbstractUITagTest {
019:
020: public void testDefaultValues() throws Exception {
021: TestAction testAction = (TestAction) action;
022: testAction.setFoo("bar");
023:
024: ResetTag tag = new ResetTag();
025: tag.setPageContext(pageContext);
026: tag.setLabel("mylabel");
027: tag.setName("myname");
028: tag.setTitle("mytitle");
029:
030: tag.doStartTag();
031: tag.doEndTag();
032:
033: verify(TextFieldTag.class.getResource("Reset-2.txt"));
034: }
035:
036: public void testSimple() throws Exception {
037: TestAction testAction = (TestAction) action;
038: testAction.setFoo("bar");
039:
040: ResetTag tag = new ResetTag();
041: tag.setPageContext(pageContext);
042: tag.setLabel("mylabel");
043: tag.setAlign("left");
044: tag.setName("myname");
045: tag.setValue("%{foo}");
046:
047: tag.doStartTag();
048: tag.doEndTag();
049:
050: verify(TextFieldTag.class.getResource("Reset-1.txt"));
051: }
052:
053: public void testButtonSimple() throws Exception {
054: TestAction testAction = (TestAction) action;
055: testAction.setFoo("bar");
056:
057: ResetTag tag = new ResetTag();
058: tag.setPageContext(pageContext);
059: tag.setType("button");
060: tag.setName("myname");
061: tag.setValue("%{foo}");
062:
063: tag.doStartTag();
064: tag.doEndTag();
065:
066: verify(TextFieldTag.class.getResource("Reset-3.txt"));
067: }
068:
069: public void testButtonWithLabel() throws Exception {
070: TestAction testAction = (TestAction) action;
071: testAction.setFoo("bar");
072:
073: ResetTag tag = new ResetTag();
074: tag.setPageContext(pageContext);
075: tag.setLabel("mylabel");
076: tag.setType("button");
077: tag.setAlign("left");
078: tag.setName("myname");
079: tag.setValue("%{foo}");
080:
081: tag.doStartTag();
082: tag.doEndTag();
083:
084: verify(TextFieldTag.class.getResource("Reset-4.txt"));
085: }
086:
087: /**
088: * Initialize a map of {@link com.opensymphony.webwork.views.jsp.AbstractUITagTest.PropertyHolder} for generic tag
089: * property testing. Will be used when calling {@link #verifyGenericProperties(AbstractUITag,
090: * String, String[])} as properties to verify.<p/> This implementation extends testdata from AbstractUITag.
091: *
092: * @return A Map of PropertyHolders values bound to {@link com.opensymphony.webwork.views.jsp.AbstractUITagTest.PropertyHolder#getName()}
093: * as key.
094: */
095: protected Map initializedGenericTagTestProperties() {
096: Map result = new HashMap();
097: new PropertyHolder("title", "someTitle").addToMap(result);
098: new PropertyHolder("cssClass", "cssClass1",
099: "class=\"cssClass1\"").addToMap(result);
100: new PropertyHolder("cssStyle", "cssStyle1",
101: "style=\"cssStyle1\"").addToMap(result);
102: new PropertyHolder("name", "someName").addToMap(result);
103: new PropertyHolder("value", "someValue").addToMap(result);
104: return result;
105: }
106:
107: public void testGenericSimple() throws Exception {
108: ResetTag tag = new ResetTag();
109: verifyGenericProperties(tag, "simple", null);
110: }
111:
112: public void testGenericXhtml() throws Exception {
113: ResetTag tag = new ResetTag();
114: verifyGenericProperties(tag, "xhtml", null);
115: }
116:
117: public void testGenericAjax() throws Exception {
118: ResetTag tag = new ResetTag();
119: verifyGenericProperties(tag, "ajax", null);
120: }
121:
122: }
|