001: package com.mockrunner.test.web;
002:
003: import java.io.IOException;
004:
005: import javax.servlet.jsp.JspException;
006: import javax.servlet.jsp.PageContext;
007: import javax.servlet.jsp.tagext.BodyTagSupport;
008: import javax.servlet.jsp.tagext.TagSupport;
009:
010: public class TestTag extends TagSupport {
011: private String testString;
012: private Integer testInteger;
013: private double testDouble;
014: private boolean releaseCalled = false;
015: private boolean releaseLastCall = false;
016: private PageContext context;
017: private int doStartTagReturnValue = TagSupport.EVAL_BODY_INCLUDE;
018: private int doEndTagReturnValue = TagSupport.EVAL_PAGE;
019: private int doAfterBodyReturnValue = TagSupport.SKIP_BODY;
020: private boolean doStartTagCalled = false;
021: private boolean doEndTagCalled = false;
022: private boolean doAfterBodyCalled = false;
023:
024: public void setDoAfterBodyReturnValue(int doAfterBodyReturnValue) {
025: this .doAfterBodyReturnValue = doAfterBodyReturnValue;
026: }
027:
028: public void setDoEndTagReturnValue(int doEndTagReturnValue) {
029: this .doEndTagReturnValue = doEndTagReturnValue;
030: }
031:
032: public void setDoStartTagReturnValue(int doStartTagReturnValue) {
033: this .doStartTagReturnValue = doStartTagReturnValue;
034: }
035:
036: public int doStartTag() throws JspException {
037: doStartTagCalled = true;
038: try {
039: pageContext.getOut().print("TestTag");
040: } catch (IOException exc) {
041: throw new RuntimeException(exc.getMessage());
042: }
043: return doStartTagReturnValue;
044: }
045:
046: public int doAfterBody() throws JspException {
047: doAfterBodyCalled = true;
048: int returnValue = doAfterBodyReturnValue;
049: if (BodyTagSupport.EVAL_BODY_AGAIN == doAfterBodyReturnValue) {
050: doAfterBodyReturnValue = BodyTagSupport.SKIP_BODY;
051: }
052: return returnValue;
053: }
054:
055: public int doEndTag() throws JspException {
056: doEndTagCalled = true;
057: return doEndTagReturnValue;
058: }
059:
060: public double getTestDouble() {
061: return testDouble;
062: }
063:
064: public Integer getTestInteger() {
065: return testInteger;
066: }
067:
068: public String getTestString() {
069: return testString;
070: }
071:
072: public void setTestDouble(double testDouble) {
073: this .testDouble = testDouble;
074: }
075:
076: public void setTestInteger(Integer testInteger) {
077: this .testInteger = testInteger;
078: }
079:
080: public void setTestString(String testString) {
081: this .testString = testString;
082: }
083:
084: public void release() {
085: if (wasDoStartTagCalled() && wasDoEndTagCalled()) {
086: releaseLastCall = true;
087: }
088: releaseCalled = true;
089: }
090:
091: public boolean wasReleaseCalled() {
092: return releaseCalled;
093: }
094:
095: public boolean wasReleaseCallLastMethodCall() {
096: return releaseLastCall;
097: }
098:
099: public boolean wasDoAfterBodyCalled() {
100: return doAfterBodyCalled;
101: }
102:
103: public boolean wasDoEndTagCalled() {
104: return doEndTagCalled;
105: }
106:
107: public boolean wasDoStartTagCalled() {
108: return doStartTagCalled;
109: }
110:
111: public void setPageContext(PageContext context) {
112: super .setPageContext(context);
113: this .context = context;
114: }
115:
116: public PageContext getPageContext() {
117: return context;
118: }
119: }
|