001: /*
002: * Copyright (c) 2002-2003 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.Map;
011: import java.util.HashMap;
012:
013: /**
014: * @author Matt Ho <a href="mailto:matt@enginegreen.com"><matt@enginegreen.com></a>
015: * @version $Id: LabelTest.java 2098 2006-02-03 13:14:46Z rgielen $
016: */
017: public class LabelTest extends AbstractUITagTest {
018:
019: public void testSimple() throws Exception {
020: TestAction testAction = (TestAction) action;
021: testAction.setFoo("bar");
022:
023: LabelTag tag = new LabelTag();
024: tag.setPageContext(pageContext);
025: tag.setLabel("mylabel");
026: tag.setName("myname");
027: tag.setTitle("mytitle");
028: tag.setValue("%{foo}");
029:
030: tag.doStartTag();
031: tag.doEndTag();
032:
033: verify(LabelTest.class.getResource("Label-1.txt"));
034: }
035:
036: public void testSimpleWithLabelposition() throws Exception {
037: TestAction testAction = (TestAction) action;
038: testAction.setFoo("bar");
039:
040: LabelTag tag = new LabelTag();
041: tag.setPageContext(pageContext);
042: tag.setLabel("mylabel");
043: tag.setName("myname");
044: tag.setValue("%{foo}");
045: tag.setLabelPosition("top");
046:
047: tag.doStartTag();
048: tag.doEndTag();
049:
050: verify(LabelTest.class.getResource("Label-3.txt"));
051: }
052:
053: /**
054: * Initialize a map of {@link com.opensymphony.webwork.views.jsp.AbstractUITagTest.PropertyHolder} for generic tag
055: * property testing. Will be used when calling {@link #verifyGenericProperties(com.opensymphony.webwork.views.jsp.ui.AbstractUITag,
056: * String, String[])} as properties to verify.<p/> This implementation extends testdata from AbstractUITag.
057: *
058: * @return A Map of PropertyHolders values bound to {@link com.opensymphony.webwork.views.jsp.AbstractUITagTest.PropertyHolder#getName()}
059: * as key.
060: */
061: protected Map initializedGenericTagTestProperties() {
062: Map result = new HashMap();
063: new PropertyHolder("title", "someTitle").addToMap(result);
064: new PropertyHolder("cssClass", "cssClass1",
065: "class=\"cssClass1\"").addToMap(result);
066: new PropertyHolder("cssStyle", "cssStyle1",
067: "style=\"cssStyle1\"").addToMap(result);
068: new PropertyHolder("id", "someId").addToMap(result);
069: new PropertyHolder("for", "someFor").addToMap(result);
070: return result;
071: }
072:
073: public void testWithNoValue() throws Exception {
074: TestAction testAction = (TestAction) action;
075: testAction.setFoo("baz");
076:
077: LabelTag tag = new LabelTag();
078: tag.setPageContext(pageContext);
079: tag.setLabel("mylabel");
080: tag.setName("foo");
081: tag.setFor("for");
082:
083: tag.doStartTag();
084: tag.doEndTag();
085:
086: verify(LabelTest.class.getResource("Label-2.txt"));
087: }
088:
089: public void testGenericSimple() throws Exception {
090: LabelTag tag = new LabelTag();
091: verifyGenericProperties(tag, "simple", null);
092: }
093:
094: public void testGenericXhtml() throws Exception {
095: LabelTag tag = new LabelTag();
096: verifyGenericProperties(tag, "xhtml", null);
097: }
098:
099: public void testGenericAjax() throws Exception {
100: LabelTag tag = new LabelTag();
101: verifyGenericProperties(tag, "ajax", null);
102: }
103:
104: }
|