Methods Summary |
---|
protected void | setUp()
super.setUp();
// create the needed objects
elseTag = new ElseTag();
stack = ValueStackFactory.getFactory().createValueStack();
// create the mock http servlet request
StrutsMockHttpServletRequest request = new StrutsMockHttpServletRequest();
// NOTE: in Struts Tag library, TagUtil gets stack from request, which will be set
// when request going through the FilterDispatcher --> DispatcherUtil etc. route
request.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, stack);
StrutsMockServletContext servletContext = new StrutsMockServletContext();
servletContext.setServletInfo("not-weblogic");
// create the mock page context
pageContext = new StrutsMockPageContext();
pageContext.setRequest(request);
pageContext.setServletContext(servletContext);
pageContext.setJspWriter(new MockJspWriter());
|
public void | testTestFalse()
stack.getContext().put(If.ANSWER, new Boolean(false));
int result = 0;
try {
elseTag.setPageContext(pageContext);
result = elseTag.doStartTag();
elseTag.doEndTag();
} catch (JspException e) {
e.printStackTrace();
fail();
}
assertEquals(TagSupport.EVAL_BODY_INCLUDE, result);
|
public void | testTestNull()
elseTag.setPageContext(pageContext);
int result = 0;
try {
result = elseTag.doStartTag();
} catch (JspException e) {
e.printStackTrace();
fail();
}
assertEquals(TagSupport.SKIP_BODY, result);
|
public void | testTestTrue()
stack.getContext().put(If.ANSWER, new Boolean(true));
elseTag.setPageContext(pageContext);
int result = 0;
try {
result = elseTag.doStartTag();
} catch (JspException e) {
e.printStackTrace();
fail();
}
assertEquals(TagSupport.SKIP_BODY, result);
|