mirror of
https://github.com/apache/struts.git
synced 2026-08-07 15:46:57 +00:00
Merge pull request #501 from JCgH4164838Gh792C124B5/localS2_26_WW-5124_fix
WW-5124 - Proposed fix for Struts JSP tag behaviour with tag pooling (re-target to 2.6.x)
This commit is contained in:
@@ -72,6 +72,7 @@ public class Component {
|
||||
protected Map<String, Object> parameters;
|
||||
protected ActionMapper actionMapper;
|
||||
protected boolean throwExceptionOnELFailure;
|
||||
protected boolean performClearTagStateForTagPoolingServers = false;
|
||||
private UrlHelper urlHelper;
|
||||
|
||||
private NotExcludedAcceptedPatternsChecker notExcludedAcceptedPatterns;
|
||||
@@ -568,6 +569,27 @@ public class Component {
|
||||
return standardAttributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request that the tag state be cleared during {@link org.apache.struts2.views.jsp.StrutsBodyTagSupport#doEndTag()} processing,
|
||||
* which may help with certain edge cases with tag logic running on servers that implement JSP Tag Pooling.
|
||||
*
|
||||
* <em>Note:</em> All Tag classes that extend {@link org.apache.struts2.views.jsp.StrutsBodyTagSupport} must implement a setter for
|
||||
* this attribute (same name), and it must be defined at the Tag class level.
|
||||
* Defining a setter in the superclass alone is insufficient (results in "Cannot find a setter method for the attribute").
|
||||
*
|
||||
* See {@link org.apache.struts2.views.jsp.StrutsBodyTagSupport#clearTagStateForTagPoolingServers() for additional details.
|
||||
*
|
||||
* @param performClearTagStateForTagPoolingServers true if tag state should be cleared, false otherwise.
|
||||
*/
|
||||
@StrutsTagAttribute(description="Whether to clear all tag state during doEndTag() processing (if applicable)", type="Boolean", defaultValue="false", required = false)
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
this.performClearTagStateForTagPoolingServers = performClearTagStateForTagPoolingServers;
|
||||
}
|
||||
|
||||
public boolean getPerformClearTagStateForTagPoolingServers() {
|
||||
return this.performClearTagStateForTagPoolingServers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if expression doesn't contain vulnerable code
|
||||
*
|
||||
|
||||
@@ -251,4 +251,15 @@ public class PrepareOperations {
|
||||
return devModeOverride.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear any override of the static devMode value being applied to the current thread.
|
||||
*
|
||||
* This can be useful for any situation where {@link #overrideDevMode(boolean)} might be called
|
||||
* in a flow where {@link #cleanupRequest(javax.servlet.http.HttpServletRequest)} does not get called.
|
||||
* May be very situational (such as some unit tests), but may have other utility as well.
|
||||
*/
|
||||
public static void clearDevModeOverride() {
|
||||
devModeOverride.remove(); // Remove current thread's value, enxure next read returns it to initialValue (typically null).
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,10 +39,12 @@ public class ActionTag extends ContextBeanTag {
|
||||
protected boolean flush = true;
|
||||
protected boolean rethrowException;
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new ActionComponent(stack, req, res);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
|
||||
@@ -88,4 +90,26 @@ public class ActionTag extends ContextBeanTag {
|
||||
this.rethrowException = rethrowException;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.name = null;
|
||||
this.namespace = null;
|
||||
this.executeResult = false;
|
||||
this.ignoreContextParams = false;
|
||||
this.flush = true;
|
||||
this.rethrowException = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,10 +39,12 @@ public class BeanTag extends ContextBeanTag {
|
||||
|
||||
protected String name;
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new Bean(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
|
||||
@@ -52,4 +54,22 @@ public class BeanTag extends ContextBeanTag {
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.name = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -35,12 +35,15 @@ public abstract class ComponentTagSupport extends StrutsBodyTagSupport {
|
||||
|
||||
public abstract Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res);
|
||||
|
||||
@Override
|
||||
public int doEndTag() throws JspException {
|
||||
component.end(pageContext.getOut(), getBody());
|
||||
component = null;
|
||||
component = null; // Always clear component reference (since clearTagStateForTagPoolingServers() is conditional).
|
||||
clearTagStateForTagPoolingServers();
|
||||
return EVAL_PAGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int doStartTag() throws JspException {
|
||||
ValueStack stack = getStack();
|
||||
component = getBean(stack, (HttpServletRequest) pageContext.getRequest(), (HttpServletResponse) pageContext.getResponse());
|
||||
@@ -57,10 +60,39 @@ public abstract class ComponentTagSupport extends StrutsBodyTagSupport {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Define method to populate component state based on the Tag parameters.
|
||||
*
|
||||
* Descendants should override this method for custom behaviour, but should <em>always</em> call the ancestor method when doing so.
|
||||
*/
|
||||
protected void populateParams() {
|
||||
populatePerformClearTagStateForTagPoolingServersParam();
|
||||
}
|
||||
|
||||
/**
|
||||
* Specialized method to populate the performClearTagStateForTagPoolingServers state of the Component to match the value set in the Tag.
|
||||
*
|
||||
* Generally only unit tests would call this method directly, to avoid calling the whole populateParams() chain again after doStartTag()
|
||||
* has been called. Doing that can break tag / component state behaviour, but unit tests still need a way to set the
|
||||
* performClearTagStateForTagPoolingServers state for the component (which only comes into being after doStartTag() is called).
|
||||
*/
|
||||
protected void populatePerformClearTagStateForTagPoolingServersParam() {
|
||||
if (component != null) {
|
||||
component.setPerformClearTagStateForTagPoolingServers(super.getPerformClearTagStateForTagPoolingServers());
|
||||
}
|
||||
}
|
||||
|
||||
public Component getComponent() {
|
||||
return component;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
component = null; // Duplicate clear, kept for consistency.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.apache.struts2.components.ContextBean;
|
||||
public abstract class ContextBeanTag extends ComponentTagSupport {
|
||||
private String var;
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
|
||||
@@ -34,4 +35,22 @@ public abstract class ContextBeanTag extends ComponentTagSupport {
|
||||
public void setVar(String var) {
|
||||
this.var = var;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.var = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,10 +37,12 @@ public class DateTag extends ContextBeanTag {
|
||||
protected boolean nice;
|
||||
protected String timezone;
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new Date(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
Date d = (Date)component;
|
||||
@@ -66,4 +68,24 @@ public class DateTag extends ContextBeanTag {
|
||||
this.timezone = timezone;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.name = null;
|
||||
this.format = null;
|
||||
this.nice = false;
|
||||
this.timezone = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -35,15 +35,36 @@ public class ElseIfTag extends ComponentTagSupport {
|
||||
|
||||
protected String test;
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new ElseIf(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
((ElseIf) getComponent()).setTest(test);
|
||||
}
|
||||
|
||||
public void setTest(String test) {
|
||||
this.test = test;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.test = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,7 +33,16 @@ public class ElseTag extends ComponentTagSupport {
|
||||
|
||||
private static final long serialVersionUID = 8166807953193406785L;
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new Else(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,10 +35,12 @@ public class I18nTag extends ComponentTagSupport {
|
||||
|
||||
protected String name;
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new I18n(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
|
||||
@@ -48,4 +50,22 @@ public class I18nTag extends ComponentTagSupport {
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.name = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -35,15 +35,36 @@ public class IfTag extends ComponentTagSupport {
|
||||
|
||||
String test;
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new If(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
((If) getComponent()).setTest(test);
|
||||
}
|
||||
|
||||
public void setTest(String test) {
|
||||
this.test = test;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.test = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -35,10 +35,12 @@ public class IncludeTag extends ComponentTagSupport {
|
||||
|
||||
protected String value;
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new Include(stack, req, res);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
|
||||
@@ -48,4 +50,22 @@ public class IncludeTag extends ComponentTagSupport {
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.value = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,10 +39,12 @@ public class IteratorTag extends ContextBeanTag {
|
||||
protected String end;
|
||||
protected String step;
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new IteratorComponent(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
|
||||
@@ -74,11 +76,14 @@ public class IteratorTag extends ContextBeanTag {
|
||||
this.step = step;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int doEndTag() throws JspException {
|
||||
component = null;
|
||||
clearTagStateForTagPoolingServers();
|
||||
return EVAL_PAGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int doAfterBody() throws JspException {
|
||||
boolean again = component.end(pageContext.getOut(), getBody());
|
||||
|
||||
@@ -96,4 +101,25 @@ public class IteratorTag extends ContextBeanTag {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.statusAttr = null;
|
||||
this.value = null;
|
||||
this.begin = null;
|
||||
this.end = null;
|
||||
this.step = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -43,10 +43,12 @@ public class NumberTag extends ContextBeanTag {
|
||||
private Boolean parseIntegerOnly;
|
||||
private String roundingMode;
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new Number(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
Number n = (Number) component;
|
||||
@@ -133,4 +135,30 @@ public class NumberTag extends ContextBeanTag {
|
||||
this.roundingMode = roundingMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.name = null;
|
||||
this.currency = null;
|
||||
this.type = null;
|
||||
this.groupingUsed = null;
|
||||
this.maximumFractionDigits = null;
|
||||
this.maximumIntegerDigits = null;
|
||||
this.minimumFractionDigits = null;
|
||||
this.minimumIntegerDigits = null;
|
||||
this.parseIntegerOnly = null;
|
||||
this.roundingMode = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,10 +36,12 @@ public class ParamTag extends ComponentTagSupport {
|
||||
protected String value;
|
||||
protected boolean suppressEmptyParameters;
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new Param(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
|
||||
@@ -60,4 +62,24 @@ public class ParamTag extends ComponentTagSupport {
|
||||
public void setSuppressEmptyParameters(boolean suppressEmptyParameters) {
|
||||
this.suppressEmptyParameters = suppressEmptyParameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.name = null;
|
||||
this.value = null;
|
||||
this.suppressEmptyParameters = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -40,10 +40,12 @@ public class PropertyTag extends ComponentTagSupport {
|
||||
private boolean escapeXml = false;
|
||||
private boolean escapeCsv = false;
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new Property(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
|
||||
@@ -83,4 +85,27 @@ public class PropertyTag extends ComponentTagSupport {
|
||||
public void setEscapeXml(boolean escapeXml) {
|
||||
this.escapeXml = escapeXml;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.defaultValue = null;
|
||||
this.value = null;
|
||||
this.escapeHtml = true;
|
||||
this.escapeJavaScript = false;
|
||||
this.escapeXml = false;
|
||||
this.escapeCsv = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -35,10 +35,12 @@ public class PushTag extends ComponentTagSupport {
|
||||
|
||||
protected String value;
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new Push(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
|
||||
@@ -48,4 +50,22 @@ public class PushTag extends ComponentTagSupport {
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.value = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,10 +37,12 @@ public class SetTag extends ContextBeanTag {
|
||||
protected String value;
|
||||
protected boolean trimBody = true;
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new Set(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
|
||||
@@ -77,4 +79,24 @@ public class SetTag extends ContextBeanTag {
|
||||
return (bodyContent == null ? null : bodyContent.getString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.scope = null;
|
||||
this.value = null;
|
||||
this.trimBody = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,11 +20,12 @@ package org.apache.struts2.views.jsp;
|
||||
|
||||
import com.opensymphony.xwork2.util.TextParseUtil;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import java.io.PrintWriter;
|
||||
import javax.servlet.jsp.JspException;
|
||||
import javax.servlet.jsp.tagext.BodyTagSupport;
|
||||
import org.apache.struts2.util.ComponentUtils;
|
||||
import org.apache.struts2.util.FastByteArrayOutputStream;
|
||||
|
||||
import javax.servlet.jsp.tagext.BodyTagSupport;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
/**
|
||||
* Contains common functonalities for Struts JSP Tags.
|
||||
@@ -33,6 +34,8 @@ public class StrutsBodyTagSupport extends BodyTagSupport {
|
||||
|
||||
private static final long serialVersionUID = -1201668454354226175L;
|
||||
|
||||
private boolean performClearTagStateForTagPoolingServers = false;
|
||||
|
||||
protected ValueStack getStack() {
|
||||
return TagUtils.getStack(pageContext);
|
||||
}
|
||||
@@ -72,4 +75,97 @@ public class StrutsBodyTagSupport extends BodyTagSupport {
|
||||
return bodyContent.getString().trim();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int doEndTag() throws JspException {
|
||||
clearTagStateForTagPoolingServers();
|
||||
return super.doEndTag();
|
||||
}
|
||||
|
||||
/**
|
||||
* Release state for a Struts JSP Tag handler.
|
||||
*
|
||||
* According to the JSP API documentation, the page compiler guarantees that the release() method
|
||||
* will be invoked on the Tag handler before releasing it to the GC (garbage collector). It does
|
||||
* not specify <em>when</em> the release() call will be made, though, and timing likely depends
|
||||
* on the implementation of the JSP/servlet engine being used.
|
||||
*/
|
||||
@Override
|
||||
public void release() {
|
||||
// Ensure release() performs the clearTagStateForTagPoolingServers tag state clearing processing with
|
||||
// the clear state flag forced to true (if not already set to true), to ensure cleanup.
|
||||
// The performClearTagStateForTagPoolingServers flag state is preserved for consistency, in case
|
||||
// release() is called by framework code.
|
||||
final boolean originalPerformClearTagState = getPerformClearTagStateForTagPoolingServers();
|
||||
if (originalPerformClearTagState == true) {
|
||||
clearTagStateForTagPoolingServers();
|
||||
} else {
|
||||
setPerformClearTagStateForTagPoolingServers(true);
|
||||
clearTagStateForTagPoolingServers();
|
||||
setPerformClearTagStateForTagPoolingServers(originalPerformClearTagState);
|
||||
}
|
||||
super.release();
|
||||
}
|
||||
|
||||
/**
|
||||
* Request that the tag state be cleared during {@link StrutsBodyTagSupport#doEndTag()} processing,
|
||||
* which may help with certain edge cases with tag logic running on servers that implement JSP Tag Pooling.
|
||||
*
|
||||
* <em>Note:</em> Even though the Tag classes extend this class {@link StrutsBodyTagSupport}, and this method
|
||||
* {@link StrutsBodyTagSupport#setPerformClearTagStateForTagPoolingServers(boolean)} exists in the method hierarchy,
|
||||
* the JSP processing requires us to explicitly override it in <em>every Tag class<em> in order for the Tag handler
|
||||
* method to be visible to the JSP processing.
|
||||
* Defining a setter in the superclass alone is insufficient (results in "Cannot find a setter method for the attribute").
|
||||
*
|
||||
* See {@link StrutsBodyTagSupport#clearTagStateForTagPoolingServers()} for additional details.
|
||||
*
|
||||
* <em>Warning:</em> Setting this value to true may allow for the desired behaviour, but doing so
|
||||
* may violate the JSP specification. <em>Set to true at your own risk</em>.
|
||||
*
|
||||
* @param performClearTagStateForTagPoolingServers true if tag state should be cleared, false otherwise.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
this.performClearTagStateForTagPoolingServers = performClearTagStateForTagPoolingServers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow descendant tags to check if the tag state should be cleared during {@link StrutsBodyTagSupport#doEndTag()} processing,
|
||||
*
|
||||
* @return true if tag state should be cleared, false (default) otherwise.
|
||||
*/
|
||||
protected boolean getPerformClearTagStateForTagPoolingServers() {
|
||||
return this.performClearTagStateForTagPoolingServers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a mechanism to clear tag state, to handle servlet container JSP tag pooling
|
||||
* behaviour with some servers, such as Glassfish.
|
||||
*
|
||||
* Usage: Override this method in descendant classes to clear any state that might cause issues should the
|
||||
* servlet container re-use a cached instance of the tag object. If the descendant class does not
|
||||
* declare any new field members then it should not be strictly necessary to call this method there.
|
||||
* Typically that means calling the ancestor's {@link ComponentTagSupport#clearTagStateForTagPoolingServers()}
|
||||
* method first, then resetting instance variables at the current level to their default state.
|
||||
*
|
||||
* Note: If the descendant overrides {@link StrutsBodyTagSupport#doEndTag()}, and does not call
|
||||
* super.doEndTag(), then the descendant should call this method in the descendant doEndTag() method
|
||||
* to ensure consistent clearing of tag state.
|
||||
*/
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
// Default implementation.
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
this.setBodyContent(null); // Always clear the tag body (if any) after tag completion.
|
||||
this.setId(null); // Always clear the tag id (if any) after tag completion.
|
||||
// Note: The pageContext and parent Tag state are NOT cleared, only the "user-defined" tag state should be cleared.
|
||||
// Calling setPageContext(null) and setParent(null) appears too dangerous to consider, and the container
|
||||
// should always set them, even if a tag instance from a pool is re-used. Also, clearing those two
|
||||
// values likely violates the JSP specification.
|
||||
// Note: We intentionally do NOT reset performClearTagStateForTagPoolingServers to false here, for two reasons.
|
||||
// Firstly, if a tag pool re-uses the instance, in order to qualify/match the tag parameters should be
|
||||
// the same, including performClearTagStateForTagPoolingServers. Secondly, if we change the state of
|
||||
// the control flag during clearing, it makes unit testing virtually impossible.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,10 +39,12 @@ public class TextTag extends ContextBeanTag {
|
||||
private boolean escapeXml = false;
|
||||
private boolean escapeCsv = false;
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new Text(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
|
||||
@@ -74,4 +76,25 @@ public class TextTag extends ContextBeanTag {
|
||||
this.escapeCsv = escapeCsv;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.name = null;
|
||||
this.escapeHtml = false;
|
||||
this.escapeJavaScript = false;
|
||||
this.escapeXml = false;
|
||||
this.escapeCsv = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -48,10 +48,12 @@ public class URLTag extends ContextBeanTag {
|
||||
protected String anchor;
|
||||
protected String forceAddSchemeHostAndPort;
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new URL(stack, req, res);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
|
||||
@@ -136,4 +138,35 @@ public class URLTag extends ContextBeanTag {
|
||||
public void setForceAddSchemeHostAndPort(String forceAddSchemeHostAndPort) {
|
||||
this.forceAddSchemeHostAndPort = forceAddSchemeHostAndPort;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.includeParams = null;
|
||||
this.scheme = null;
|
||||
this.value = null;
|
||||
this.action = null;
|
||||
this.namespace = null;
|
||||
this.method = null;
|
||||
this.encode = null;
|
||||
this.includeContext = null;
|
||||
this.escapeAmp = null;
|
||||
this.portletMode = null;
|
||||
this.windowState = null;
|
||||
this.portletUrlType = null;
|
||||
this.anchor = null;
|
||||
this.forceAddSchemeHostAndPort = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,8 +37,16 @@ public class AppendIteratorTag extends ContextBeanTag {
|
||||
|
||||
private static final long serialVersionUID = -6017337859763283691L;
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new AppendIterator(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,6 +176,13 @@ public class IteratorGeneratorTag extends StrutsBodyTagSupport {
|
||||
this.var = var;
|
||||
}
|
||||
|
||||
@StrutsTagAttribute(description="Whether to clear all tag state during doEndTag() processing", type="Boolean", defaultValue="false", required = false)
|
||||
@Override
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int doStartTag() throws JspException {
|
||||
|
||||
// value
|
||||
@@ -230,11 +237,27 @@ public class IteratorGeneratorTag extends StrutsBodyTagSupport {
|
||||
return EVAL_BODY_INCLUDE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int doEndTag() throws JspException {
|
||||
// pop resulting iterator from stack at end tag
|
||||
getStack().pop();
|
||||
iteratorGenerator = null; // clean up
|
||||
clearTagStateForTagPoolingServers(); // Clean-up, including iteratorGenerator reference.
|
||||
|
||||
return EVAL_PAGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.countAttr = null;
|
||||
this.separatorAttr = null;
|
||||
this.valueAttr = null;
|
||||
this.converterAttr = null;
|
||||
this.var = null;
|
||||
this.iteratorGenerator = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,8 +38,17 @@ public class MergeIteratorTag extends ContextBeanTag {
|
||||
|
||||
private static final long serialVersionUID = 4999729472466011218L;
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new MergeIterator(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -110,6 +110,13 @@ public class SortIteratorTag extends StrutsBodyTagSupport {
|
||||
this.var = var;
|
||||
}
|
||||
|
||||
@StrutsTagAttribute(description="Whether to clear all tag state during doEndTag() processing", type="Boolean", defaultValue="false", required = false)
|
||||
@Override
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int doStartTag() throws JspException {
|
||||
// Source
|
||||
Object srcToSort;
|
||||
@@ -144,13 +151,28 @@ public class SortIteratorTag extends StrutsBodyTagSupport {
|
||||
return EVAL_BODY_INCLUDE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int doEndTag() throws JspException {
|
||||
int returnVal = super.doEndTag();
|
||||
|
||||
// pop sorted list from stack at the end of tag
|
||||
getStack().pop();
|
||||
sortIteratorFilter = null;
|
||||
// The super.doEndTag() above should ensure clearTagStateForTagPoolingServers() is called correctly,
|
||||
// which should clean-up the sortIteratorFilter reference.
|
||||
|
||||
return returnVal;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.comparatorAttr = null;
|
||||
this.sourceAttr = null;
|
||||
this.var = null;
|
||||
this.sortIteratorFilter = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,6 +193,13 @@ public class SubsetIteratorTag extends StrutsBodyTagSupport {
|
||||
this.var = var;
|
||||
}
|
||||
|
||||
@StrutsTagAttribute(description="Whether to clear all tag state during doEndTag() processing", type="Boolean", defaultValue="false", required = false)
|
||||
@Override
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int doStartTag() throws JspException {
|
||||
|
||||
// source
|
||||
@@ -272,12 +279,27 @@ public class SubsetIteratorTag extends StrutsBodyTagSupport {
|
||||
return EVAL_BODY_INCLUDE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int doEndTag() throws JspException {
|
||||
|
||||
// pop resulting subset iterator from stack at end tag
|
||||
getStack().pop();
|
||||
|
||||
subsetIteratorFilter = null;
|
||||
clearTagStateForTagPoolingServers(); // Clean-up, including subsetIteratorFilter reference.
|
||||
|
||||
return EVAL_PAGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.countAttr = null;
|
||||
this.sourceAttr = null;
|
||||
this.startAttr = null;
|
||||
this.deciderAttr = null;
|
||||
this.var = null;
|
||||
this.subsetIteratorFilter = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.apache.struts2.components.ClosingUIBean;
|
||||
public abstract class AbstractClosingTag extends AbstractUITag {
|
||||
protected String openTemplate;
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
|
||||
@@ -32,4 +33,22 @@ public abstract class AbstractClosingTag extends AbstractUITag {
|
||||
public void setOpenTemplate(String openTemplate) {
|
||||
this.openTemplate = openTemplate;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.openTemplate = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ public abstract class AbstractDoubleListTag extends AbstractRequiredListTag {
|
||||
|
||||
protected String doubleAccesskey;
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
|
||||
@@ -382,4 +383,59 @@ public abstract class AbstractDoubleListTag extends AbstractRequiredListTag {
|
||||
public void setDoubleAccesskey(String doubleAccesskey) {
|
||||
this.doubleAccesskey = doubleAccesskey;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.doubleList = null;
|
||||
this.doubleListKey = null;
|
||||
this.doubleListValue = null;
|
||||
this.doubleListCssClass = null;
|
||||
this.doubleListCssStyle = null;
|
||||
this.doubleListTitle = null;
|
||||
this.doubleName = null;
|
||||
this.doubleValue = null;
|
||||
this.formName = null;
|
||||
this.emptyOption = null;
|
||||
this.headerKey = null;
|
||||
this.headerValue = null;
|
||||
this.multiple = null;
|
||||
this.size = null;
|
||||
this.doubleId = null;
|
||||
this.doubleDisabled = null;
|
||||
this.doubleMultiple = null;
|
||||
this.doubleSize = null;
|
||||
this.doubleHeaderKey = null;
|
||||
this.doubleHeaderValue = null;
|
||||
this.doubleEmptyOption = null;
|
||||
this.doubleCssClass = null;
|
||||
this.doubleCssStyle = null;
|
||||
this.doubleOnclick = null;
|
||||
this.doubleOndblclick = null;
|
||||
this.doubleOnmousedown = null;
|
||||
this.doubleOnmouseup = null;
|
||||
this.doubleOnmouseover = null;
|
||||
this.doubleOnmousemove = null;
|
||||
this.doubleOnmouseout = null;
|
||||
this.doubleOnfocus = null;
|
||||
this.doubleOnblur = null;
|
||||
this.doubleOnkeypress = null;
|
||||
this.doubleOnkeydown = null;
|
||||
this.doubleOnkeyup = null;
|
||||
this.doubleOnselect = null;
|
||||
this.doubleOnchange = null;
|
||||
this.doubleAccesskey = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ public abstract class AbstractListTag extends AbstractUITag {
|
||||
protected String listCssStyle;
|
||||
protected String listTitle;
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
|
||||
@@ -75,4 +76,29 @@ public abstract class AbstractListTag extends AbstractUITag {
|
||||
public void setListTitle(String listTitle) {
|
||||
this.listTitle = listTitle;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.list = null;
|
||||
this.listKey = null;
|
||||
this.listValue = null;
|
||||
this.listValueKey = null;
|
||||
this.listLabelKey = null;
|
||||
this.listCssClass = null;
|
||||
this.listCssStyle = null;
|
||||
this.listTitle = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.apache.struts2.components.ListUIBean;
|
||||
|
||||
public abstract class AbstractRequiredListTag extends AbstractListTag {
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
|
||||
@@ -29,4 +30,11 @@ public abstract class AbstractRequiredListTag extends AbstractListTag {
|
||||
listUIBean.setThrowExceptionOnNullValueAttribute(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,6 +78,7 @@ public abstract class AbstractUITag extends ComponentTagSupport implements Dynam
|
||||
// dynamic attributes.
|
||||
protected Map<String, String> dynamicAttributes = new HashMap<>();
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
|
||||
@@ -127,6 +128,7 @@ public abstract class AbstractUITag extends ComponentTagSupport implements Dynam
|
||||
uiBean.setDynamicAttributes(dynamicAttributes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
@@ -312,8 +314,67 @@ public abstract class AbstractUITag extends ComponentTagSupport implements Dynam
|
||||
this.labelSeparator = labelSeparator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDynamicAttribute(String uri, String localName, Object value) throws JspException {
|
||||
dynamicAttributes.put(localName, String.valueOf(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.cssClass = null;
|
||||
this.cssErrorClass = null;
|
||||
this.cssStyle = null;
|
||||
this.cssErrorStyle = null;
|
||||
this.title = null;
|
||||
this.disabled = null;
|
||||
this.label = null;
|
||||
this.labelSeparator = null;
|
||||
this.labelPosition = null;
|
||||
this.requiredPosition = null;
|
||||
this.errorPosition = null;
|
||||
this.name = null;
|
||||
this.requiredLabel = null;
|
||||
this.tabindex = null;
|
||||
this.value = null;
|
||||
this.template = null;
|
||||
this.theme = null;
|
||||
this.templateDir = null;
|
||||
this.onclick = null;
|
||||
this.ondblclick = null;
|
||||
this.onmousedown = null;
|
||||
this.onmouseup = null;
|
||||
this.onmouseover = null;
|
||||
this.onmousemove = null;
|
||||
this.onmouseout = null;
|
||||
this.onfocus = null;
|
||||
this.onblur = null;
|
||||
this.onkeypress = null;
|
||||
this.onkeydown = null;
|
||||
this.onkeyup = null;
|
||||
this.onselect = null;
|
||||
this.onchange = null;
|
||||
this.accesskey = null;
|
||||
this.id = null;
|
||||
this.key = null;
|
||||
this.tooltip = null;
|
||||
this.tooltipConfig = null;
|
||||
this.javascriptTooltip = null;
|
||||
this.tooltipDelay = null;
|
||||
this.tooltipCssClass = null;
|
||||
this.tooltipIconPath = null;
|
||||
this.dynamicAttributes.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,10 +36,12 @@ public class ActionErrorTag extends AbstractUITag {
|
||||
|
||||
private boolean escape = true;
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new ActionError(stack, req, res);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
|
||||
@@ -50,4 +52,22 @@ public class ActionErrorTag extends AbstractUITag {
|
||||
public void setEscape(boolean escape) {
|
||||
this.escape = escape;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.escape = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.struts2.components.ActionMessage;
|
||||
import org.apache.struts2.components.Component;
|
||||
import org.apache.struts2.components.ActionError;
|
||||
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
|
||||
@@ -37,10 +36,12 @@ public class ActionMessageTag extends AbstractUITag {
|
||||
|
||||
private boolean escape = true;
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new ActionMessage(stack, req, res);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
|
||||
@@ -51,4 +52,22 @@ public class ActionMessageTag extends AbstractUITag {
|
||||
public void setEscape(boolean escape) {
|
||||
this.escape = escape;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.escape = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -49,10 +49,12 @@ public class AnchorTag extends AbstractClosingTag {
|
||||
protected String forceAddSchemeHostAndPort;
|
||||
protected boolean escapeHtmlBody = true; // Default - escape HTML body
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new Anchor(stack, req, res);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
|
||||
@@ -120,6 +122,7 @@ public class AnchorTag extends AbstractClosingTag {
|
||||
this.scheme = scheme;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
@@ -154,6 +157,36 @@ public class AnchorTag extends AbstractClosingTag {
|
||||
public void setEscapeHtmlBody(boolean escapeHtmlBody) {
|
||||
this.escapeHtmlBody = escapeHtmlBody;
|
||||
}
|
||||
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
@Override
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.href = null;
|
||||
this.includeParams = null;
|
||||
this.scheme = null;
|
||||
this.action = null;
|
||||
this.namespace = null;
|
||||
this.method = null;
|
||||
this.encode = null;
|
||||
this.includeContext = null;
|
||||
this.escapeAmp = null;
|
||||
this.portletMode = null;
|
||||
this.windowState = null;
|
||||
this.portletUrlType = null;
|
||||
this.anchor = null;
|
||||
this.forceAddSchemeHostAndPort = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -33,7 +33,16 @@ public class CheckboxListTag extends AbstractRequiredListTag {
|
||||
|
||||
private static final long serialVersionUID = 4023034029558150010L;
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new CheckboxList(stack, req, res);
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,10 +35,12 @@ public class CheckboxTag extends AbstractUITag {
|
||||
protected String fieldValue;
|
||||
protected String submitUnchecked;
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new Checkbox(stack, req, res);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
|
||||
@@ -53,4 +55,22 @@ public class CheckboxTag extends AbstractUITag {
|
||||
public void setSubmitUnchecked(String aValue) {
|
||||
this.submitUnchecked = aValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
@Override
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.fieldValue = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -60,10 +60,12 @@ public class ComboBoxTag extends TextFieldTag {
|
||||
this.listValue = listValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new ComboBox(stack, req, res);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
|
||||
@@ -78,4 +80,27 @@ public class ComboBoxTag extends TextFieldTag {
|
||||
public void setList(String list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.list = null;
|
||||
this.listKey = null;
|
||||
this.listValue = null;
|
||||
this.headerKey = null;
|
||||
this.headerValue = null;
|
||||
this.emptyOption = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,7 +33,16 @@ public class ComponentTag extends AbstractUITag {
|
||||
|
||||
private static final long serialVersionUID = 5448365363044104731L;
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new GenericUIBean(stack, req, res);
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,10 +35,12 @@ public class DateTextFieldTag extends AbstractUITag {
|
||||
|
||||
protected String format;
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new DateTextField(stack, req, res);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
|
||||
@@ -46,8 +48,25 @@ public class DateTextFieldTag extends AbstractUITag {
|
||||
textField.setFormat(format);
|
||||
}
|
||||
|
||||
public void setFormat(String format) {
|
||||
this.format = format;
|
||||
}
|
||||
public void setFormat(String format) {
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.format = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,8 +30,16 @@ public class DebugTag extends AbstractUITag {
|
||||
|
||||
private static final long serialVersionUID = 3487684841317160628L;
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new Debug(stack, req, res);
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,10 +33,12 @@ public class DoubleSelectTag extends AbstractDoubleListTag {
|
||||
|
||||
private static final long serialVersionUID = 7426011596359509386L;
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new DoubleSelect(stack, req, res);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
|
||||
@@ -48,4 +50,12 @@ public class DoubleSelectTag extends AbstractDoubleListTag {
|
||||
doubleSelect.setSize(size);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,10 +37,12 @@ public class FieldErrorTag extends AbstractUITag {
|
||||
protected boolean escape = true;
|
||||
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new FieldError(stack, req, res);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
|
||||
@@ -56,5 +58,23 @@ public class FieldErrorTag extends AbstractUITag {
|
||||
public void setEscape(boolean escape) {
|
||||
this.escape = escape;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.fieldName = null;
|
||||
this.escape = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,10 +36,12 @@ public class FileTag extends AbstractUITag {
|
||||
protected String accept;
|
||||
protected String size;
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new File(stack, req, res);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
|
||||
@@ -55,4 +57,23 @@ public class FileTag extends AbstractUITag {
|
||||
public void setSize(String size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.accept = null;
|
||||
this.size = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -47,10 +47,12 @@ public class FormTag extends AbstractClosingTag {
|
||||
protected String focusElement;
|
||||
protected boolean includeContext = true;
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new Form(stack, req, res);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
Form form = ((Form) component);
|
||||
@@ -121,4 +123,34 @@ public class FormTag extends AbstractClosingTag {
|
||||
public void setIncludeContext(boolean includeContext) {
|
||||
this.includeContext = includeContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.action = null;
|
||||
this.target = null;
|
||||
this.enctype = null;
|
||||
this.method = null;
|
||||
this.namespace = null;
|
||||
this.validate = null;
|
||||
this.onsubmit = null;
|
||||
this.onreset = null;
|
||||
this.portletMode = null;
|
||||
this.windowState = null;
|
||||
this.acceptcharset = null;
|
||||
this.focusElement = null;
|
||||
this.includeContext = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,7 +33,16 @@ public class HeadTag extends AbstractUITag {
|
||||
|
||||
private static final long serialVersionUID = 6876765769175246030L;
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new Head(stack, req, res);
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,16 @@ public class HiddenTag extends AbstractUITag {
|
||||
|
||||
private static final long serialVersionUID = -1124367972048371675L;
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new Hidden(stack, req, res);
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,10 +53,12 @@ public class InputTransferSelectTag extends AbstractListTag {
|
||||
protected String headerKey;
|
||||
protected String headerValue;
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new InputTransferSelect(stack, req, res);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
|
||||
@@ -200,4 +202,36 @@ public class InputTransferSelectTag extends AbstractListTag {
|
||||
public void setHeaderValue(String headerValue) {
|
||||
this.headerValue = headerValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.size = null;
|
||||
this.multiple = null;
|
||||
this.allowRemoveAll = null;
|
||||
this.allowUpDown = null;
|
||||
this.leftTitle = null;
|
||||
this.rightTitle = null;
|
||||
this.buttonCssClass = null;
|
||||
this.buttonCssStyle = null;
|
||||
this.addLabel = null;
|
||||
this.removeLabel = null;
|
||||
this.removeAllLabel = null;
|
||||
this.upLabel = null;
|
||||
this.downLabel = null;
|
||||
this.headerKey = null;
|
||||
this.headerValue = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -35,10 +35,12 @@ public class LabelTag extends AbstractUITag {
|
||||
|
||||
protected String forAttr;
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new Label(stack, req, res);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
|
||||
@@ -48,4 +50,22 @@ public class LabelTag extends AbstractUITag {
|
||||
public void setFor(String aFor) {
|
||||
this.forAttr = aFor;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.forAttr = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -40,10 +40,12 @@ public class OptGroupTag extends ComponentTagSupport {
|
||||
protected String listCssStyle;
|
||||
protected String listTitle;
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new OptGroup(stack, req, res);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
|
||||
@@ -89,4 +91,29 @@ public class OptGroupTag extends ComponentTagSupport {
|
||||
public void setListTitle(String listTitle) {
|
||||
this.listTitle = listTitle;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.list = null;
|
||||
this.label = null;
|
||||
this.disabled = null;
|
||||
this.listKey = null;
|
||||
this.listValue = null;
|
||||
this.listCssClass = null;
|
||||
this.listCssStyle = null;
|
||||
this.listTitle = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -66,10 +66,12 @@ public class OptionTransferSelectTag extends AbstractDoubleListTag {
|
||||
protected String upDownOnRightOnclick;
|
||||
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new OptionTransferSelect(stack, req, res);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
|
||||
@@ -342,4 +344,48 @@ public class OptionTransferSelectTag extends AbstractDoubleListTag {
|
||||
public String getSelectAllOnclick() {
|
||||
return this.selectAllOnclick;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.allowAddToLeft = null;
|
||||
this.allowAddToRight = null;
|
||||
this.allowAddAllToLeft = null;
|
||||
this.allowAddAllToRight = null;
|
||||
this.allowSelectAll = null;
|
||||
this.allowUpDownOnLeft = null;
|
||||
this.allowUpDownOnRight = null;
|
||||
this.leftTitle = null;
|
||||
this.rightTitle = null;
|
||||
this.buttonCssClass = null;
|
||||
this.buttonCssStyle = null;
|
||||
this.addToLeftLabel = null;
|
||||
this.addToRightLabel = null;
|
||||
this.addAllToLeftLabel = null;
|
||||
this.addAllToRightLabel = null;
|
||||
this.selectAllLabel = null;
|
||||
this.leftUpLabel = null;
|
||||
this.leftDownLabel = null;
|
||||
this.rightUpLabel = null;
|
||||
this.rightDownLabel = null;
|
||||
this.addToLeftOnclick = null;
|
||||
this.addToRightOnclick = null;
|
||||
this.addAllToLeftOnclick = null;
|
||||
this.addAllToRightOnclick = null;
|
||||
this.selectAllOnclick = null;
|
||||
this.upDownOnLeftOnclick = null;
|
||||
this.upDownOnRightOnclick = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -35,10 +35,12 @@ public class PasswordTag extends TextFieldTag {
|
||||
|
||||
protected String showPassword;
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new Password(stack, req, res);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
|
||||
@@ -52,4 +54,22 @@ public class PasswordTag extends TextFieldTag {
|
||||
public void setShowPassword(String showPassword) {
|
||||
this.showPassword = showPassword;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.showPassword = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,7 +33,16 @@ public class RadioTag extends AbstractRequiredListTag {
|
||||
|
||||
private static final long serialVersionUID = -6497403399521333624L;
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new Radio(stack, req, res);
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,10 +37,12 @@ public class ResetTag extends AbstractUITag {
|
||||
protected String type;
|
||||
protected String src;
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new Reset(stack, req, res);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
|
||||
@@ -67,4 +69,24 @@ public class ResetTag extends AbstractUITag {
|
||||
this.src = src;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.action = null;
|
||||
this.method = null;
|
||||
this.type = null;
|
||||
this.src = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,10 +39,12 @@ public class SelectTag extends AbstractRequiredListTag {
|
||||
protected String multiple;
|
||||
protected String size;
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new Select(stack, req, res);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
|
||||
@@ -74,4 +76,25 @@ public class SelectTag extends AbstractRequiredListTag {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.emptyOption = null;
|
||||
this.headerKey = null;
|
||||
this.headerValue = null;
|
||||
this.multiple = null;
|
||||
this.size = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,10 +39,12 @@ public class SubmitTag extends AbstractClosingTag {
|
||||
protected String src;
|
||||
protected boolean escapeHtmlBody = true; // Default - escape HTML body
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new Submit(stack, req, res);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
|
||||
@@ -84,4 +86,25 @@ public class SubmitTag extends AbstractClosingTag {
|
||||
public void setEscapeHtmlBody(boolean escapeHtmlBody) {
|
||||
this.escapeHtmlBody = escapeHtmlBody;
|
||||
}
|
||||
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
@Override
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.action = null;
|
||||
this.method = null;
|
||||
this.type = null;
|
||||
this.src = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,10 +37,12 @@ public class TextFieldTag extends AbstractUITag {
|
||||
protected String size;
|
||||
protected String type;
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new TextField(stack, req, res);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
|
||||
@@ -66,4 +68,25 @@ public class TextFieldTag extends AbstractUITag {
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.maxlength = null;
|
||||
this.readonly = null;
|
||||
this.size = null;
|
||||
this.type = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -40,10 +40,12 @@ public class TextareaTag extends AbstractUITag {
|
||||
protected String maxlength;
|
||||
protected String minlength;
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new TextArea(stack, req, res);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
|
||||
@@ -80,4 +82,24 @@ public class TextareaTag extends AbstractUITag {
|
||||
this.minlength = minlength;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.cols = null;
|
||||
this.readonly = null;
|
||||
this.rows = null;
|
||||
this.wrap = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,7 +33,17 @@ public class TokenTag extends AbstractUITag {
|
||||
|
||||
private static final long serialVersionUID = 722480798151703457L;
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new Token(stack, req, res);
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -42,10 +42,12 @@ public class UpDownSelectTag extends SelectTag {
|
||||
protected String selectAllLabel;
|
||||
|
||||
|
||||
@Override
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new UpDownSelect(stack, req, res);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
|
||||
@@ -118,4 +120,27 @@ public class UpDownSelectTag extends SelectTag {
|
||||
public void setSelectAllLabel(String selectAllLabel) {
|
||||
this.selectAllLabel = selectAllLabel;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Must declare the setter at the descendant Tag class level in order for the tag handler to locate the method.
|
||||
*/
|
||||
public void setPerformClearTagStateForTagPoolingServers(boolean performClearTagStateForTagPoolingServers) {
|
||||
super.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTagStateForTagPoolingServers() {
|
||||
if (getPerformClearTagStateForTagPoolingServers() == false) {
|
||||
return; // If flag is false (default setting), do not perform any state clearing.
|
||||
}
|
||||
super.clearTagStateForTagPoolingServers();
|
||||
this.allowMoveUp = null;
|
||||
this.allowMoveDown = null;
|
||||
this.allowSelectAll = null;
|
||||
this.moveUpLabel = null;
|
||||
this.moveDownLabel = null;
|
||||
this.selectAllLabel = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,12 +19,11 @@
|
||||
package org.apache.struts2;
|
||||
|
||||
import com.opensymphony.xwork2.XWorkTestCase;
|
||||
import org.apache.commons.lang3.builder.EqualsBuilder;
|
||||
import org.apache.struts2.dispatcher.Dispatcher;
|
||||
import org.apache.struts2.dispatcher.PrepareOperations;
|
||||
import org.apache.struts2.util.StrutsTestCaseHelper;
|
||||
import org.apache.struts2.views.jsp.StrutsMockServletContext;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -39,9 +38,13 @@ public abstract class StrutsInternalTestCase extends XWorkTestCase {
|
||||
/**
|
||||
* Sets up the configuration settings, XWork configuration, and
|
||||
* message resources
|
||||
*
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
PrepareOperations.clearDevModeOverride(); // Clear DevMode override every time (consistent ThreadLocal state for tests).
|
||||
initDispatcher(null);
|
||||
}
|
||||
|
||||
@@ -68,6 +71,7 @@ public abstract class StrutsInternalTestCase extends XWorkTestCase {
|
||||
return initDispatcher(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
// maybe someone else already destroyed Dispatcher
|
||||
@@ -78,4 +82,26 @@ public abstract class StrutsInternalTestCase extends XWorkTestCase {
|
||||
StrutsTestCaseHelper.tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare if two objects are considered equal according to their fields as accessed
|
||||
* via reflection.
|
||||
*
|
||||
* Utilizes {@link EqualsBuilder#reflectionEquals(java.lang.Object, java.lang.Object, boolean)} to perform
|
||||
* the check, and compares transient fields as well. This may fail when run while a security manager is
|
||||
* active, due to a need to user reflection.
|
||||
*
|
||||
*
|
||||
* @param obj1 the first {@link Object} to compare against the other.
|
||||
* @param obj2 the second {@link Object} to compare against the other.
|
||||
* @return true if the objects are equal based on field comparisons by reflection, false otherwise.
|
||||
*/
|
||||
protected boolean objectsAreReflectionEqual(Object obj1, Object obj2) {
|
||||
boolean result = false;
|
||||
if (obj1 == obj2) {
|
||||
result = true;
|
||||
} else if (obj1 != null && obj2 != null) {
|
||||
result = EqualsBuilder.reflectionEquals(obj1, obj2, true);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,8 @@ import org.apache.struts2.views.jsp.iterator.MergeIteratorTag;
|
||||
import org.apache.struts2.views.jsp.ui.TextFieldTag;
|
||||
import org.apache.struts2.views.jsp.ui.UpDownSelectTag;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import java.util.HashMap;
|
||||
import org.apache.struts2.StrutsException;
|
||||
|
||||
/**
|
||||
* Test case for method findAncestor(Class) in Component and some commons
|
||||
@@ -542,4 +543,52 @@ public class ComponentTest extends AbstractTagTest {
|
||||
submit.setEscapeHtmlBody(true);
|
||||
assertTrue("Submit htmlEscapeBody not true after set true ?", submit.escapeHtmlBody());
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt some code coverage tests for {@link Component} that can be achieved without
|
||||
* too much difficulty.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testComponent_coverageTest() throws Exception {
|
||||
HashMap<String, Object> propertyMap = new HashMap<>();
|
||||
Exception exception = new Exception("Generic exception");
|
||||
Property property = new Property(stack);
|
||||
ActionComponent actionComponent = new ActionComponent(stack, request, response);
|
||||
|
||||
try {
|
||||
actionComponent.setName("componentName");
|
||||
// Simulate component attribute with a hyphen in its name.
|
||||
propertyMap.put("hyphen-keyname-for-coverage", "hyphen-keyname-for-coverage-value");
|
||||
propertyMap.put("someKeyName", "someKeyValue");
|
||||
actionComponent.copyParams(propertyMap);
|
||||
actionComponent.addAllParameters(propertyMap);
|
||||
try {
|
||||
actionComponent.findString(null, "fieldName", "errorMessage");
|
||||
fail("null expr parameter should cause a StrutsException");
|
||||
} catch (StrutsException se) {
|
||||
// expected
|
||||
}
|
||||
assertNull("completeExpression of a null expression returned non-null result ?", actionComponent.completeExpression(null));
|
||||
try {
|
||||
actionComponent.findValue(null, "fieldName", "errorMessage");
|
||||
fail("null expr parameter should cause a StrutsException");
|
||||
} catch (StrutsException se) {
|
||||
// expected
|
||||
}
|
||||
try {
|
||||
actionComponent.findValue("", "fieldName", "errorMessage");
|
||||
fail("empty expr parameter should cause a StrutsException due to finding a null value");
|
||||
} catch (StrutsException se) {
|
||||
// expected
|
||||
}
|
||||
assertNotNull("the toString() method with Exception parameter returned null result ?", actionComponent.toString(exception));
|
||||
assertFalse("Initial performClearTagStateForTagPoolingServers not false ?", actionComponent.getPerformClearTagStateForTagPoolingServers());
|
||||
actionComponent.setPerformClearTagStateForTagPoolingServers(true);
|
||||
assertTrue("performClearTagStateForTagPoolingServers false after setting to true ?", actionComponent.getPerformClearTagStateForTagPoolingServers());
|
||||
}
|
||||
finally {
|
||||
property.getComponentStack().pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.util.Map;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.jsp.JspWriter;
|
||||
|
||||
import org.apache.commons.lang3.builder.EqualsBuilder;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
import org.apache.struts2.StrutsInternalTestCase;
|
||||
import org.apache.struts2.TestAction;
|
||||
@@ -74,6 +75,7 @@ public abstract class AbstractTagTest extends StrutsInternalTestCase {
|
||||
return new TestAction();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
createMocks();
|
||||
@@ -129,6 +131,7 @@ public abstract class AbstractTagTest extends StrutsInternalTestCase {
|
||||
.bind();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
pageContext.verify();
|
||||
@@ -144,4 +147,44 @@ public abstract class AbstractTagTest extends StrutsInternalTestCase {
|
||||
servletContext = null;
|
||||
mockContainer = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare if two component tags are considered equal according to their fields as accessed
|
||||
* via reflection.
|
||||
*
|
||||
* Utilizes {@link EqualsBuilder#reflectionEquals(java.lang.Object, java.lang.Object, boolean)} to perform
|
||||
* the check, and compares transient fields as well. This may fail when run while a security manager is
|
||||
* active, due to a need to user reflection.
|
||||
*
|
||||
* This method may be useful for checking if the state of a tag is what is expected after a given set of operations,
|
||||
* or after clearing state such as for calls involving {@link StrutsBodyTagSupport#clearTagStateForTagPoolingServers()}
|
||||
* has taken place following {@link StrutsBodyTagSupport#doEndTag()} processing. When making comparisons, keep in mind the
|
||||
* pageContext and parent Tag state are not cleared by clearTagStateForTagPoolingServers().
|
||||
*
|
||||
* @param tag1 the first {@link StrutsBodyTagSupport} to compare against the other.
|
||||
* @param tag2 the second {@link StrutsBodyTagSupport} to compare against the other.
|
||||
* @return true if the Tags are equal based on field comparisons by reflection, false otherwise.
|
||||
*/
|
||||
protected boolean strutsBodyTagsAreReflectionEqual(StrutsBodyTagSupport tag1, StrutsBodyTagSupport tag2) {
|
||||
return objectsAreReflectionEqual(tag1, tag2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to simplify setting the performClearTagStateForTagPoolingServers state for a
|
||||
* {@link ComponentTagSupport} tag's {@link Component} to match expectations for the test.
|
||||
*
|
||||
* The component reference is not available to the tag until after the doStartTag() method is called.
|
||||
* We need to ensure the component's {@link Component#performClearTagStateForTagPoolingServers} state matches
|
||||
* what we set for the Tag when a non-default (true) value is used, so this method accesses the component instance,
|
||||
* sets the value specified and forces the tag's parameters to be repopulated again.
|
||||
*
|
||||
* @param tag The ComponentTagSupport tag upon whose component we will set the performClearTagStateForTagPoolingServers state.
|
||||
* @param performClearTagStateForTagPoolingServers true to clear tag state, false otherwise
|
||||
*/
|
||||
protected void setComponentTagClearTagState(ComponentTagSupport tag, boolean performClearTagStateForTagPoolingServers) {
|
||||
tag.component.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
//tag.populateParams(); // Not safe to call after doStartTag() ... breaks some tests.
|
||||
tag.populatePerformClearTagStateForTagPoolingServersParam(); // Only populate the performClearTagStateForTagPoolingServers parameter for the Tag.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -66,6 +66,47 @@ public class ActionTagTest extends AbstractTagTest {
|
||||
ex.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionTag freshTag = new ActionTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testActionTagWithNamespace_clearTagStateSet() {
|
||||
request.setupGetServletPath(TestConfigurationProvider.TEST_NAMESPACE + "/" + "foo.action");
|
||||
|
||||
ActionTag tag = new ActionTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setName(TestConfigurationProvider.TEST_NAMESPACE_ACTION);
|
||||
tag.setVar(TestConfigurationProvider.TEST_NAMESPACE_ACTION);
|
||||
|
||||
try {
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
ActionComponent ac = ((ActionComponent) tag.component);
|
||||
tag.doEndTag();
|
||||
ActionProxy proxy = ac.getProxy();
|
||||
|
||||
Object o = pageContext.findAttribute(TestConfigurationProvider.TEST_NAMESPACE_ACTION);
|
||||
assertTrue(o instanceof TestAction);
|
||||
|
||||
assertEquals(TestConfigurationProvider.TEST_NAMESPACE, proxy.getNamespace());
|
||||
} catch (JspException ex) {
|
||||
ex.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionTag freshTag = new ActionTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testSimple() {
|
||||
@@ -98,6 +139,57 @@ public class ActionTagTest extends AbstractTagTest {
|
||||
ex.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionTag freshTag = new ActionTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
|
||||
}
|
||||
|
||||
public void testSimple_clearTagStateSet() {
|
||||
request.setupGetServletPath("/foo.action");
|
||||
|
||||
ActionConfig config = configuration.getRuntimeConfiguration().getActionConfig("", "testAction");
|
||||
container.inject(config.getInterceptors().get(0).getInterceptor());
|
||||
|
||||
ActionTag tag = new ActionTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setName("testAction");
|
||||
tag.setVar("testAction");
|
||||
|
||||
int stackSize = stack.size();
|
||||
|
||||
try {
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.addParameter("foo", "myFoo");
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals(stack.size(), ActionContext.getContext().getValueStack().size());
|
||||
assertEquals("myFoo", stack.findValue("#testAction.foo"));
|
||||
assertEquals(stackSize, stack.size());
|
||||
|
||||
Object o = pageContext.findAttribute("testAction");
|
||||
assertTrue(o instanceof TestAction);
|
||||
assertEquals("myFoo", ((TestAction) o).getFoo());
|
||||
assertEquals(Action.SUCCESS, ((TestAction) o).getResult());
|
||||
} catch (JspException ex) {
|
||||
ex.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionTag freshTag = new ActionTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
|
||||
}
|
||||
|
||||
public void testSimpleWithoutServletActionContext() {
|
||||
@@ -136,6 +228,57 @@ public class ActionTagTest extends AbstractTagTest {
|
||||
ex.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionTag freshTag = new ActionTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
|
||||
}
|
||||
|
||||
public void testSimpleWithctionMethodInOriginalURI_clearTagStateSet() {
|
||||
request.setupGetServletPath("/foo!foo.action");
|
||||
|
||||
ActionConfig config = configuration.getRuntimeConfiguration().getActionConfig("", "testAction");
|
||||
container.inject(config.getInterceptors().get(0).getInterceptor());
|
||||
|
||||
ActionTag tag = new ActionTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setName("testAction");
|
||||
tag.setVar("testAction");
|
||||
|
||||
int stackSize = stack.size();
|
||||
|
||||
try {
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.addParameter("foo", "myFoo");
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals(stack.size(), ActionContext.getContext().getValueStack().size());
|
||||
assertEquals("myFoo", stack.findValue("#testAction.foo"));
|
||||
assertEquals(stackSize, stack.size());
|
||||
|
||||
Object o = pageContext.findAttribute("testAction");
|
||||
assertTrue(o instanceof TestAction);
|
||||
assertEquals("myFoo", ((TestAction) o).getFoo());
|
||||
assertEquals(Action.SUCCESS, ((TestAction) o).getResult());
|
||||
} catch (JspException ex) {
|
||||
ex.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionTag freshTag = new ActionTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
|
||||
}
|
||||
|
||||
public void testActionWithExecuteResult() throws Exception {
|
||||
@@ -157,6 +300,46 @@ public class ActionTagTest extends AbstractTagTest {
|
||||
assertTrue(stack.getContext().containsKey(ServletActionContext.PAGE_CONTEXT));
|
||||
assertTrue(stack.getContext().get(ServletActionContext.PAGE_CONTEXT) instanceof PageContext);
|
||||
assertTrue(result.isExecuted());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionTag freshTag = new ActionTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
|
||||
}
|
||||
|
||||
public void testActionWithExecuteResult_clearTagStateSet() throws Exception {
|
||||
ActionTag tag = new ActionTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setNamespace("");
|
||||
tag.setName("testActionTagAction");
|
||||
tag.setExecuteResult(true);
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
|
||||
// tag clear components on doEndTag
|
||||
ActionComponent component = (ActionComponent) tag.getComponent();
|
||||
|
||||
tag.doEndTag();
|
||||
|
||||
TestActionTagResult result = (TestActionTagResult) component.getProxy().getInvocation().getResult();
|
||||
|
||||
assertTrue(stack.getContext().containsKey(ServletActionContext.PAGE_CONTEXT));
|
||||
assertTrue(stack.getContext().get(ServletActionContext.PAGE_CONTEXT)instanceof PageContext);
|
||||
assertTrue(result.isExecuted());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionTag freshTag = new ActionTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
|
||||
}
|
||||
|
||||
public void testActionWithoutExecuteResult() throws Exception {
|
||||
@@ -178,6 +361,44 @@ public class ActionTagTest extends AbstractTagTest {
|
||||
assertTrue(stack.getContext().containsKey(ServletActionContext.PAGE_CONTEXT));
|
||||
assertTrue(stack.getContext().get(ServletActionContext.PAGE_CONTEXT) instanceof PageContext);
|
||||
assertNull(result); // result is never executed, hence never set into invocation
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionTag freshTag = new ActionTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testActionWithoutExecuteResult_clearTagStateSet() throws Exception {
|
||||
ActionTag tag = new ActionTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setNamespace("");
|
||||
tag.setName("testActionTagAction");
|
||||
tag.setExecuteResult(false);
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
|
||||
// tag clear components on doEndTag, so we need to get it here
|
||||
ActionComponent component = (ActionComponent) tag.getComponent();
|
||||
|
||||
tag.doEndTag();
|
||||
|
||||
TestActionTagResult result = (TestActionTagResult) component.getProxy().getInvocation().getResult();
|
||||
|
||||
assertTrue(stack.getContext().containsKey(ServletActionContext.PAGE_CONTEXT));
|
||||
assertTrue(stack.getContext().get(ServletActionContext.PAGE_CONTEXT)instanceof PageContext);
|
||||
assertNull(result); // result is never executed, hence never set into invocation
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionTag freshTag = new ActionTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testExecuteButResetReturnSameInvocation() throws Exception {
|
||||
@@ -199,6 +420,45 @@ public class ActionTagTest extends AbstractTagTest {
|
||||
|
||||
tag.doEndTag();
|
||||
assertSame(oldInvocation, ActionContext.getContext().getActionInvocation());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionTag freshTag = new ActionTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
|
||||
}
|
||||
|
||||
public void testExecuteButResetReturnSameInvocation_clearTagStateSet() throws Exception {
|
||||
Mock mockActionInv = new Mock(ActionInvocation.class);
|
||||
ActionTag tag = new ActionTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setNamespace("");
|
||||
tag.setName("testActionTagAction");
|
||||
tag.setExecuteResult(true);
|
||||
ActionContext.getContext().setActionInvocation((ActionInvocation) mockActionInv.proxy());
|
||||
|
||||
ActionInvocation oldInvocation = ActionContext.getContext().getActionInvocation();
|
||||
assertNotNull(oldInvocation);
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
|
||||
// tag clear components on doEndTag
|
||||
ActionComponent component = (ActionComponent) tag.getComponent();
|
||||
|
||||
tag.doEndTag();
|
||||
assertTrue(oldInvocation == ActionContext.getContext().getActionInvocation());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionTag freshTag = new ActionTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testIngoreContextParamsFalse() throws Exception {
|
||||
@@ -224,6 +484,50 @@ public class ActionTagTest extends AbstractTagTest {
|
||||
ActionInvocation ai = component.getProxy().getInvocation();
|
||||
ActionContext ac = ai.getInvocationContext();
|
||||
assertEquals(1, ac.getParameters().keySet().size());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionTag freshTag = new ActionTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
|
||||
}
|
||||
|
||||
public void testIngoreContextParamsFalse_clearTagStateSet() throws Exception {
|
||||
ActionTag tag = new ActionTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setNamespace("");
|
||||
tag.setName("testActionTagAction");
|
||||
tag.setExecuteResult(false);
|
||||
tag.setIgnoreContextParams(false);
|
||||
|
||||
Map<String, String[]> params = new HashMap<>();
|
||||
params.put("user", new String[]{"Santa Claus"});
|
||||
ActionContext.getContext().setParameters(HttpParameters.create(params).build());
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
|
||||
// tag clear components on doEndTag, so we need to get it here
|
||||
ActionComponent component = (ActionComponent) tag.getComponent();
|
||||
|
||||
tag.doEndTag();
|
||||
|
||||
// check parameters, there should be one
|
||||
ActionInvocation ai = component.getProxy().getInvocation();
|
||||
ActionContext ac = ai.getInvocationContext();
|
||||
assertEquals(1, ac.getParameters().keySet().size());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionTag freshTag = new ActionTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
|
||||
}
|
||||
|
||||
public void testIngoreContextParamsTrue() throws Exception {
|
||||
@@ -249,6 +553,48 @@ public class ActionTagTest extends AbstractTagTest {
|
||||
ActionInvocation ai = component.getProxy().getInvocation();
|
||||
ActionContext ac = ai.getInvocationContext();
|
||||
assertEquals(0, ac.getParameters().keySet().size());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionTag freshTag = new ActionTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testIngoreContextParamsTrue_clearTagStateSet() throws Exception {
|
||||
ActionTag tag = new ActionTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setNamespace("");
|
||||
tag.setName("testActionTagAction");
|
||||
tag.setExecuteResult(false);
|
||||
tag.setIgnoreContextParams(true);
|
||||
|
||||
Map<String, String[]> params = new HashMap<>();
|
||||
params.put("user", new String[] { "Santa Claus" });
|
||||
ActionContext.getContext().setParameters(HttpParameters.create(params).build());
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
|
||||
// tag clear components on doEndTag, so we need to get it here
|
||||
ActionComponent component = (ActionComponent) tag.getComponent();
|
||||
|
||||
tag.doEndTag();
|
||||
|
||||
// check parameters, there should be one
|
||||
ActionInvocation ai = component.getProxy().getInvocation();
|
||||
ActionContext ac = ai.getInvocationContext();
|
||||
assertEquals(0, ac.getParameters().keySet().size());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionTag freshTag = new ActionTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testNoNameDefined() throws Exception {
|
||||
@@ -265,6 +611,8 @@ public class ActionTagTest extends AbstractTagTest {
|
||||
} catch (StrutsException e) {
|
||||
assertEquals("tag 'actioncomponent', field 'name': Action name is required. Example: updatePerson", e.getMessage());
|
||||
}
|
||||
|
||||
// The doEndTag() call is expected not to complete. Cannot perform basic sanity check of clearTagStateForTagPoolingServers() behaviour.
|
||||
}
|
||||
|
||||
// FIXME: Logging the error seems to cause the standard Maven build to fail
|
||||
@@ -278,6 +626,36 @@ public class ActionTagTest extends AbstractTagTest {
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
// will just log it to ERROR but we run the code to test that it works somehow
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionTag freshTag = new ActionTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
// FIXME: Logging the error seems to cause the standard Maven build to fail
|
||||
public void testUnknownNameDefined_clearTagStateSet() throws Exception {
|
||||
ActionTag tag = new ActionTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setNamespace("");
|
||||
tag.setName("UNKNOWN_NAME");
|
||||
tag.setExecuteResult(false);
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
// will just log it to ERROR but we run the code to test that it works somehow
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionTag freshTag = new ActionTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testActionMethodWithExecuteResult() throws Exception {
|
||||
@@ -300,8 +678,48 @@ public class ActionTagTest extends AbstractTagTest {
|
||||
assertTrue(stack.getContext().containsKey(ServletActionContext.PAGE_CONTEXT));
|
||||
assertTrue(stack.getContext().get(ServletActionContext.PAGE_CONTEXT) instanceof PageContext);
|
||||
assertTrue(result.isExecuted());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionTag freshTag = new ActionTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testActionMethodWithExecuteResult_clearTagStateSet() throws Exception {
|
||||
ActionTag tag = new ActionTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setNamespace("");
|
||||
tag.setName("testActionTagAction!input");
|
||||
tag.setExecuteResult(true);
|
||||
((DefaultActionMapper)container.getInstance(ActionMapper.class)).setAllowDynamicMethodCalls("true");
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
|
||||
// tag clear components on doEndTag
|
||||
ActionComponent component = (ActionComponent) tag.getComponent();
|
||||
|
||||
tag.doEndTag();
|
||||
|
||||
TestActionTagResult result = (TestActionTagResult) component.getProxy().getInvocation().getResult();
|
||||
|
||||
assertTrue(stack.getContext().containsKey(ServletActionContext.PAGE_CONTEXT));
|
||||
assertTrue(stack.getContext().get(ServletActionContext.PAGE_CONTEXT)instanceof PageContext);
|
||||
assertTrue(result.isExecuted());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionTag freshTag = new ActionTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
initDispatcher(new HashMap<String, String>() {{
|
||||
@@ -310,6 +728,7 @@ public class ActionTagTest extends AbstractTagTest {
|
||||
createMocks();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -82,6 +82,107 @@ public class AppendIteratorTagTest extends AbstractTagTest {
|
||||
assertTrue(appendedIterator.hasNext());
|
||||
assertEquals(appendedIterator.next(), "C");
|
||||
assertFalse(appendedIterator.hasNext());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ParamTag freshParamTag = new ParamTag();
|
||||
freshParamTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(iterator1ParamTag, freshParamTag));
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(iterator2ParamTag, freshParamTag));
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(iterator3ParamTag, freshParamTag));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
AppendIteratorTag freshTag = new AppendIteratorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testAppendingIteratorUsingArrayAsSource_clearTagStateSet() throws Exception {
|
||||
AppendIteratorTag tag = new AppendIteratorTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setVar("myAppendedIterator");
|
||||
|
||||
ParamTag iterator1ParamTag = new ParamTag();
|
||||
iterator1ParamTag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
iterator1ParamTag.setPageContext(pageContext);
|
||||
iterator1ParamTag.setValue("%{myArr1}");
|
||||
|
||||
ParamTag iterator2ParamTag = new ParamTag();
|
||||
iterator2ParamTag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
iterator2ParamTag.setPageContext(pageContext);
|
||||
iterator2ParamTag.setValue("%{myArr2}");
|
||||
|
||||
ParamTag iterator3ParamTag = new ParamTag();
|
||||
iterator3ParamTag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
iterator3ParamTag.setPageContext(pageContext);
|
||||
iterator3ParamTag.setValue("%{myArr3}");
|
||||
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
iterator1ParamTag.doStartTag();
|
||||
setComponentTagClearTagState(iterator1ParamTag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
iterator1ParamTag.doEndTag();
|
||||
iterator2ParamTag.doStartTag();
|
||||
setComponentTagClearTagState(iterator2ParamTag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
iterator2ParamTag.doEndTag();
|
||||
iterator3ParamTag.doStartTag();
|
||||
setComponentTagClearTagState(iterator3ParamTag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
iterator3ParamTag.doEndTag();
|
||||
tag.doEndTag();
|
||||
|
||||
Iterator appendedIterator = (Iterator) stack.findValue("#myAppendedIterator");
|
||||
|
||||
assertNotNull(appendedIterator);
|
||||
assertTrue(appendedIterator.hasNext());
|
||||
assertEquals(appendedIterator.next(), "1");
|
||||
assertTrue(appendedIterator.hasNext());
|
||||
assertEquals(appendedIterator.next(), "2");
|
||||
assertTrue(appendedIterator.hasNext());
|
||||
assertEquals(appendedIterator.next(), "3");
|
||||
assertTrue(appendedIterator.hasNext());
|
||||
assertEquals(appendedIterator.next(), "a");
|
||||
assertTrue(appendedIterator.hasNext());
|
||||
assertEquals(appendedIterator.next(), "b");
|
||||
assertTrue(appendedIterator.hasNext());
|
||||
assertEquals(appendedIterator.next(), "c");
|
||||
assertTrue(appendedIterator.hasNext());
|
||||
assertEquals(appendedIterator.next(), "A");
|
||||
assertTrue(appendedIterator.hasNext());
|
||||
assertEquals(appendedIterator.next(), "B");
|
||||
assertTrue(appendedIterator.hasNext());
|
||||
assertEquals(appendedIterator.next(), "C");
|
||||
assertFalse(appendedIterator.hasNext());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ParamTag freshParamTag = new ParamTag();
|
||||
freshParamTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshParamTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(iterator1ParamTag, freshParamTag));
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(iterator2ParamTag, freshParamTag));
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(iterator3ParamTag, freshParamTag));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
AppendIteratorTag freshTag = new AppendIteratorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testAppendingIteratorsUsingListAsSource() throws Exception {
|
||||
@@ -133,10 +234,110 @@ public class AppendIteratorTagTest extends AbstractTagTest {
|
||||
assertTrue(appendedIterator.hasNext());
|
||||
assertEquals(appendedIterator.next(), "C");
|
||||
assertFalse(appendedIterator.hasNext());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ParamTag freshParamTag = new ParamTag();
|
||||
freshParamTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(iterator1ParamTag, freshParamTag));
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(iterator2ParamTag, freshParamTag));
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(iterator3ParamTag, freshParamTag));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
AppendIteratorTag freshTag = new AppendIteratorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testAppendingIteratorsUsingListAsSource_clearTagStateSet() throws Exception {
|
||||
AppendIteratorTag tag = new AppendIteratorTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setVar("myAppendedIterator");
|
||||
|
||||
ParamTag iterator1ParamTag = new ParamTag();
|
||||
iterator1ParamTag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
iterator1ParamTag.setPageContext(pageContext);
|
||||
iterator1ParamTag.setValue("%{myList1}");
|
||||
|
||||
ParamTag iterator2ParamTag = new ParamTag();
|
||||
iterator2ParamTag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
iterator2ParamTag.setPageContext(pageContext);
|
||||
iterator2ParamTag.setValue("%{myList2}");
|
||||
|
||||
ParamTag iterator3ParamTag = new ParamTag();
|
||||
iterator3ParamTag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
iterator3ParamTag.setPageContext(pageContext);
|
||||
iterator3ParamTag.setValue("%{myList3}");
|
||||
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
iterator1ParamTag.doStartTag();
|
||||
setComponentTagClearTagState(iterator1ParamTag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
iterator1ParamTag.doEndTag();
|
||||
iterator2ParamTag.doStartTag();
|
||||
setComponentTagClearTagState(iterator2ParamTag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
iterator2ParamTag.doEndTag();
|
||||
iterator3ParamTag.doStartTag();
|
||||
setComponentTagClearTagState(iterator3ParamTag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
iterator3ParamTag.doEndTag();
|
||||
tag.doEndTag();
|
||||
|
||||
Iterator appendedIterator = (Iterator) stack.findValue("#myAppendedIterator");
|
||||
|
||||
assertNotNull(appendedIterator);
|
||||
assertTrue(appendedIterator.hasNext());
|
||||
assertEquals(appendedIterator.next(), "1");
|
||||
assertTrue(appendedIterator.hasNext());
|
||||
assertEquals(appendedIterator.next(), "2");
|
||||
assertTrue(appendedIterator.hasNext());
|
||||
assertEquals(appendedIterator.next(), "3");
|
||||
assertTrue(appendedIterator.hasNext());
|
||||
assertEquals(appendedIterator.next(), "a");
|
||||
assertTrue(appendedIterator.hasNext());
|
||||
assertEquals(appendedIterator.next(), "b");
|
||||
assertTrue(appendedIterator.hasNext());
|
||||
assertEquals(appendedIterator.next(), "c");
|
||||
assertTrue(appendedIterator.hasNext());
|
||||
assertEquals(appendedIterator.next(), "A");
|
||||
assertTrue(appendedIterator.hasNext());
|
||||
assertEquals(appendedIterator.next(), "B");
|
||||
assertTrue(appendedIterator.hasNext());
|
||||
assertEquals(appendedIterator.next(), "C");
|
||||
assertFalse(appendedIterator.hasNext());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ParamTag freshParamTag = new ParamTag();
|
||||
freshParamTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshParamTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(iterator1ParamTag, freshParamTag));
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(iterator2ParamTag, freshParamTag));
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(iterator3ParamTag, freshParamTag));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
AppendIteratorTag freshTag = new AppendIteratorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Action getAction() {
|
||||
return new ActionSupport() {
|
||||
public List getMyList1() {
|
||||
|
||||
@@ -53,6 +53,46 @@ public class BeanTagTest extends AbstractUITagTest {
|
||||
|
||||
request.verify();
|
||||
pageContext.verify();
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
BeanTag freshTag = new BeanTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testSimple_clearTagStateSet() {
|
||||
BeanTag tag = new BeanTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setName("org.apache.struts2.TestAction");
|
||||
|
||||
try {
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.component.addParameter("result", "success");
|
||||
|
||||
assertEquals("success", stack.findValue("result"));
|
||||
// TestAction from bean tag, Action from execution and DefaultTextProvider
|
||||
assertEquals(3, stack.size());
|
||||
tag.doEndTag();
|
||||
assertEquals(2, stack.size());
|
||||
} catch (JspException ex) {
|
||||
ex.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
request.verify();
|
||||
pageContext.verify();
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
BeanTag freshTag = new BeanTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testNotAccepted() throws Exception {
|
||||
@@ -108,4 +148,5 @@ public class BeanTagTest extends AbstractUITagTest {
|
||||
|
||||
tag.doEndTag();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -50,6 +50,36 @@ public class ElseIfTagTest extends StrutsInternalTestCase {
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals(result, TagSupport.EVAL_BODY_INCLUDE);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ElseIfTag freshTag = new ElseIfTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testIfIsFalseElseIfIsTrue_clearTagStateSet() throws Exception {
|
||||
stack.getContext().put(If.ANSWER, Boolean.FALSE);
|
||||
|
||||
ElseIfTag tag = new ElseIfTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setTest("true");
|
||||
|
||||
int result = tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals(result, TagSupport.EVAL_BODY_INCLUDE);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ElseIfTag freshTag = new ElseIfTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testIfIsFalseElseIfIsFalse() throws Exception {
|
||||
@@ -63,6 +93,36 @@ public class ElseIfTagTest extends StrutsInternalTestCase {
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals(result, TagSupport.SKIP_BODY);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ElseIfTag freshTag = new ElseIfTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testIfIsFalseElseIfIsFalse_clearTagStateSet() throws Exception {
|
||||
stack.getContext().put(If.ANSWER, Boolean.FALSE);
|
||||
|
||||
ElseIfTag tag = new ElseIfTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setTest("false");
|
||||
|
||||
int result = tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals(result, TagSupport.SKIP_BODY);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ElseIfTag freshTag = new ElseIfTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testIfIsTrueElseIfIsTrue() throws Exception {
|
||||
@@ -76,6 +136,36 @@ public class ElseIfTagTest extends StrutsInternalTestCase {
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals(result, TagSupport.SKIP_BODY);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ElseIfTag freshTag = new ElseIfTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testIfIsTrueElseIfIsTrue_clearTagStateSet() throws Exception {
|
||||
stack.getContext().put(If.ANSWER, Boolean.TRUE);
|
||||
|
||||
ElseIfTag tag = new ElseIfTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setTest("true");
|
||||
|
||||
int result = tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals(result, TagSupport.SKIP_BODY);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ElseIfTag freshTag = new ElseIfTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testIfIsTrueElseIfIsFalse() throws Exception {
|
||||
@@ -89,9 +179,39 @@ public class ElseIfTagTest extends StrutsInternalTestCase {
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals(result, TagSupport.SKIP_BODY);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ElseIfTag freshTag = new ElseIfTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testIfIsTrueElseIfIsFalse_clearTagStateSet() throws Exception {
|
||||
stack.getContext().put(If.ANSWER, Boolean.TRUE);
|
||||
|
||||
ElseIfTag tag = new ElseIfTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setTest("false");
|
||||
|
||||
int result = tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals(result, TagSupport.SKIP_BODY);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ElseIfTag freshTag = new ElseIfTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
stack = ActionContext.getContext().getValueStack();
|
||||
@@ -111,5 +231,22 @@ public class ElseIfTagTest extends StrutsInternalTestCase {
|
||||
request.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to simplify setting the performClearTagStateForTagPoolingServers state for a
|
||||
* {@link ComponentTagSupport} tag's {@link Component} to match expectations for the test.
|
||||
*
|
||||
* The component reference is not available to the tag until after the doStartTag() method is called.
|
||||
* We need to ensure the component's {@link Component#performClearTagStateForTagPoolingServers} state matches
|
||||
* what we set for the Tag when a non-default (true) value is used, so this method accesses the component instance,
|
||||
* sets the value specified and forces the tag's parameters to be repopulated again.
|
||||
*
|
||||
* @param tag The ComponentTagSupport tag upon whose component we will set the performClearTagStateForTagPoolingServers state.
|
||||
* @param performClearTagStateForTagPoolingServers true to clear tag state, false otherwise
|
||||
*/
|
||||
protected void setComponentTagClearTagState(ComponentTagSupport tag, boolean performClearTagStateForTagPoolingServers) {
|
||||
tag.component.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
//tag.populateParams(); // Not safe to call after doStartTag() ... breaks some tests.
|
||||
tag.populatePerformClearTagStateForTagPoolingServersParam(); // Only populate the performClearTagStateForTagPoolingServers parameter for the Tag.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -54,6 +54,40 @@ public class ElseTagTest extends StrutsInternalTestCase {
|
||||
fail();
|
||||
}
|
||||
assertEquals(TagSupport.EVAL_BODY_INCLUDE, result);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ElseTag freshTag = new ElseTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
// ElseTag has no additional state, so it compares as equal with the default tag clear state as well.
|
||||
assertTrue("Tag state after doEndTag() under default tag clear state is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(elseTag, freshTag));
|
||||
}
|
||||
|
||||
public void testTestFalse_clearTagStateSet() {
|
||||
stack.getContext().put(If.ANSWER, new Boolean(false));
|
||||
|
||||
int result = 0;
|
||||
|
||||
try {
|
||||
elseTag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
elseTag.setPageContext(pageContext);
|
||||
result = elseTag.doStartTag();
|
||||
setComponentTagClearTagState(elseTag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
elseTag.doEndTag();
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
assertEquals(TagSupport.EVAL_BODY_INCLUDE, result);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ElseTag freshTag = new ElseTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(elseTag, freshTag));
|
||||
}
|
||||
|
||||
public void testTestNull() {
|
||||
@@ -63,12 +97,47 @@ public class ElseTagTest extends StrutsInternalTestCase {
|
||||
|
||||
try {
|
||||
result = elseTag.doStartTag();
|
||||
elseTag.doEndTag();
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
assertEquals(TagSupport.SKIP_BODY, result);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ElseTag freshTag = new ElseTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
// ElseTag has no additional state, so it compares as equal with the default tag clear state as well.
|
||||
assertTrue("Tag state after doEndTag() under default tag clear state is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(elseTag, freshTag));
|
||||
}
|
||||
|
||||
public void testTestNull_clearTagStateSet() {
|
||||
elseTag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
elseTag.setPageContext(pageContext);
|
||||
|
||||
int result = 0;
|
||||
|
||||
try {
|
||||
result = elseTag.doStartTag();
|
||||
setComponentTagClearTagState(elseTag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
elseTag.doEndTag();
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
assertEquals(TagSupport.SKIP_BODY, result);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ElseTag freshTag = new ElseTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(elseTag, freshTag));
|
||||
}
|
||||
|
||||
public void testTestTrue() {
|
||||
@@ -79,14 +148,69 @@ public class ElseTagTest extends StrutsInternalTestCase {
|
||||
|
||||
try {
|
||||
result = elseTag.doStartTag();
|
||||
elseTag.doEndTag();
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
assertEquals(TagSupport.SKIP_BODY, result);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ElseTag freshTag = new ElseTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
// ElseTag has no additional state, so it compares as equal with the default tag clear state as well.
|
||||
assertTrue("Tag state after doEndTag() under default tag clear state is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(elseTag, freshTag));
|
||||
}
|
||||
|
||||
public void testTestTrue_clearTagStateSet() {
|
||||
stack.getContext().put(If.ANSWER, new Boolean(true));
|
||||
elseTag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
elseTag.setPageContext(pageContext);
|
||||
|
||||
int result = 0;
|
||||
|
||||
try {
|
||||
result = elseTag.doStartTag();
|
||||
setComponentTagClearTagState(elseTag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
elseTag.doEndTag();
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
assertEquals(TagSupport.SKIP_BODY, result);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ElseTag freshTag = new ElseTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(elseTag, freshTag));
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to simplify setting the performClearTagStateForTagPoolingServers state for a
|
||||
* {@link ComponentTagSupport} tag's {@link Component} to match expecations for a test.
|
||||
*
|
||||
* Since the component is not available to the tag until after the doStartTag() method is called,
|
||||
* but we need to ensure the component's {@link Component#performClearTagStateForTagPoolingServers} state matches
|
||||
* what we set for the Tag when a non-default (true) value is used, this method retrieves the component instance,
|
||||
* sets the value specified and forces the parameters to be repopulated again.
|
||||
*
|
||||
* @param tag The ComponentTagSupport tag upon whose component we will set the performClearTagStateForTagPoolingServers state.
|
||||
* @param performClearTagStateForTagPoolingServers true to clear tag state, false otherwise
|
||||
*/
|
||||
protected void setComponentTagClearTagState(ComponentTagSupport tag, boolean performClearTagStateForTagPoolingServers) {
|
||||
tag.component.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
//tag.populateParams(); // Not safe to call after doStartTag() ... breaks some tests.
|
||||
tag.populatePerformClearTagStateForTagPoolingServersParam(); // Only populate the performClearTagStateForTagPoolingServers parameter for the Tag.
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
// create the needed objects
|
||||
|
||||
@@ -35,6 +35,7 @@ public class I18nTagTest extends StrutsInternalTestCase {
|
||||
MockPageContext pageContext;
|
||||
ValueStack stack;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
// create the needed objects
|
||||
@@ -76,6 +77,65 @@ public class I18nTagTest extends StrutsInternalTestCase {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
I18nTag freshTag = new I18nTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testSimple_clearTagStateSet() throws Exception {
|
||||
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
// set the resource bundle
|
||||
tag.setName("testmessages");
|
||||
|
||||
int result = 0;
|
||||
|
||||
try {
|
||||
result = tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
assertEquals(TagSupport.EVAL_BODY_INCLUDE, result);
|
||||
|
||||
try {
|
||||
result = tag.doEndTag();
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
I18nTag freshTag = new I18nTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to simplify setting the performClearTagStateForTagPoolingServers state for a
|
||||
* {@link ComponentTagSupport} tag's {@link Component} to match expecations for a test.
|
||||
*
|
||||
* Since the component is not available to the tag until after the doStartTag() method is called,
|
||||
* but we need to ensure the component's {@link Component#performClearTagStateForTagPoolingServers} state matches
|
||||
* what we set for the Tag when a non-default (true) value is used, this method retrieves the component instance,
|
||||
* sets the value specified and forces the parameters to be repopulated again.
|
||||
*
|
||||
* @param tag The ComponentTagSupport tag upon whose component we will set the performClearTagStateForTagPoolingServers state.
|
||||
* @param performClearTagStateForTagPoolingServers true to clear tag state, false otherwise
|
||||
*/
|
||||
protected void setComponentTagClearTagState(ComponentTagSupport tag, boolean performClearTagStateForTagPoolingServers) {
|
||||
tag.component.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
//tag.populateParams(); // Not safe to call after doStartTag() ... breaks some tests.
|
||||
tag.populatePerformClearTagStateForTagPoolingServersParam(); // Only populate the performClearTagStateForTagPoolingServers parameter for the Tag.
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -65,6 +65,51 @@ public class IfTagTest extends StrutsInternalTestCase {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IfTag freshTag = new IfTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testNonBooleanTest_clearTagStateSet() {
|
||||
// set up the stack
|
||||
Foo foo = new Foo();
|
||||
foo.setNum(1);
|
||||
stack.push(foo);
|
||||
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
// set up the test
|
||||
tag.setTest("num");
|
||||
|
||||
int result = 0;
|
||||
|
||||
try {
|
||||
result = tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
assertEquals(TagSupport.EVAL_BODY_INCLUDE, result);
|
||||
|
||||
try {
|
||||
result = tag.doEndTag();
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IfTag freshTag = new IfTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testTestError() {
|
||||
@@ -93,6 +138,51 @@ public class IfTagTest extends StrutsInternalTestCase {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IfTag freshTag = new IfTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testTestError_clearTagStateSet() {
|
||||
// set up the stack
|
||||
Foo foo = new Foo();
|
||||
foo.setNum(2);
|
||||
stack.push(foo);
|
||||
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
// set up the test
|
||||
tag.setTest("nuuuuum == 2");
|
||||
|
||||
int result = 0;
|
||||
|
||||
try {
|
||||
result = tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
assertEquals(TagSupport.SKIP_BODY, result);
|
||||
|
||||
try {
|
||||
result = tag.doEndTag();
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IfTag freshTag = new IfTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testTestFalse() {
|
||||
@@ -121,6 +211,51 @@ public class IfTagTest extends StrutsInternalTestCase {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IfTag freshTag = new IfTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testTestFalse_clearTagStateSet() {
|
||||
// set up the stack
|
||||
Foo foo = new Foo();
|
||||
foo.setNum(2);
|
||||
stack.push(foo);
|
||||
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
// set up the test
|
||||
tag.setTest("num != 2");
|
||||
|
||||
int result = 0;
|
||||
|
||||
try {
|
||||
result = tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
assertEquals(TagSupport.SKIP_BODY, result);
|
||||
|
||||
try {
|
||||
result = tag.doEndTag();
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IfTag freshTag = new IfTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testTestTrue() {
|
||||
@@ -150,8 +285,53 @@ public class IfTagTest extends StrutsInternalTestCase {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IfTag freshTag = new IfTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testTestTrue_clearTagStateSet() {
|
||||
// set up the stack
|
||||
Foo foo = new Foo();
|
||||
foo.setNum(2);
|
||||
stack.push(foo);
|
||||
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
// set up the test
|
||||
tag.setTest("num == 2");
|
||||
|
||||
int result = 0;
|
||||
//tag.setPageContext(pageContext);
|
||||
|
||||
try {
|
||||
result = tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
assertEquals(TagSupport.EVAL_BODY_INCLUDE, result);
|
||||
|
||||
try {
|
||||
result = tag.doEndTag();
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IfTag freshTag = new IfTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testIfElse1() throws Exception {
|
||||
IfTag ifTag = new IfTag();
|
||||
@@ -168,6 +348,58 @@ public class IfTagTest extends StrutsInternalTestCase {
|
||||
|
||||
assertEquals(TagSupport.EVAL_BODY_INCLUDE, r1);
|
||||
assertEquals(TagSupport.SKIP_BODY, r2);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IfTag freshTag = new IfTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(ifTag, freshTag));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ElseTag freshTag2 = new ElseTag();
|
||||
freshTag2.setPageContext(pageContext);
|
||||
// ElseTag has no additional state, so it compares as equal with the default tag clear state as well.
|
||||
assertTrue("Tag state after doEndTag() under default tag clear state is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(elseTag, freshTag2));
|
||||
}
|
||||
|
||||
public void testIfElse1_clearTagStateSet() throws Exception {
|
||||
IfTag ifTag = new IfTag();
|
||||
ifTag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
ifTag.setPageContext(pageContext);
|
||||
ifTag.setTest("true");
|
||||
|
||||
ElseTag elseTag = new ElseTag();
|
||||
elseTag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
elseTag.setPageContext(pageContext);
|
||||
|
||||
int r1 = ifTag.doStartTag();
|
||||
setComponentTagClearTagState(ifTag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
ifTag.doEndTag();
|
||||
int r2 = elseTag.doStartTag();
|
||||
setComponentTagClearTagState(elseTag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
elseTag.doEndTag();
|
||||
|
||||
assertEquals(TagSupport.EVAL_BODY_INCLUDE, r1);
|
||||
assertEquals(TagSupport.SKIP_BODY, r2);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IfTag freshTag = new IfTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(ifTag, freshTag));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ElseTag freshTag2 = new ElseTag();
|
||||
freshTag2.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag2.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(elseTag, freshTag2));
|
||||
}
|
||||
|
||||
public void testIfElse2() throws Exception {
|
||||
@@ -185,6 +417,58 @@ public class IfTagTest extends StrutsInternalTestCase {
|
||||
|
||||
assertEquals(TagSupport.SKIP_BODY, r1);
|
||||
assertEquals(TagSupport.EVAL_BODY_INCLUDE, r2);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IfTag freshTag = new IfTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(ifTag, freshTag));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ElseTag freshTag2 = new ElseTag();
|
||||
freshTag2.setPageContext(pageContext);
|
||||
// ElseTag has no additional state, so it compares as equal with the default tag clear state as well.
|
||||
assertTrue("Tag state after doEndTag() under default tag clear state is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(elseTag, freshTag2));
|
||||
}
|
||||
|
||||
public void testIfElse2_clearTagStateSet() throws Exception {
|
||||
IfTag ifTag = new IfTag();
|
||||
ifTag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
ifTag.setPageContext(pageContext);
|
||||
ifTag.setTest("false");
|
||||
|
||||
ElseTag elseTag = new ElseTag();
|
||||
elseTag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
elseTag.setPageContext(pageContext);
|
||||
|
||||
int r1 = ifTag.doStartTag();
|
||||
setComponentTagClearTagState(ifTag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
ifTag.doEndTag();
|
||||
int r2 = elseTag.doStartTag();
|
||||
setComponentTagClearTagState(elseTag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
elseTag.doEndTag();
|
||||
|
||||
assertEquals(TagSupport.SKIP_BODY, r1);
|
||||
assertEquals(TagSupport.EVAL_BODY_INCLUDE, r2);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IfTag freshTag = new IfTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(ifTag, freshTag));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ElseTag freshTag2 = new ElseTag();
|
||||
freshTag2.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag2.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(elseTag, freshTag2));
|
||||
}
|
||||
|
||||
public void testIfElseIf() throws Exception {
|
||||
@@ -217,6 +501,88 @@ public class IfTagTest extends StrutsInternalTestCase {
|
||||
assertEquals(TagSupport.SKIP_BODY, r2);
|
||||
assertEquals(TagSupport.EVAL_BODY_INCLUDE, r3);
|
||||
assertEquals(TagSupport.SKIP_BODY, r4);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IfTag freshTag = new IfTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(ifTag, freshTag));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ElseIfTag freshTag2 = new ElseIfTag();
|
||||
freshTag2.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(elseIfTag1, freshTag2));
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(elseIfTag2, freshTag2));
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(elseIfTag3, freshTag2));
|
||||
}
|
||||
|
||||
public void testIfElseIf_clearTagStateSet() throws Exception {
|
||||
IfTag ifTag = new IfTag();
|
||||
ifTag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
ifTag.setPageContext(pageContext);
|
||||
ifTag.setTest("false");
|
||||
|
||||
ElseIfTag elseIfTag1 = new ElseIfTag();
|
||||
elseIfTag1.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
elseIfTag1.setPageContext(pageContext);
|
||||
elseIfTag1.setTest("false");
|
||||
|
||||
ElseIfTag elseIfTag2 = new ElseIfTag();
|
||||
elseIfTag2.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
elseIfTag2.setPageContext(pageContext);
|
||||
elseIfTag2.setTest("true");
|
||||
|
||||
ElseIfTag elseIfTag3 = new ElseIfTag();
|
||||
elseIfTag3.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
elseIfTag3.setPageContext(pageContext);
|
||||
elseIfTag3.setTest("true");
|
||||
|
||||
int r1 = ifTag.doStartTag();
|
||||
setComponentTagClearTagState(ifTag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
ifTag.doEndTag();
|
||||
int r2 = elseIfTag1.doStartTag();
|
||||
setComponentTagClearTagState(elseIfTag1, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
elseIfTag1.doEndTag();
|
||||
int r3 = elseIfTag2.doStartTag();
|
||||
setComponentTagClearTagState(elseIfTag2, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
elseIfTag2.doEndTag();
|
||||
int r4 = elseIfTag3.doStartTag();
|
||||
setComponentTagClearTagState(elseIfTag3, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
elseIfTag3.doEndTag();
|
||||
|
||||
assertEquals(TagSupport.SKIP_BODY, r1);
|
||||
assertEquals(TagSupport.SKIP_BODY, r2);
|
||||
assertEquals(TagSupport.EVAL_BODY_INCLUDE, r3);
|
||||
assertEquals(TagSupport.SKIP_BODY, r4);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IfTag freshTag = new IfTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(ifTag, freshTag));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ElseIfTag freshTag2 = new ElseIfTag();
|
||||
freshTag2.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag2.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(elseIfTag1, freshTag2));
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(elseIfTag2, freshTag2));
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(elseIfTag3, freshTag2));
|
||||
}
|
||||
|
||||
public void testIfElseIfElse() throws Exception {
|
||||
@@ -255,8 +621,113 @@ public class IfTagTest extends StrutsInternalTestCase {
|
||||
assertEquals(TagSupport.SKIP_BODY, r3);
|
||||
assertEquals(TagSupport.SKIP_BODY, r4);
|
||||
assertEquals(TagSupport.EVAL_BODY_INCLUDE, r5);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IfTag freshTag = new IfTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(ifTag, freshTag));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ElseIfTag freshTag2 = new ElseIfTag();
|
||||
freshTag2.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(elseIfTag1, freshTag2));
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(elseIfTag2, freshTag2));
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(elseIfTag3, freshTag2));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ElseTag freshTag3 = new ElseTag();
|
||||
freshTag3.setPageContext(pageContext);
|
||||
// ElseTag has no additional state, so it compares as equal with the default tag clear state as well.
|
||||
assertTrue("Tag state after doEndTag() under default tag clear state is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(elseTag, freshTag3));
|
||||
}
|
||||
|
||||
public void testIfElseIfElse_clearTagStateSet() throws Exception {
|
||||
IfTag ifTag = new IfTag();
|
||||
ifTag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
ifTag.setPageContext(pageContext);
|
||||
ifTag.setTest("false");
|
||||
|
||||
ElseIfTag elseIfTag1 = new ElseIfTag();
|
||||
elseIfTag1.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
elseIfTag1.setPageContext(pageContext);
|
||||
elseIfTag1.setTest("false");
|
||||
|
||||
ElseIfTag elseIfTag2 = new ElseIfTag();
|
||||
elseIfTag2.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
elseIfTag2.setPageContext(pageContext);
|
||||
elseIfTag2.setTest("false");
|
||||
|
||||
ElseIfTag elseIfTag3 = new ElseIfTag();
|
||||
elseIfTag3.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
elseIfTag3.setPageContext(pageContext);
|
||||
elseIfTag3.setTest("false");
|
||||
|
||||
ElseTag elseTag = new ElseTag();
|
||||
elseTag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
elseTag.setPageContext(pageContext);
|
||||
|
||||
int r1 = ifTag.doStartTag();
|
||||
setComponentTagClearTagState(ifTag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
ifTag.doEndTag();
|
||||
int r2 = elseIfTag1.doStartTag();
|
||||
setComponentTagClearTagState(elseIfTag1, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
elseIfTag1.doEndTag();
|
||||
int r3 = elseIfTag2.doStartTag();
|
||||
setComponentTagClearTagState(elseIfTag2, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
elseIfTag2.doEndTag();
|
||||
int r4 = elseIfTag3.doStartTag();
|
||||
setComponentTagClearTagState(elseIfTag3, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
elseIfTag3.doEndTag();
|
||||
int r5 = elseTag.doStartTag();
|
||||
setComponentTagClearTagState(elseTag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
elseTag.doEndTag();
|
||||
|
||||
assertEquals(TagSupport.SKIP_BODY, r1);
|
||||
assertEquals(TagSupport.SKIP_BODY, r2);
|
||||
assertEquals(TagSupport.SKIP_BODY, r3);
|
||||
assertEquals(TagSupport.SKIP_BODY, r4);
|
||||
assertEquals(TagSupport.EVAL_BODY_INCLUDE, r5);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IfTag freshTag = new IfTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(ifTag, freshTag));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ElseIfTag freshTag2 = new ElseIfTag();
|
||||
freshTag2.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag2.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(elseIfTag1, freshTag2));
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(elseIfTag2, freshTag2));
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(elseIfTag3, freshTag2));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ElseTag freshTag3 = new ElseTag();
|
||||
freshTag3.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag3.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(elseTag, freshTag3));
|
||||
}
|
||||
|
||||
public void testNestedIfElse1() throws Exception {
|
||||
IfTag ifTag = new IfTag();
|
||||
@@ -283,6 +754,76 @@ public class IfTagTest extends StrutsInternalTestCase {
|
||||
assertEquals(TagSupport.EVAL_PAGE, r4);
|
||||
assertEquals(TagSupport.SKIP_BODY, r5);
|
||||
assertEquals(TagSupport.EVAL_PAGE, r6);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IfTag freshTag = new IfTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(ifTag, freshTag));
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(nestedIfTag, freshTag));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ElseTag freshTag2 = new ElseTag();
|
||||
freshTag2.setPageContext(pageContext);
|
||||
// ElseTag has no additional state, so it compares as equal with the default tag clear state as well.
|
||||
assertTrue("Tag state after doEndTag() under default tag clear state is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(elseTag, freshTag2));
|
||||
}
|
||||
|
||||
public void testNestedIfElse1_clearTagStateSet() throws Exception {
|
||||
IfTag ifTag = new IfTag();
|
||||
ifTag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
ifTag.setPageContext(pageContext);
|
||||
ifTag.setTest("true");
|
||||
|
||||
IfTag nestedIfTag = new IfTag();
|
||||
nestedIfTag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
nestedIfTag.setPageContext(pageContext);
|
||||
nestedIfTag.setTest("true");
|
||||
|
||||
ElseTag elseTag = new ElseTag();
|
||||
elseTag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
elseTag.setPageContext(pageContext);
|
||||
|
||||
int r1 = ifTag.doStartTag();
|
||||
setComponentTagClearTagState(ifTag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
int r2 = nestedIfTag.doStartTag();
|
||||
setComponentTagClearTagState(nestedIfTag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
int r3 = nestedIfTag.doEndTag();
|
||||
int r4 = ifTag.doEndTag();
|
||||
int r5 = elseTag.doStartTag();
|
||||
setComponentTagClearTagState(elseTag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
int r6 = elseTag.doEndTag();
|
||||
|
||||
assertEquals(TagSupport.EVAL_BODY_INCLUDE, r1);
|
||||
assertEquals(TagSupport.EVAL_BODY_INCLUDE, r2);
|
||||
assertEquals(TagSupport.EVAL_PAGE, r3);
|
||||
assertEquals(TagSupport.EVAL_PAGE, r4);
|
||||
assertEquals(TagSupport.SKIP_BODY, r5);
|
||||
assertEquals(TagSupport.EVAL_PAGE, r6);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IfTag freshTag = new IfTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(ifTag, freshTag));
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(nestedIfTag, freshTag));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ElseTag freshTag2 = new ElseTag();
|
||||
freshTag2.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag2.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(elseTag, freshTag2));
|
||||
}
|
||||
|
||||
public void testNestedIfElse2() throws Exception {
|
||||
@@ -310,11 +851,97 @@ public class IfTagTest extends StrutsInternalTestCase {
|
||||
assertEquals(TagSupport.EVAL_PAGE, r4);
|
||||
assertEquals(TagSupport.SKIP_BODY, r5);
|
||||
assertEquals(TagSupport.EVAL_PAGE, r6);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IfTag freshTag = new IfTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(ifTag, freshTag));
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(nestedIfTag, freshTag));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ElseTag freshTag2 = new ElseTag();
|
||||
freshTag2.setPageContext(pageContext);
|
||||
// ElseTag has no additional state, so it compares as equal with the default tag clear state as well.
|
||||
assertTrue("Tag state after doEndTag() under default tag clear state is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(elseTag, freshTag2));
|
||||
}
|
||||
|
||||
public void testNestedIfElse2_clearTagStateSet() throws Exception {
|
||||
IfTag ifTag = new IfTag();
|
||||
ifTag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
ifTag.setPageContext(pageContext);
|
||||
ifTag.setTest("true");
|
||||
|
||||
IfTag nestedIfTag = new IfTag();
|
||||
nestedIfTag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
nestedIfTag.setPageContext(pageContext);
|
||||
nestedIfTag.setTest("false");
|
||||
|
||||
ElseTag elseTag = new ElseTag();
|
||||
elseTag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
elseTag.setPageContext(pageContext);
|
||||
|
||||
int r1 = ifTag.doStartTag();
|
||||
setComponentTagClearTagState(ifTag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
int r2 = nestedIfTag.doStartTag();
|
||||
setComponentTagClearTagState(nestedIfTag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
int r3 = nestedIfTag.doEndTag();
|
||||
int r4 = ifTag.doEndTag();
|
||||
int r5 = elseTag.doStartTag();
|
||||
setComponentTagClearTagState(elseTag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
int r6 = elseTag.doEndTag();
|
||||
|
||||
assertEquals(TagSupport.EVAL_BODY_INCLUDE, r1);
|
||||
assertEquals(TagSupport.SKIP_BODY, r2);
|
||||
assertEquals(TagSupport.EVAL_PAGE, r3);
|
||||
assertEquals(TagSupport.EVAL_PAGE, r4);
|
||||
assertEquals(TagSupport.SKIP_BODY, r5);
|
||||
assertEquals(TagSupport.EVAL_PAGE, r6);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IfTag freshTag = new IfTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(ifTag, freshTag));
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(nestedIfTag, freshTag));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ElseTag freshTag2 = new ElseTag();
|
||||
freshTag2.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag2.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(elseTag, freshTag2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to simplify setting the performClearTagStateForTagPoolingServers state for a
|
||||
* {@link ComponentTagSupport} tag's {@link Component} to match expecations for a test.
|
||||
*
|
||||
* Since the component is not available to the tag until after the doStartTag() method is called,
|
||||
* but we need to ensure the component's {@link Component#performClearTagStateForTagPoolingServers} state matches
|
||||
* what we set for the Tag when a non-default (true) value is used, this method retrieves the component instance,
|
||||
* sets the value specified and forces the parameters to be repopulated again.
|
||||
*
|
||||
* @param tag The ComponentTagSupport tag upon whose component we will set the performClearTagStateForTagPoolingServers state.
|
||||
* @param performClearTagStateForTagPoolingServers true to clear tag state, false otherwise
|
||||
*/
|
||||
protected void setComponentTagClearTagState(ComponentTagSupport tag, boolean performClearTagStateForTagPoolingServers) {
|
||||
tag.component.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
//tag.populateParams(); // Not safe to call after doStartTag() ... breaks some tests.
|
||||
tag.populatePerformClearTagStateForTagPoolingServersParam(); // Only populate the performClearTagStateForTagPoolingServers parameter for the Tag.
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
// create the needed objects
|
||||
|
||||
@@ -65,6 +65,41 @@ public class IncludeTagTest extends AbstractTagTest {
|
||||
assertEquals("", writer.toString());
|
||||
|
||||
verify(mockRequestDispatcher);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IncludeTag freshTag = new IncludeTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testIncludeNoParam_clearTagStateSet() throws Exception {
|
||||
|
||||
// Use always matcher as we can not determine the exact objects used in mock.include(request, response) call
|
||||
mockRequestDispatcher.include(anyObject(ServletRequest.class), anyObject(ServletResponse.class));
|
||||
expectLastCall().times(1);
|
||||
|
||||
replay(mockRequestDispatcher);
|
||||
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setValue("person/list.jsp");
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals("/person/list.jsp", request.getRequestDispatherString());
|
||||
assertEquals("", writer.toString());
|
||||
|
||||
verify(mockRequestDispatcher);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IncludeTag freshTag = new IncludeTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testIncludeWithParameters() throws Exception {
|
||||
@@ -86,6 +121,44 @@ public class IncludeTagTest extends AbstractTagTest {
|
||||
assertEquals("", writer.toString());
|
||||
|
||||
verify(mockRequestDispatcher);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IncludeTag freshTag = new IncludeTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testIncludeWithParameters_clearTagStateSet() throws Exception {
|
||||
|
||||
// Use always matcher as we can not determine the exact objects used in mock.include(request, response) call
|
||||
mockRequestDispatcher.include(anyObject(ServletRequest.class), anyObject(ServletResponse.class));
|
||||
expectLastCall().times(1);
|
||||
|
||||
replay(mockRequestDispatcher);
|
||||
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setValue("person/create.jsp");
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
// adding param must be done after doStartTag()
|
||||
Include include = (Include) tag.getComponent();
|
||||
include.addParameter("user", "Santa Claus");
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals("/person/create.jsp?user=Santa+Claus", request.getRequestDispatherString());
|
||||
assertEquals("", writer.toString());
|
||||
|
||||
verify(mockRequestDispatcher);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IncludeTag freshTag = new IncludeTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testIncludeRelative2Dots() throws Exception {
|
||||
@@ -105,7 +178,44 @@ public class IncludeTagTest extends AbstractTagTest {
|
||||
assertEquals("/car/view.jsp", request.getRequestDispatherString());
|
||||
assertEquals("", writer.toString());
|
||||
|
||||
verify(mockRequestDispatcher);
|
||||
verify(mockRequestDispatcher);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IncludeTag freshTag = new IncludeTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testIncludeRelative2Dots_clearTagStateSet() throws Exception {
|
||||
// TODO: we should test for .. in unit test - is this test correct?
|
||||
// Use always matcher as we can not determine the exact objects used in mock.include(request, response) call
|
||||
mockRequestDispatcher.include(anyObject(ServletRequest.class), anyObject(ServletResponse.class));
|
||||
expectLastCall().times(1);
|
||||
|
||||
replay(mockRequestDispatcher);
|
||||
|
||||
request.setupGetServletPath("app/manager");
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setValue("../car/view.jsp");
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
|
||||
assertEquals("/car/view.jsp", request.getRequestDispatherString());
|
||||
assertEquals("", writer.toString());
|
||||
|
||||
verify(mockRequestDispatcher);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IncludeTag freshTag = new IncludeTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testIncludeSetUseResponseEncodingTrue() throws Exception {
|
||||
@@ -133,6 +243,50 @@ public class IncludeTagTest extends AbstractTagTest {
|
||||
assertEquals("", writer.toString()); // Nothing gets written for mock-include
|
||||
|
||||
verify(mockRequestDispatcher);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IncludeTag freshTag = new IncludeTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testIncludeSetUseResponseEncodingTrue_clearTagStateSet() throws Exception {
|
||||
// TODO: If possible in future mock-test an actual content-includes with various encodings
|
||||
// while setting the response encoding to match. Doesn't appear to be possible
|
||||
// right now in unit-test form.
|
||||
// Seems that the best we can do is verify the setUseResponseEncoding() doesn't fail...
|
||||
|
||||
// Use always matcher as we can not determine the exact objects used in mock.include(request, response) call
|
||||
mockRequestDispatcher.include(anyObject(ServletRequest.class), anyObject(ServletResponse.class));
|
||||
expectLastCall().times(1);
|
||||
|
||||
replay(mockRequestDispatcher);
|
||||
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setValue("person/create.jsp");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
// Manipulate after doStartTag to ensure the tag component has undergone injection
|
||||
Include include = (Include) tag.getComponent();
|
||||
include.setUseResponseEncoding("true");
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals("UTF-8", response.getCharacterEncoding());
|
||||
assertEquals("/person/create.jsp", request.getRequestDispatherString());
|
||||
assertEquals("", writer.toString()); // Nothing gets written for mock-include
|
||||
|
||||
verify(mockRequestDispatcher);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IncludeTag freshTag = new IncludeTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testIncludeSetUseResponseEncodingFalse() throws Exception {
|
||||
@@ -160,8 +314,53 @@ public class IncludeTagTest extends AbstractTagTest {
|
||||
assertEquals("", writer.toString()); // Nothing gets written for mock-include
|
||||
|
||||
verify(mockRequestDispatcher);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IncludeTag freshTag = new IncludeTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testIncludeSetUseResponseEncodingFalse_clearTagStateSet() throws Exception {
|
||||
// TODO: If possible in future mock-test an actual content-includes with various encodings
|
||||
// while setting the response encoding to match. Doesn't appear to be possible
|
||||
// right now in unit-test form.
|
||||
// Seems that the best we can do is verify the setUseResponseEncoding() doesn't fail...
|
||||
|
||||
// Use always matcher as we can not determine the exact objects used in mock.include(request, response) call
|
||||
mockRequestDispatcher.include(anyObject(ServletRequest.class), anyObject(ServletResponse.class));
|
||||
expectLastCall().times(1);
|
||||
|
||||
replay(mockRequestDispatcher);
|
||||
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setValue("person/create.jsp");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
// Manipulate after doStartTag to ensure the tag component has undergone injection
|
||||
Include include = (Include) tag.getComponent();
|
||||
include.setUseResponseEncoding("false");
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals("UTF-8", response.getCharacterEncoding());
|
||||
assertEquals("/person/create.jsp", request.getRequestDispatherString());
|
||||
assertEquals("", writer.toString()); // Nothing gets written for mock-include
|
||||
|
||||
verify(mockRequestDispatcher);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IncludeTag freshTag = new IncludeTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
request.setupGetRequestDispatcher(new MockRequestDispatcher());
|
||||
@@ -174,6 +373,7 @@ public class IncludeTagTest extends AbstractTagTest {
|
||||
tag.setPageContext(pageContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
tag = null;
|
||||
|
||||
@@ -65,6 +65,57 @@ public class IteratorGeneratorTagTest extends AbstractTagTest {
|
||||
|
||||
|
||||
assertNotSame(afterTopOfStack, topOfStack);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IteratorGeneratorTag freshTag = new IteratorGeneratorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testGeneratorBasic_clearTagStateSet() throws Exception {
|
||||
IteratorGeneratorTag tag = new IteratorGeneratorTag();
|
||||
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setVal("%{'aaa,bbb,ccc,ddd,eee'}");
|
||||
tag.doStartTag();
|
||||
Object topOfStack = stack.findValue("top");
|
||||
|
||||
|
||||
assertTrue(topOfStack instanceof Iterator);
|
||||
// 1
|
||||
assertTrue(((Iterator)topOfStack).hasNext());
|
||||
assertEquals(((Iterator)topOfStack).next(), "aaa");
|
||||
// 2
|
||||
assertTrue(((Iterator)topOfStack).hasNext());
|
||||
assertEquals(((Iterator)topOfStack).next(), "bbb");
|
||||
// 3
|
||||
assertTrue(((Iterator)topOfStack).hasNext());
|
||||
assertEquals(((Iterator)topOfStack).next(), "ccc");
|
||||
// 4
|
||||
assertTrue(((Iterator)topOfStack).hasNext());
|
||||
assertEquals(((Iterator)topOfStack).next(), "ddd");
|
||||
// 5
|
||||
assertTrue(((Iterator)topOfStack).hasNext());
|
||||
assertEquals(((Iterator)topOfStack).next(),"eee");
|
||||
|
||||
assertFalse(((Iterator)topOfStack).hasNext());
|
||||
|
||||
tag.doEndTag();
|
||||
Object afterTopOfStack = stack.findValue("top");
|
||||
|
||||
|
||||
assertNotSame(afterTopOfStack, topOfStack);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IteratorGeneratorTag freshTag = new IteratorGeneratorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testGeneratorWithSeparator() throws Exception {
|
||||
@@ -97,6 +148,54 @@ public class IteratorGeneratorTagTest extends AbstractTagTest {
|
||||
|
||||
assertFalse(((Iterator)topOfStack).hasNext());
|
||||
assertNotSame(afterTopOfStack, topOfStack);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IteratorGeneratorTag freshTag = new IteratorGeneratorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testGeneratorWithSeparator_clearTagStateSet() throws Exception {
|
||||
IteratorGeneratorTag tag = new IteratorGeneratorTag();
|
||||
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setVal("%{'aaa|bbb|ccc|ddd|eee'}");
|
||||
tag.setSeparator("|");
|
||||
tag.doStartTag();
|
||||
Object topOfStack = stack.findValue("top");
|
||||
tag.doEndTag();
|
||||
Object afterTopOfStack = stack.findValue("top");
|
||||
|
||||
assertTrue(topOfStack instanceof Iterator);
|
||||
// 1
|
||||
assertTrue(((Iterator)topOfStack).hasNext());
|
||||
assertEquals(((Iterator)topOfStack).next(), "aaa");
|
||||
// 2
|
||||
assertTrue(((Iterator)topOfStack).hasNext());
|
||||
assertEquals(((Iterator)topOfStack).next(), "bbb");
|
||||
// 3
|
||||
assertTrue(((Iterator)topOfStack).hasNext());
|
||||
assertEquals(((Iterator)topOfStack).next(), "ccc");
|
||||
// 4
|
||||
assertTrue(((Iterator)topOfStack).hasNext());
|
||||
assertEquals(((Iterator)topOfStack).next(), "ddd");
|
||||
// 5
|
||||
assertTrue(((Iterator)topOfStack).hasNext());
|
||||
assertEquals(((Iterator)topOfStack).next(), "eee");
|
||||
|
||||
assertFalse(((Iterator)topOfStack).hasNext());
|
||||
assertNotSame(afterTopOfStack, topOfStack);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IteratorGeneratorTag freshTag = new IteratorGeneratorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testGeneratorWithConverter() throws Exception {
|
||||
@@ -129,6 +228,54 @@ public class IteratorGeneratorTagTest extends AbstractTagTest {
|
||||
|
||||
assertFalse(((Iterator)topOfStack).hasNext());
|
||||
assertNotSame(afterTopOfStack, topOfStack);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IteratorGeneratorTag freshTag = new IteratorGeneratorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testGeneratorWithConverter_clearTagStateSet() throws Exception {
|
||||
IteratorGeneratorTag tag = new IteratorGeneratorTag();
|
||||
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setVal("%{'aaa, bbb, ccc, ddd, eee'}");
|
||||
tag.setConverter("myConverter");
|
||||
tag.doStartTag();
|
||||
Object topOfStack = stack.findValue("top");
|
||||
tag.doEndTag();
|
||||
Object afterTopOfStack = stack.findValue("top");
|
||||
|
||||
assertTrue(topOfStack instanceof Iterator);
|
||||
// 1.
|
||||
assertTrue(((Iterator)topOfStack).hasNext());
|
||||
assertEquals(((Iterator)topOfStack).next(), "myConverter-aaa");
|
||||
// 2
|
||||
assertTrue(((Iterator)topOfStack).hasNext());
|
||||
assertEquals(((Iterator)topOfStack).next(), "myConverter-bbb");
|
||||
// 3
|
||||
assertTrue(((Iterator)topOfStack).hasNext());
|
||||
assertEquals(((Iterator)topOfStack).next(), "myConverter-ccc");
|
||||
// 4.
|
||||
assertTrue(((Iterator)topOfStack).hasNext());
|
||||
assertEquals(((Iterator)topOfStack).next(), "myConverter-ddd");
|
||||
// 5.
|
||||
assertTrue(((Iterator)topOfStack).hasNext());
|
||||
assertEquals(((Iterator)topOfStack).next(), "myConverter-eee");
|
||||
|
||||
assertFalse(((Iterator)topOfStack).hasNext());
|
||||
assertNotSame(afterTopOfStack, topOfStack);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IteratorGeneratorTag freshTag = new IteratorGeneratorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testGeneratorWithId() throws Exception {
|
||||
@@ -159,6 +306,52 @@ public class IteratorGeneratorTagTest extends AbstractTagTest {
|
||||
assertEquals(((Iterator)pageContextIterator).next(), "eee");
|
||||
|
||||
assertFalse(((Iterator)pageContextIterator).hasNext());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IteratorGeneratorTag freshTag = new IteratorGeneratorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testGeneratorWithId_clearTagStateSet() throws Exception {
|
||||
IteratorGeneratorTag tag = new IteratorGeneratorTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setVal("%{'aaa,bbb,ccc,ddd,eee'}");
|
||||
tag.setVar("myPageContextAttId");
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
|
||||
Object pageContextIterator = stack.findValue("myPageContextAttId");
|
||||
|
||||
assertTrue(pageContextIterator instanceof Iterator);
|
||||
// 1
|
||||
assertTrue(((Iterator)pageContextIterator).hasNext());
|
||||
assertEquals(((Iterator)pageContextIterator).next(), "aaa");
|
||||
// 2.
|
||||
assertTrue(((Iterator)pageContextIterator).hasNext());
|
||||
assertEquals(((Iterator)pageContextIterator).next(), "bbb");
|
||||
// 3.
|
||||
assertTrue(((Iterator)pageContextIterator).hasNext());
|
||||
assertEquals(((Iterator)pageContextIterator).next(), "ccc");
|
||||
// 4
|
||||
assertTrue(((Iterator)pageContextIterator).hasNext());
|
||||
assertEquals(((Iterator)pageContextIterator).next(), "ddd");
|
||||
// 5
|
||||
assertTrue(((Iterator)pageContextIterator).hasNext());
|
||||
assertEquals(((Iterator)pageContextIterator).next(), "eee");
|
||||
|
||||
assertFalse(((Iterator)pageContextIterator).hasNext());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IteratorGeneratorTag freshTag = new IteratorGeneratorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testGeneratorWithCount() throws Exception {
|
||||
@@ -186,9 +379,52 @@ public class IteratorGeneratorTagTest extends AbstractTagTest {
|
||||
|
||||
assertFalse(((Iterator)topOfStack).hasNext());
|
||||
assertNotSame(topOfStack, afterTopOfStack);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IteratorGeneratorTag freshTag = new IteratorGeneratorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testGeneratorWithCount_clearTagStateSet() throws Exception {
|
||||
IteratorGeneratorTag tag = new IteratorGeneratorTag();
|
||||
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setVal("%{'aaa,bbb,ccc,ddd,eee'}");
|
||||
tag.setCount("myCount");
|
||||
tag.doStartTag();
|
||||
Object topOfStack = stack.findValue("top");
|
||||
tag.doEndTag();
|
||||
Object afterTopOfStack = stack.findValue("top");
|
||||
|
||||
|
||||
assertTrue(topOfStack instanceof Iterator);
|
||||
// 1
|
||||
assertTrue(((Iterator)topOfStack).hasNext());
|
||||
assertEquals(((Iterator)topOfStack).next(), "aaa");
|
||||
// 2
|
||||
assertTrue(((Iterator)topOfStack).hasNext());
|
||||
assertEquals(((Iterator)topOfStack).next(), "bbb");
|
||||
// 3.
|
||||
assertTrue(((Iterator)topOfStack).hasNext());
|
||||
assertEquals(((Iterator)topOfStack).next(), "ccc");
|
||||
|
||||
assertFalse(((Iterator)topOfStack).hasNext());
|
||||
assertNotSame(topOfStack, afterTopOfStack);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IteratorGeneratorTag freshTag = new IteratorGeneratorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Action getAction() {
|
||||
return new ActionSupport() {
|
||||
public Converter getMyConverter() {
|
||||
|
||||
@@ -59,7 +59,7 @@ public class IteratorTagTest extends AbstractUITagTest {
|
||||
|
||||
// one
|
||||
int result = tag.doStartTag();
|
||||
assertEquals(result, TagSupport.EVAL_BODY_INCLUDE);
|
||||
assertEquals(TagSupport.EVAL_BODY_INCLUDE, result);
|
||||
assertEquals(stack.peek(), "one");
|
||||
assertEquals(stack.getContext().get("myId"), "one");
|
||||
|
||||
@@ -68,39 +68,116 @@ public class IteratorTagTest extends AbstractUITagTest {
|
||||
|
||||
// two
|
||||
result = tag.doAfterBody();
|
||||
assertEquals(result, TagSupport.EVAL_BODY_AGAIN);
|
||||
assertEquals(TagSupport.EVAL_BODY_AGAIN, result);
|
||||
assertEquals(stack.peek(), "two");
|
||||
assertEquals(stack.getContext().get("myId"), "two");
|
||||
|
||||
|
||||
// three
|
||||
result = tag.doAfterBody();
|
||||
assertEquals(result, TagSupport.EVAL_BODY_AGAIN);
|
||||
assertEquals(TagSupport.EVAL_BODY_AGAIN, result);
|
||||
assertEquals(stack.peek(), "three");
|
||||
assertEquals(stack.getContext().get("myId"), "three");
|
||||
|
||||
|
||||
// four
|
||||
result = tag.doAfterBody();
|
||||
assertEquals(result, TagSupport.EVAL_BODY_AGAIN);
|
||||
assertEquals(TagSupport.EVAL_BODY_AGAIN, result);
|
||||
assertEquals(stack.peek(), "four");
|
||||
assertEquals(stack.getContext().get("myId"), "four");
|
||||
|
||||
|
||||
// five
|
||||
result = tag.doAfterBody();
|
||||
assertEquals(result, TagSupport.EVAL_BODY_AGAIN);
|
||||
assertEquals(TagSupport.EVAL_BODY_AGAIN, result);
|
||||
assertEquals(stack.peek(), "five");
|
||||
assertEquals(stack.getContext().get("myId"), "five");
|
||||
|
||||
|
||||
result = tag.doAfterBody();
|
||||
assertEquals(result, TagSupport.SKIP_BODY);
|
||||
assertEquals(TagSupport.SKIP_BODY, result);
|
||||
|
||||
result = tag.doEndTag();
|
||||
assertEquals(result, TagSupport.EVAL_PAGE);
|
||||
assertEquals(TagSupport.EVAL_PAGE, result);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IteratorTag freshTag = new IteratorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
|
||||
public void testIteratingWithIdSpecified_clearTagStateSet() throws Exception {
|
||||
List list = new ArrayList();
|
||||
list.add("one");
|
||||
list.add("two");
|
||||
list.add("three");
|
||||
list.add("four");
|
||||
list.add("five");
|
||||
|
||||
Foo foo = new Foo();
|
||||
foo.setList(list);
|
||||
|
||||
stack.push(foo);
|
||||
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setValue("list");
|
||||
tag.setVar("myId");
|
||||
|
||||
// one
|
||||
int result = tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
assertEquals(TagSupport.EVAL_BODY_INCLUDE, result);
|
||||
assertEquals(stack.peek(), "one");
|
||||
assertEquals(stack.getContext().get("myId"), "one");
|
||||
|
||||
|
||||
tag.doInitBody();
|
||||
|
||||
// two
|
||||
result = tag.doAfterBody();
|
||||
assertEquals(TagSupport.EVAL_BODY_AGAIN, result);
|
||||
assertEquals(stack.peek(), "two");
|
||||
assertEquals(stack.getContext().get("myId"), "two");
|
||||
|
||||
|
||||
// three
|
||||
result = tag.doAfterBody();
|
||||
assertEquals(TagSupport.EVAL_BODY_AGAIN, result);
|
||||
assertEquals(stack.peek(), "three");
|
||||
assertEquals(stack.getContext().get("myId"), "three");
|
||||
|
||||
|
||||
// four
|
||||
result = tag.doAfterBody();
|
||||
assertEquals(TagSupport.EVAL_BODY_AGAIN, result);
|
||||
assertEquals(stack.peek(), "four");
|
||||
assertEquals(stack.getContext().get("myId"), "four");
|
||||
|
||||
|
||||
// five
|
||||
result = tag.doAfterBody();
|
||||
assertEquals(TagSupport.EVAL_BODY_AGAIN, result);
|
||||
assertEquals(stack.peek(), "five");
|
||||
assertEquals(stack.getContext().get("myId"), "five");
|
||||
|
||||
|
||||
result = tag.doAfterBody();
|
||||
assertEquals(TagSupport.SKIP_BODY, result);
|
||||
|
||||
result = tag.doEndTag();
|
||||
assertEquals(TagSupport.EVAL_PAGE, result);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IteratorTag freshTag = new IteratorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testIteratingWithIdSpecifiedAndNullElementOnCollection() throws Exception {
|
||||
List list = new ArrayList();
|
||||
list.add("one");
|
||||
@@ -117,7 +194,7 @@ public class IteratorTagTest extends AbstractUITagTest {
|
||||
|
||||
// one
|
||||
int result = tag.doStartTag();
|
||||
assertEquals(result, TagSupport.EVAL_BODY_INCLUDE);
|
||||
assertEquals(TagSupport.EVAL_BODY_INCLUDE, result);
|
||||
assertEquals(stack.peek(), "one");
|
||||
assertEquals(stack.getContext().get("myId"), "one");
|
||||
|
||||
@@ -126,24 +203,83 @@ public class IteratorTagTest extends AbstractUITagTest {
|
||||
|
||||
// two
|
||||
result = tag.doAfterBody();
|
||||
assertEquals(result, TagSupport.EVAL_BODY_AGAIN);
|
||||
assertEquals(TagSupport.EVAL_BODY_AGAIN, result);
|
||||
assertNull(stack.peek());
|
||||
assertNull(stack.getContext().get("myId"));
|
||||
|
||||
|
||||
// three
|
||||
result = tag.doAfterBody();
|
||||
assertEquals(result, TagSupport.EVAL_BODY_AGAIN);
|
||||
assertEquals(TagSupport.EVAL_BODY_AGAIN, result);
|
||||
assertEquals(stack.peek(), "three");
|
||||
assertEquals(stack.getContext().get("myId"), "three");
|
||||
|
||||
result = tag.doAfterBody();
|
||||
assertEquals(result, TagSupport.SKIP_BODY);
|
||||
assertEquals(TagSupport.SKIP_BODY, result);
|
||||
|
||||
result = tag.doEndTag();
|
||||
assertEquals(result, TagSupport.EVAL_PAGE);
|
||||
assertEquals(TagSupport.EVAL_PAGE, result);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IteratorTag freshTag = new IteratorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testIteratingWithIdSpecifiedAndNullElementOnCollection_clearTagStateSet() throws Exception {
|
||||
List list = new ArrayList();
|
||||
list.add("one");
|
||||
list.add(null);
|
||||
list.add("three");
|
||||
|
||||
Foo foo = new Foo();
|
||||
foo.setList(list);
|
||||
|
||||
stack.push(foo);
|
||||
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setValue("list");
|
||||
tag.setVar("myId");
|
||||
|
||||
// one
|
||||
int result = tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
assertEquals(TagSupport.EVAL_BODY_INCLUDE, result);
|
||||
assertEquals(stack.peek(), "one");
|
||||
assertEquals(stack.getContext().get("myId"), "one");
|
||||
|
||||
|
||||
tag.doInitBody();
|
||||
|
||||
// two
|
||||
result = tag.doAfterBody();
|
||||
assertEquals(TagSupport.EVAL_BODY_AGAIN, result);
|
||||
assertNull(stack.peek());
|
||||
assertNull(stack.getContext().get("myId"));
|
||||
|
||||
|
||||
// three
|
||||
result = tag.doAfterBody();
|
||||
assertEquals(TagSupport.EVAL_BODY_AGAIN, result);
|
||||
assertEquals(stack.peek(), "three");
|
||||
assertEquals(stack.getContext().get("myId"), "three");
|
||||
|
||||
result = tag.doAfterBody();
|
||||
assertEquals(TagSupport.SKIP_BODY, result);
|
||||
|
||||
result = tag.doEndTag();
|
||||
assertEquals(TagSupport.EVAL_PAGE, result);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IteratorTag freshTag = new IteratorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testArrayIterator() {
|
||||
Foo foo = new Foo();
|
||||
@@ -232,6 +368,99 @@ public class IteratorTagTest extends AbstractUITagTest {
|
||||
|
||||
assertEquals(TagSupport.SKIP_BODY, result);
|
||||
assertEquals(3, stack.size());
|
||||
|
||||
try {
|
||||
result = tag.doEndTag();
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
assertEquals(TagSupport.EVAL_PAGE, result);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IteratorTag freshTag = new IteratorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testMapIterator_clearTagStateSet() {
|
||||
Foo foo = new Foo();
|
||||
HashMap map = new HashMap();
|
||||
map.put("test1", "123");
|
||||
map.put("test2", "456");
|
||||
map.put("test3", "789");
|
||||
foo.setMap(map);
|
||||
|
||||
stack.push(foo);
|
||||
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setValue("map");
|
||||
|
||||
int result = 0;
|
||||
|
||||
try {
|
||||
result = tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
assertEquals(TagSupport.EVAL_BODY_INCLUDE, result);
|
||||
assertEquals(4, stack.size());
|
||||
assertTrue(stack.getRoot().peek() instanceof Map.Entry);
|
||||
|
||||
try {
|
||||
result = tag.doAfterBody();
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
assertEquals(TagSupport.EVAL_BODY_AGAIN, result);
|
||||
assertEquals(4, stack.size());
|
||||
assertTrue(stack.getRoot().peek() instanceof Map.Entry);
|
||||
|
||||
try {
|
||||
result = tag.doAfterBody();
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
assertEquals(TagSupport.EVAL_BODY_AGAIN, result);
|
||||
assertEquals(4, stack.size());
|
||||
assertTrue(stack.getRoot().peek() instanceof Map.Entry);
|
||||
|
||||
try {
|
||||
result = tag.doAfterBody();
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
assertEquals(TagSupport.SKIP_BODY, result);
|
||||
assertEquals(3, stack.size());
|
||||
|
||||
try {
|
||||
result = tag.doEndTag();
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
assertEquals(TagSupport.EVAL_PAGE, result);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IteratorTag freshTag = new IteratorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testStatus() {
|
||||
@@ -252,7 +481,7 @@ public class IteratorTagTest extends AbstractUITagTest {
|
||||
fail();
|
||||
}
|
||||
|
||||
assertEquals(result, TagSupport.EVAL_BODY_INCLUDE);
|
||||
assertEquals(TagSupport.EVAL_BODY_INCLUDE, result);
|
||||
assertEquals("test1", stack.getRoot().peek());
|
||||
assertEquals(4, stack.size());
|
||||
|
||||
@@ -272,7 +501,7 @@ public class IteratorTagTest extends AbstractUITagTest {
|
||||
fail();
|
||||
}
|
||||
|
||||
assertEquals(result, TagSupport.EVAL_BODY_AGAIN);
|
||||
assertEquals(TagSupport.EVAL_BODY_AGAIN, result);
|
||||
assertEquals("test2", stack.getRoot().peek());
|
||||
assertEquals(4, stack.size());
|
||||
|
||||
@@ -292,7 +521,7 @@ public class IteratorTagTest extends AbstractUITagTest {
|
||||
fail();
|
||||
}
|
||||
|
||||
assertEquals(result, TagSupport.EVAL_BODY_AGAIN);
|
||||
assertEquals(TagSupport.EVAL_BODY_AGAIN, result);
|
||||
assertEquals("test3", stack.getRoot().peek());
|
||||
assertEquals(4, stack.size());
|
||||
|
||||
@@ -304,6 +533,113 @@ public class IteratorTagTest extends AbstractUITagTest {
|
||||
assertEquals(3, status.getCount());
|
||||
assertTrue(status.isOdd());
|
||||
assertFalse(status.isEven());
|
||||
|
||||
try {
|
||||
result = tag.doEndTag();
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
assertEquals(TagSupport.EVAL_PAGE, result);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IteratorTag freshTag = new IteratorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testStatus_clearTagStateSet() {
|
||||
Foo foo = new Foo();
|
||||
foo.setArray(new String[]{"test1", "test2", "test3"});
|
||||
|
||||
stack.push(foo);
|
||||
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setValue("array");
|
||||
tag.setStatus("fooStatus");
|
||||
|
||||
int result = 0;
|
||||
|
||||
try {
|
||||
result = tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
assertEquals(TagSupport.EVAL_BODY_INCLUDE, result);
|
||||
assertEquals("test1", stack.getRoot().peek());
|
||||
assertEquals(4, stack.size());
|
||||
|
||||
IteratorStatus status = (IteratorStatus) context.get("fooStatus");
|
||||
assertNotNull(status);
|
||||
assertFalse(status.isLast());
|
||||
assertTrue(status.isFirst());
|
||||
assertEquals(0, status.getIndex());
|
||||
assertEquals(1, status.getCount());
|
||||
assertTrue(status.isOdd());
|
||||
assertFalse(status.isEven());
|
||||
|
||||
try {
|
||||
result = tag.doAfterBody();
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
assertEquals(TagSupport.EVAL_BODY_AGAIN, result);
|
||||
assertEquals("test2", stack.getRoot().peek());
|
||||
assertEquals(4, stack.size());
|
||||
|
||||
status = (IteratorStatus) context.get("fooStatus");
|
||||
assertNotNull(status);
|
||||
assertFalse(status.isLast());
|
||||
assertFalse(status.isFirst());
|
||||
assertEquals(1, status.getIndex());
|
||||
assertEquals(2, status.getCount());
|
||||
assertFalse(status.isOdd());
|
||||
assertTrue(status.isEven());
|
||||
|
||||
try {
|
||||
result = tag.doAfterBody();
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
assertEquals(TagSupport.EVAL_BODY_AGAIN, result);
|
||||
assertEquals("test3", stack.getRoot().peek());
|
||||
assertEquals(4, stack.size());
|
||||
|
||||
status = (IteratorStatus) context.get("fooStatus");
|
||||
assertNotNull(status);
|
||||
assertTrue(status.isLast());
|
||||
assertFalse(status.isFirst());
|
||||
assertEquals(2, status.getIndex());
|
||||
assertEquals(3, status.getCount());
|
||||
assertTrue(status.isOdd());
|
||||
assertFalse(status.isEven());
|
||||
|
||||
try {
|
||||
result = tag.doEndTag();
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
assertEquals(TagSupport.EVAL_PAGE, result);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IteratorTag freshTag = new IteratorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testEmptyArray() {
|
||||
@@ -661,7 +997,7 @@ public class IteratorTagTest extends AbstractUITagTest {
|
||||
List values = new ArrayList();
|
||||
try {
|
||||
int result = tag.doStartTag();
|
||||
assertEquals(result, TagSupport.EVAL_BODY_INCLUDE);
|
||||
assertEquals(TagSupport.EVAL_BODY_INCLUDE, result);
|
||||
values.add(stack.getRoot().peek());
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
@@ -676,6 +1012,7 @@ public class IteratorTagTest extends AbstractUITagTest {
|
||||
ListUtils.isEqualList(Arrays.asList(expectedValues), values);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
@@ -700,7 +1037,7 @@ public class IteratorTagTest extends AbstractUITagTest {
|
||||
fail();
|
||||
}
|
||||
|
||||
assertEquals(result, TagSupport.EVAL_BODY_INCLUDE);
|
||||
assertEquals(TagSupport.EVAL_BODY_INCLUDE, result);
|
||||
assertEquals("test1", stack.getRoot().peek());
|
||||
assertEquals(4, stack.size());
|
||||
|
||||
@@ -711,7 +1048,7 @@ public class IteratorTagTest extends AbstractUITagTest {
|
||||
fail();
|
||||
}
|
||||
|
||||
assertEquals(result, TagSupport.EVAL_BODY_AGAIN);
|
||||
assertEquals(TagSupport.EVAL_BODY_AGAIN, result);
|
||||
assertEquals("test2", stack.getRoot().peek());
|
||||
assertEquals(4, stack.size());
|
||||
|
||||
@@ -722,7 +1059,7 @@ public class IteratorTagTest extends AbstractUITagTest {
|
||||
fail();
|
||||
}
|
||||
|
||||
assertEquals(result, TagSupport.EVAL_BODY_AGAIN);
|
||||
assertEquals(TagSupport.EVAL_BODY_AGAIN, result);
|
||||
assertEquals("test3", stack.getRoot().peek());
|
||||
assertEquals(4, stack.size());
|
||||
|
||||
@@ -733,7 +1070,7 @@ public class IteratorTagTest extends AbstractUITagTest {
|
||||
fail();
|
||||
}
|
||||
|
||||
assertEquals(result, TagSupport.SKIP_BODY);
|
||||
assertEquals(TagSupport.SKIP_BODY, result);
|
||||
assertEquals(3, stack.size());
|
||||
}
|
||||
|
||||
@@ -747,13 +1084,22 @@ public class IteratorTagTest extends AbstractUITagTest {
|
||||
fail();
|
||||
}
|
||||
|
||||
assertEquals(result, TagSupport.SKIP_BODY);
|
||||
assertEquals(TagSupport.SKIP_BODY, result);
|
||||
try {
|
||||
result = tag.doEndTag();
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
assertEquals(TagSupport.EVAL_PAGE, result);
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
IteratorTag freshTag = new IteratorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
class Foo {
|
||||
|
||||
@@ -82,8 +82,108 @@ public class MergeIteratorTagTest extends AbstractTagTest {
|
||||
assertTrue(mergedIterator.hasNext());
|
||||
assertEquals(mergedIterator.next(), "C");
|
||||
assertFalse(mergedIterator.hasNext());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ParamTag freshParamTag = new ParamTag();
|
||||
freshParamTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(iterator1ParamTag, freshParamTag));
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(iterator2ParamTag, freshParamTag));
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(iterator3ParamTag, freshParamTag));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
MergeIteratorTag freshTag = new MergeIteratorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testMergingIteratorWithArrayAsSource_clearTagStateSet() throws Exception {
|
||||
MergeIteratorTag tag = new MergeIteratorTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setVar("myMergedIterator");
|
||||
|
||||
ParamTag iterator1ParamTag = new ParamTag();
|
||||
iterator1ParamTag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
iterator1ParamTag.setPageContext(pageContext);
|
||||
iterator1ParamTag.setValue("myArr1");
|
||||
|
||||
ParamTag iterator2ParamTag = new ParamTag();
|
||||
iterator2ParamTag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
iterator2ParamTag.setPageContext(pageContext);
|
||||
iterator2ParamTag.setValue("myArr2");
|
||||
|
||||
ParamTag iterator3ParamTag = new ParamTag();
|
||||
iterator3ParamTag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
iterator3ParamTag.setPageContext(pageContext);
|
||||
iterator3ParamTag.setValue("myArr3");
|
||||
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
iterator1ParamTag.doStartTag();
|
||||
setComponentTagClearTagState(iterator1ParamTag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
iterator1ParamTag.doEndTag();
|
||||
iterator2ParamTag.doStartTag();
|
||||
setComponentTagClearTagState(iterator2ParamTag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
iterator2ParamTag.doEndTag();
|
||||
iterator3ParamTag.doStartTag();
|
||||
setComponentTagClearTagState(iterator3ParamTag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
iterator3ParamTag.doEndTag();
|
||||
tag.doEndTag();
|
||||
|
||||
Iterator mergedIterator = (Iterator) stack.findValue("#myMergedIterator"); // if not iterator, let CCE surface
|
||||
|
||||
assertNotNull(mergedIterator);
|
||||
assertTrue(mergedIterator.hasNext());
|
||||
assertEquals(mergedIterator.next(), "1");
|
||||
assertTrue(mergedIterator.hasNext());
|
||||
assertEquals(mergedIterator.next(), "a");
|
||||
assertTrue(mergedIterator.hasNext());
|
||||
assertEquals(mergedIterator.next(), "A");
|
||||
assertTrue(mergedIterator.hasNext());
|
||||
assertEquals(mergedIterator.next(), "2");
|
||||
assertTrue(mergedIterator.hasNext());
|
||||
assertEquals(mergedIterator.next(), "b");
|
||||
assertTrue(mergedIterator.hasNext());
|
||||
assertEquals(mergedIterator.next(), "B");
|
||||
assertTrue(mergedIterator.hasNext());
|
||||
assertEquals(mergedIterator.next(), "3");
|
||||
assertTrue(mergedIterator.hasNext());
|
||||
assertEquals(mergedIterator.next(), "c");
|
||||
assertTrue(mergedIterator.hasNext());
|
||||
assertEquals(mergedIterator.next(), "C");
|
||||
assertFalse(mergedIterator.hasNext());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ParamTag freshParamTag = new ParamTag();
|
||||
freshParamTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshParamTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(iterator1ParamTag, freshParamTag));
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(iterator2ParamTag, freshParamTag));
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(iterator3ParamTag, freshParamTag));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
MergeIteratorTag freshTag = new MergeIteratorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testMergingIteratorsWithListAsSource() throws Exception {
|
||||
MergeIteratorTag tag = new MergeIteratorTag();
|
||||
@@ -134,9 +234,108 @@ public class MergeIteratorTagTest extends AbstractTagTest {
|
||||
assertTrue(mergedIterator.hasNext());
|
||||
assertEquals(mergedIterator.next(), "C");
|
||||
assertFalse(mergedIterator.hasNext());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ParamTag freshParamTag = new ParamTag();
|
||||
freshParamTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(iterator1ParamTag, freshParamTag));
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(iterator2ParamTag, freshParamTag));
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(iterator3ParamTag, freshParamTag));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
MergeIteratorTag freshTag = new MergeIteratorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testMergingIteratorsWithListAsSource_clearTagStateSet() throws Exception {
|
||||
MergeIteratorTag tag = new MergeIteratorTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setVar("myMergedIterator");
|
||||
|
||||
ParamTag iterator1ParamTag = new ParamTag();
|
||||
iterator1ParamTag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
iterator1ParamTag.setPageContext(pageContext);
|
||||
iterator1ParamTag.setValue("myList1");
|
||||
|
||||
ParamTag iterator2ParamTag = new ParamTag();
|
||||
iterator2ParamTag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
iterator2ParamTag.setPageContext(pageContext);
|
||||
iterator2ParamTag.setValue("myList2");
|
||||
|
||||
ParamTag iterator3ParamTag = new ParamTag();
|
||||
iterator3ParamTag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
iterator3ParamTag.setPageContext(pageContext);
|
||||
iterator3ParamTag.setValue("myList3");
|
||||
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
iterator1ParamTag.doStartTag();
|
||||
setComponentTagClearTagState(iterator1ParamTag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
iterator1ParamTag.doEndTag();
|
||||
iterator2ParamTag.doStartTag();
|
||||
setComponentTagClearTagState(iterator2ParamTag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
iterator2ParamTag.doEndTag();
|
||||
iterator3ParamTag.doStartTag();
|
||||
setComponentTagClearTagState(iterator3ParamTag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
iterator3ParamTag.doEndTag();
|
||||
tag.doEndTag();
|
||||
|
||||
Iterator mergedIterator = (Iterator) stack.findValue("#myMergedIterator"); // if not iterator, let CCE surface
|
||||
|
||||
assertNotNull(mergedIterator);
|
||||
assertTrue(mergedIterator.hasNext());
|
||||
assertEquals(mergedIterator.next(), "1");
|
||||
assertTrue(mergedIterator.hasNext());
|
||||
assertEquals(mergedIterator.next(), "a");
|
||||
assertTrue(mergedIterator.hasNext());
|
||||
assertEquals(mergedIterator.next(), "A");
|
||||
assertTrue(mergedIterator.hasNext());
|
||||
assertEquals(mergedIterator.next(), "2");
|
||||
assertTrue(mergedIterator.hasNext());
|
||||
assertEquals(mergedIterator.next(), "b");
|
||||
assertTrue(mergedIterator.hasNext());
|
||||
assertEquals(mergedIterator.next(), "B");
|
||||
assertTrue(mergedIterator.hasNext());
|
||||
assertEquals(mergedIterator.next(), "3");
|
||||
assertTrue(mergedIterator.hasNext());
|
||||
assertEquals(mergedIterator.next(), "c");
|
||||
assertTrue(mergedIterator.hasNext());
|
||||
assertEquals(mergedIterator.next(), "C");
|
||||
assertFalse(mergedIterator.hasNext());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ParamTag freshParamTag = new ParamTag();
|
||||
freshParamTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshParamTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(iterator1ParamTag, freshParamTag));
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(iterator2ParamTag, freshParamTag));
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(iterator3ParamTag, freshParamTag));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
MergeIteratorTag freshTag = new MergeIteratorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
|
||||
public Action getAction() {
|
||||
|
||||
@@ -44,8 +44,44 @@ public class NumberTagTest extends AbstractTagTest {
|
||||
|
||||
// then
|
||||
assertEquals("120", writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
NumberTag freshTag = new NumberTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
|
||||
public void testSimpleFloatFormat_clearTagStateSet() throws Exception {
|
||||
// given
|
||||
context.put(ActionContext.LOCALE, Locale.US);
|
||||
|
||||
TestAction testAction = (TestAction) action;
|
||||
testAction.setFloatNumber(120.0f);
|
||||
|
||||
NumberTag tag = new NumberTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setName("floatNumber");
|
||||
|
||||
// when
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
// then
|
||||
assertEquals("120", writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
NumberTag freshTag = new NumberTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testSimpleCurrencyUSFormat() throws Exception {
|
||||
// given
|
||||
context = ActionContext.of(context).withLocale(Locale.US).getContextMap();
|
||||
@@ -64,8 +100,43 @@ public class NumberTagTest extends AbstractTagTest {
|
||||
|
||||
// then
|
||||
assertEquals("$120.00", writer.toString());
|
||||
|
||||
NumberTag freshTag = new NumberTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
|
||||
public void testSimpleCurrencyUSFormat_clearTagStateSet() throws Exception {
|
||||
// given
|
||||
context.put(ActionContext.LOCALE, Locale.US);
|
||||
|
||||
TestAction testAction = (TestAction) action;
|
||||
testAction.setFloatNumber(120.0f);
|
||||
|
||||
NumberTag tag = new NumberTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setName("floatNumber");
|
||||
tag.setType("currency");
|
||||
|
||||
// when
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
// then
|
||||
assertEquals("$120.00", writer.toString());
|
||||
|
||||
NumberTag freshTag = new NumberTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testSimpleCurrencyPLFormat() throws Exception {
|
||||
// given
|
||||
context = ActionContext.of(context).withLocale(new Locale("pl", "PL")).getContextMap();
|
||||
@@ -89,6 +160,45 @@ public class NumberTagTest extends AbstractTagTest {
|
||||
String expected = format.format(120.0f);
|
||||
|
||||
assertEquals(expected, writer.toString());
|
||||
|
||||
NumberTag freshTag = new NumberTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testSimpleCurrencyPLFormat_clearTagStateSet() throws Exception {
|
||||
// given
|
||||
context.put(ActionContext.LOCALE, new Locale("pl", "PL"));
|
||||
|
||||
TestAction testAction = (TestAction) action;
|
||||
testAction.setFloatNumber(120.0f);
|
||||
|
||||
NumberTag tag = new NumberTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setName("floatNumber");
|
||||
tag.setType("currency");
|
||||
|
||||
// when
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
// then
|
||||
NumberFormat format = NumberFormat.getCurrencyInstance((Locale) context.get(ActionContext.LOCALE));
|
||||
format.setRoundingMode(RoundingMode.CEILING);
|
||||
String expected = format.format(120.0f);
|
||||
|
||||
assertEquals(expected, writer.toString());
|
||||
|
||||
NumberTag freshTag = new NumberTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testSimpleRoundingCeiling() throws Exception {
|
||||
@@ -114,6 +224,45 @@ public class NumberTagTest extends AbstractTagTest {
|
||||
String expected = format.format(120.45f);
|
||||
|
||||
assertEquals(expected, writer.toString());
|
||||
|
||||
NumberTag freshTag = new NumberTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testSimpleRoundingCeiling_clearTagStateSet() throws Exception {
|
||||
// given
|
||||
context.put(ActionContext.LOCALE, Locale.US);
|
||||
|
||||
TestAction testAction = (TestAction) action;
|
||||
testAction.setFloatNumber(120.45f);
|
||||
|
||||
NumberTag tag = new NumberTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setName("floatNumber");
|
||||
tag.setRoundingMode("down");
|
||||
|
||||
// when
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
// then
|
||||
NumberFormat format = NumberFormat.getInstance((Locale) context.get(ActionContext.LOCALE));
|
||||
format.setRoundingMode(RoundingMode.DOWN);
|
||||
String expected = format.format(120.45f);
|
||||
|
||||
assertEquals(expected, writer.toString());
|
||||
|
||||
NumberTag freshTag = new NumberTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -65,6 +65,67 @@ public class PropertyTagTest extends StrutsInternalTestCase {
|
||||
request.verify();
|
||||
jspWriter.verify();
|
||||
pageContext.verify();
|
||||
|
||||
try {
|
||||
tag.doEndTag();
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
PropertyTag freshTag = new PropertyTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testDefaultValue_clearTagStateSet() {
|
||||
PropertyTag tag = new PropertyTag();
|
||||
|
||||
Foo foo = new Foo();
|
||||
|
||||
stack.push(foo);
|
||||
|
||||
MockJspWriter jspWriter = new MockJspWriter();
|
||||
jspWriter.setExpectedData("TEST");
|
||||
|
||||
MockPageContext pageContext = new MockPageContext();
|
||||
pageContext.setJspWriter(jspWriter);
|
||||
pageContext.setRequest(request);
|
||||
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setValue("title");
|
||||
tag.setDefault("TEST");
|
||||
|
||||
try {
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
request.verify();
|
||||
jspWriter.verify();
|
||||
pageContext.verify();
|
||||
|
||||
try {
|
||||
tag.doEndTag();
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
PropertyTag freshTag = new PropertyTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testNull() {
|
||||
@@ -94,6 +155,66 @@ public class PropertyTagTest extends StrutsInternalTestCase {
|
||||
request.verify();
|
||||
jspWriter.verify();
|
||||
pageContext.verify();
|
||||
|
||||
try {
|
||||
tag.doEndTag();
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
PropertyTag freshTag = new PropertyTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testNull_clearTagStateSet() {
|
||||
PropertyTag tag = new PropertyTag();
|
||||
|
||||
Foo foo = new Foo();
|
||||
|
||||
stack.push(foo);
|
||||
|
||||
MockJspWriter jspWriter = new MockJspWriter();
|
||||
jspWriter.setExpectedData("");
|
||||
|
||||
MockPageContext pageContext = new MockPageContext();
|
||||
pageContext.setJspWriter(jspWriter);
|
||||
pageContext.setRequest(request);
|
||||
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setValue("title");
|
||||
|
||||
try {
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
request.verify();
|
||||
jspWriter.verify();
|
||||
pageContext.verify();
|
||||
|
||||
try {
|
||||
tag.doEndTag();
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
PropertyTag freshTag = new PropertyTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testSimple() {
|
||||
@@ -124,6 +245,67 @@ public class PropertyTagTest extends StrutsInternalTestCase {
|
||||
request.verify();
|
||||
jspWriter.verify();
|
||||
pageContext.verify();
|
||||
|
||||
try {
|
||||
tag.doEndTag();
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
PropertyTag freshTag = new PropertyTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testSimple_clearTagStateSet() {
|
||||
PropertyTag tag = new PropertyTag();
|
||||
|
||||
Foo foo = new Foo();
|
||||
foo.setTitle("test");
|
||||
|
||||
stack.push(foo);
|
||||
|
||||
MockJspWriter jspWriter = new MockJspWriter();
|
||||
jspWriter.setExpectedData("test");
|
||||
|
||||
MockPageContext pageContext = new MockPageContext();
|
||||
pageContext.setJspWriter(jspWriter);
|
||||
pageContext.setRequest(request);
|
||||
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setValue("title");
|
||||
|
||||
try {
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
request.verify();
|
||||
jspWriter.verify();
|
||||
pageContext.verify();
|
||||
|
||||
try {
|
||||
tag.doEndTag();
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
PropertyTag freshTag = new PropertyTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testTopOfStack() {
|
||||
@@ -153,8 +335,68 @@ public class PropertyTagTest extends StrutsInternalTestCase {
|
||||
request.verify();
|
||||
jspWriter.verify();
|
||||
pageContext.verify();
|
||||
|
||||
try {
|
||||
tag.doEndTag();
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
PropertyTag freshTag = new PropertyTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
// PropertyTag had no explicit values set in this test, so it compares as equal with the default tag clear state as well.
|
||||
assertTrue("Tag state after doEndTag() under default tag clear state is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testTopOfStack_clearTagStateSet() {
|
||||
PropertyTag tag = new PropertyTag();
|
||||
|
||||
Foo foo = new Foo();
|
||||
foo.setTitle("test");
|
||||
|
||||
stack.push(foo);
|
||||
|
||||
MockJspWriter jspWriter = new MockJspWriter();
|
||||
jspWriter.setExpectedData("Foo is: test");
|
||||
|
||||
MockPageContext pageContext = new MockPageContext();
|
||||
pageContext.setJspWriter(jspWriter);
|
||||
pageContext.setRequest(request);
|
||||
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
|
||||
try {
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
request.verify();
|
||||
jspWriter.verify();
|
||||
pageContext.verify();
|
||||
|
||||
try {
|
||||
tag.doEndTag();
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
PropertyTag freshTag = new PropertyTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testWithAltSyntax1() throws Exception {
|
||||
// setups
|
||||
@@ -176,6 +418,51 @@ public class PropertyTagTest extends StrutsInternalTestCase {
|
||||
tag.setValue("%{formatTitle()}");
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
PropertyTag freshTag = new PropertyTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
// verify test
|
||||
request.verify();
|
||||
jspWriter.verify();
|
||||
pageContext.verify();
|
||||
}
|
||||
|
||||
public void testWithAltSyntax1_clearTagStateSet() throws Exception {
|
||||
// setups
|
||||
Foo foo = new Foo();
|
||||
foo.setTitle("tm_jee");
|
||||
stack.push(foo);
|
||||
|
||||
MockJspWriter jspWriter = new MockJspWriter();
|
||||
jspWriter.setExpectedData("Foo is: tm_jee");
|
||||
|
||||
MockPageContext pageContext = new MockPageContext();
|
||||
pageContext.setJspWriter(jspWriter);
|
||||
pageContext.setRequest(request);
|
||||
|
||||
// test
|
||||
{
|
||||
PropertyTag tag = new PropertyTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setValue("%{formatTitle()}");
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
PropertyTag freshTag = new PropertyTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
// verify test
|
||||
@@ -198,15 +485,58 @@ public class PropertyTagTest extends StrutsInternalTestCase {
|
||||
pageContext.setRequest(request);
|
||||
|
||||
// test
|
||||
{
|
||||
PropertyTag tag = new PropertyTag();
|
||||
tag.setEscapeHtml(false);
|
||||
tag.setEscapeJavaScript(true);
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setValue("%{formatTitle()}");
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
}
|
||||
{PropertyTag tag = new PropertyTag();
|
||||
tag.setEscapeHtml(false);
|
||||
tag.setEscapeJavaScript(true);
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setValue("%{formatTitle()}");
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
PropertyTag freshTag = new PropertyTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));}
|
||||
|
||||
// verify test
|
||||
request.verify();
|
||||
jspWriter.verify();
|
||||
pageContext.verify();
|
||||
}
|
||||
|
||||
public void testEscapeJavaScript_clearTagStateSet() throws Exception {
|
||||
// setups
|
||||
Foo foo = new Foo();
|
||||
foo.setTitle("\t\b\n\f\r\"\'/\\");
|
||||
stack.push(foo);
|
||||
|
||||
MockJspWriter jspWriter = new MockJspWriter();
|
||||
jspWriter.setExpectedData("Foo is: \\t\\b\\n\\f\\r\\\"\\\'\\/\\\\");
|
||||
|
||||
MockPageContext pageContext = new MockPageContext();
|
||||
pageContext.setJspWriter(jspWriter);
|
||||
pageContext.setRequest(request);
|
||||
|
||||
// test
|
||||
{PropertyTag tag = new PropertyTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setEscapeHtml(false);
|
||||
tag.setEscapeJavaScript(true);
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setValue("%{formatTitle()}");
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
PropertyTag freshTag = new PropertyTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));}
|
||||
|
||||
// verify test
|
||||
request.verify();
|
||||
@@ -228,15 +558,58 @@ public class PropertyTagTest extends StrutsInternalTestCase {
|
||||
pageContext.setRequest(request);
|
||||
|
||||
// test
|
||||
{
|
||||
PropertyTag tag = new PropertyTag();
|
||||
tag.setEscapeHtml(false);
|
||||
tag.setEscapeXml(true);
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setValue("%{formatTitle()}");
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
}
|
||||
{PropertyTag tag = new PropertyTag();
|
||||
tag.setEscapeHtml(false);
|
||||
tag.setEscapeXml(true);
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setValue("%{formatTitle()}");
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
PropertyTag freshTag = new PropertyTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));}
|
||||
|
||||
// verify test
|
||||
request.verify();
|
||||
jspWriter.verify();
|
||||
pageContext.verify();
|
||||
}
|
||||
|
||||
public void testEscapeXml_clearTagStateSet() throws Exception {
|
||||
// setups
|
||||
Foo foo = new Foo();
|
||||
foo.setTitle("<>'\"&");
|
||||
stack.push(foo);
|
||||
|
||||
MockJspWriter jspWriter = new MockJspWriter();
|
||||
jspWriter.setExpectedData("Foo is: <>'"&");
|
||||
|
||||
MockPageContext pageContext = new MockPageContext();
|
||||
pageContext.setJspWriter(jspWriter);
|
||||
pageContext.setRequest(request);
|
||||
|
||||
// test
|
||||
{PropertyTag tag = new PropertyTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setEscapeHtml(false);
|
||||
tag.setEscapeXml(true);
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setValue("%{formatTitle()}");
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
PropertyTag freshTag = new PropertyTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));}
|
||||
|
||||
// verify test
|
||||
request.verify();
|
||||
@@ -258,15 +631,58 @@ public class PropertyTagTest extends StrutsInternalTestCase {
|
||||
pageContext.setRequest(request);
|
||||
|
||||
// test
|
||||
{
|
||||
PropertyTag tag = new PropertyTag();
|
||||
tag.setEscapeHtml(false);
|
||||
tag.setEscapeCsv(true);
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setValue("%{formatTitle()}");
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
}
|
||||
{PropertyTag tag = new PropertyTag();
|
||||
tag.setEscapeHtml(false);
|
||||
tag.setEscapeCsv(true);
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setValue("%{formatTitle()}");
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
PropertyTag freshTag = new PropertyTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));}
|
||||
|
||||
// verify test
|
||||
request.verify();
|
||||
jspWriter.verify();
|
||||
pageContext.verify();
|
||||
}
|
||||
|
||||
public void testEscapeCsv_clearTagStateSet() throws Exception {
|
||||
// setups
|
||||
Foo foo = new Foo();
|
||||
foo.setTitle("\"something,\",\"");
|
||||
stack.push(foo);
|
||||
|
||||
MockJspWriter jspWriter = new MockJspWriter();
|
||||
jspWriter.setExpectedData("\"Foo is: \"\"something,\"\",\"\"\"");
|
||||
|
||||
MockPageContext pageContext = new MockPageContext();
|
||||
pageContext.setJspWriter(jspWriter);
|
||||
pageContext.setRequest(request);
|
||||
|
||||
// test
|
||||
{PropertyTag tag = new PropertyTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setEscapeHtml(false);
|
||||
tag.setEscapeCsv(true);
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setValue("%{formatTitle()}");
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
PropertyTag freshTag = new PropertyTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));}
|
||||
|
||||
// verify test
|
||||
request.verify();
|
||||
@@ -288,13 +704,54 @@ public class PropertyTagTest extends StrutsInternalTestCase {
|
||||
pageContext.setRequest(request);
|
||||
|
||||
// test
|
||||
{
|
||||
PropertyTag tag = new PropertyTag();
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setValue("formatTitle()");
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
}
|
||||
{PropertyTag tag = new PropertyTag();
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setValue("formatTitle()");
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
PropertyTag freshTag = new PropertyTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));}
|
||||
|
||||
// verify test
|
||||
request.verify();
|
||||
jspWriter.verify();
|
||||
pageContext.verify();
|
||||
}
|
||||
|
||||
public void testWithAltSyntax2_clearTagStateSet() throws Exception {
|
||||
// setups
|
||||
Foo foo = new Foo();
|
||||
foo.setTitle("tm_jee");
|
||||
stack.push(foo);
|
||||
|
||||
MockJspWriter jspWriter = new MockJspWriter();
|
||||
jspWriter.setExpectedData("Foo is: tm_jee");
|
||||
|
||||
MockPageContext pageContext = new MockPageContext();
|
||||
pageContext.setJspWriter(jspWriter);
|
||||
pageContext.setRequest(request);
|
||||
|
||||
// test
|
||||
{PropertyTag tag = new PropertyTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setValue("formatTitle()");
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
PropertyTag freshTag = new PropertyTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));}
|
||||
|
||||
// verify test
|
||||
request.verify();
|
||||
@@ -316,13 +773,18 @@ public class PropertyTagTest extends StrutsInternalTestCase {
|
||||
pageContext.setRequest(request);
|
||||
|
||||
// test
|
||||
{
|
||||
PropertyTag tag = new PropertyTag();
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setValue("formatTitle()");
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
}
|
||||
{PropertyTag tag = new PropertyTag();
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setValue("formatTitle()");
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
PropertyTag freshTag = new PropertyTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));}
|
||||
|
||||
// verify test
|
||||
request.verify();
|
||||
@@ -330,6 +792,41 @@ public class PropertyTagTest extends StrutsInternalTestCase {
|
||||
pageContext.verify();
|
||||
}
|
||||
|
||||
public void testWithoutAltSyntax1_clearTagStateSet() throws Exception {
|
||||
// setups
|
||||
Foo foo = new Foo();
|
||||
foo.setTitle("tm_jee");
|
||||
stack.push(foo);
|
||||
|
||||
MockJspWriter jspWriter = new MockJspWriter();
|
||||
jspWriter.setExpectedData("Foo is: tm_jee");
|
||||
|
||||
MockPageContext pageContext = new MockPageContext();
|
||||
pageContext.setJspWriter(jspWriter);
|
||||
pageContext.setRequest(request);
|
||||
|
||||
// test
|
||||
{PropertyTag tag = new PropertyTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setValue("formatTitle()");
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
PropertyTag freshTag = new PropertyTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));}
|
||||
|
||||
// verify test
|
||||
request.verify();
|
||||
jspWriter.verify();
|
||||
pageContext.verify();
|
||||
}
|
||||
|
||||
public void testWithoutAltSyntax2() throws Exception {
|
||||
// setups
|
||||
@@ -344,13 +841,18 @@ public class PropertyTagTest extends StrutsInternalTestCase {
|
||||
pageContext.setRequest(request);
|
||||
|
||||
// test
|
||||
{
|
||||
PropertyTag tag = new PropertyTag();
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setValue("%{formatTitle()}");
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
}
|
||||
{PropertyTag tag = new PropertyTag();
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setValue("%{formatTitle()}");
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
PropertyTag freshTag = new PropertyTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));}
|
||||
|
||||
// verify test
|
||||
request.verify();
|
||||
@@ -358,13 +860,168 @@ public class PropertyTagTest extends StrutsInternalTestCase {
|
||||
pageContext.verify();
|
||||
}
|
||||
|
||||
public void testWithoutAltSyntax2_clearTagStateSet() throws Exception {
|
||||
// setups
|
||||
Foo foo = new Foo();
|
||||
foo.setTitle("tm_jee");
|
||||
stack.push(foo);
|
||||
|
||||
MockJspWriter jspWriter = new MockJspWriter();
|
||||
|
||||
MockPageContext pageContext = new MockPageContext();
|
||||
pageContext.setJspWriter(jspWriter);
|
||||
pageContext.setRequest(request);
|
||||
|
||||
// test
|
||||
{PropertyTag tag = new PropertyTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setValue("%{formatTitle()}");
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
PropertyTag freshTag = new PropertyTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));}
|
||||
|
||||
// verify test
|
||||
request.verify();
|
||||
jspWriter.verify();
|
||||
pageContext.verify();
|
||||
}
|
||||
|
||||
public void testSimple_release() {
|
||||
PropertyTag tag = new PropertyTag();
|
||||
|
||||
Foo foo = new Foo();
|
||||
foo.setTitle("test");
|
||||
|
||||
stack.push(foo);
|
||||
|
||||
MockJspWriter jspWriter = new MockJspWriter();
|
||||
jspWriter.setExpectedData("test");
|
||||
|
||||
MockPageContext pageContext = new MockPageContext();
|
||||
pageContext.setJspWriter(jspWriter);
|
||||
pageContext.setRequest(request);
|
||||
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setValue("title");
|
||||
|
||||
try {
|
||||
tag.doStartTag();
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
request.verify();
|
||||
jspWriter.verify();
|
||||
pageContext.verify();
|
||||
|
||||
try {
|
||||
tag.doEndTag();
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
PropertyTag freshTag = new PropertyTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));
|
||||
|
||||
// Test release at least once in unit tests (with clear tag state not set).
|
||||
tag.release();
|
||||
assertTrue("Tag state after release() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() and release() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testSimple_release_clearTagStateSet() {
|
||||
PropertyTag tag = new PropertyTag();
|
||||
|
||||
Foo foo = new Foo();
|
||||
foo.setTitle("test");
|
||||
|
||||
stack.push(foo);
|
||||
|
||||
MockJspWriter jspWriter = new MockJspWriter();
|
||||
jspWriter.setExpectedData("test");
|
||||
|
||||
MockPageContext pageContext = new MockPageContext();
|
||||
pageContext.setJspWriter(jspWriter);
|
||||
pageContext.setRequest(request);
|
||||
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setValue("title");
|
||||
|
||||
try {
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
request.verify();
|
||||
jspWriter.verify();
|
||||
pageContext.verify();
|
||||
|
||||
try {
|
||||
tag.doEndTag();
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
PropertyTag freshTag = new PropertyTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));
|
||||
|
||||
// Test release at least once in unit tests (with clear tag state set).
|
||||
tag.release();
|
||||
assertTrue("Tag state after release() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() and release() calls are not working properly.",
|
||||
objectsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
stack = ActionContext.getContext().getValueStack();
|
||||
request.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to simplify setting the performClearTagStateForTagPoolingServers state for a
|
||||
* {@link ComponentTagSupport} tag's {@link Component} to match expectations for the test.
|
||||
*
|
||||
* The component reference is not available to the tag until after the doStartTag() method is called.
|
||||
* We need to ensure the component's {@link Component#performClearTagStateForTagPoolingServers} state matches
|
||||
* what we set for the Tag when a non-default (true) value is used, so this method accesses the component instance,
|
||||
* sets the value specified and forces the tag's parameters to be repopulated again.
|
||||
*
|
||||
* @param tag The ComponentTagSupport tag upon whose component we will set the performClearTagStateForTagPoolingServers state.
|
||||
* @param performClearTagStateForTagPoolingServers true to clear tag state, false otherwise
|
||||
*/
|
||||
protected void setComponentTagClearTagState(ComponentTagSupport tag, boolean performClearTagStateForTagPoolingServers) {
|
||||
tag.component.setPerformClearTagStateForTagPoolingServers(performClearTagStateForTagPoolingServers);
|
||||
//tag.populateParams(); // Not safe to call after doStartTag() ... breaks some tests.
|
||||
tag.populatePerformClearTagStateForTagPoolingServersParam(); // Only populate the performClearTagStateForTagPoolingServers parameter for the Tag.
|
||||
}
|
||||
|
||||
public static class Foo {
|
||||
private String title;
|
||||
@@ -381,6 +1038,7 @@ public class PropertyTagTest extends StrutsInternalTestCase {
|
||||
return "Foo is: " + title;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return formatTitle();
|
||||
}
|
||||
|
||||
@@ -43,5 +43,42 @@ public class PushTagTest extends AbstractUITagTest {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
PushTag freshTag = new PushTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testSimple_clearTagStateSet() {
|
||||
PushTag tag = new PushTag();
|
||||
|
||||
stack.setValue("foo", "bar");
|
||||
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setValue("foo");
|
||||
|
||||
try {
|
||||
assertEquals(2, stack.size());
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
assertEquals(3, stack.size());
|
||||
tag.doEndTag();
|
||||
assertEquals(2, stack.size());
|
||||
} catch (JspException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
PushTag freshTag = new PushTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,33 @@ public class SetTagTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals("chewie", servletContext.getAttribute("foo"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SetTag freshTag = new SetTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testApplicationScope_clearTagStateSet() throws JspException {
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setName("foo");
|
||||
tag.setValue("name");
|
||||
tag.setScope("application");
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals("chewie", servletContext.getAttribute("foo"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SetTag freshTag = new SetTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testPageScope() throws JspException {
|
||||
@@ -49,6 +76,33 @@ public class SetTagTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals("chewie", pageContext.getAttribute("foo"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SetTag freshTag = new SetTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testPageScope_clearTagStateSet() throws JspException {
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setName("foo");
|
||||
tag.setValue("name");
|
||||
tag.setScope("page");
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals("chewie", pageContext.getAttribute("foo"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SetTag freshTag = new SetTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testRequestScope() throws JspException {
|
||||
@@ -58,6 +112,32 @@ public class SetTagTest extends AbstractUITagTest {
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
assertEquals("chewie", request.getAttribute("foo"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SetTag freshTag = new SetTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testRequestScope_clearTagStateSet() throws JspException {
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setName("foo");
|
||||
tag.setValue("name");
|
||||
tag.setScope("request");
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
assertEquals("chewie", request.getAttribute("foo"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SetTag freshTag = new SetTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testSessionScope() throws JspException {
|
||||
@@ -68,6 +148,33 @@ public class SetTagTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals("chewie", session.get("foo"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SetTag freshTag = new SetTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testSessionScope_clearTagStateSet() throws JspException {
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setName("foo");
|
||||
tag.setValue("name");
|
||||
tag.setScope("session");
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals("chewie", session.get("foo"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SetTag freshTag = new SetTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testStrutsScope() throws JspException {
|
||||
@@ -76,6 +183,31 @@ public class SetTagTest extends AbstractUITagTest {
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
assertEquals("chewie", context.get("foo"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SetTag freshTag = new SetTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testStrutsScope_clearTagStateSet() throws JspException {
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setName("foo");
|
||||
tag.setValue("name");
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
assertEquals("chewie", context.get("foo"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SetTag freshTag = new SetTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testStrutsScope2() throws JspException {
|
||||
@@ -83,6 +215,30 @@ public class SetTagTest extends AbstractUITagTest {
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
assertEquals(chewie, context.get("chewie"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SetTag freshTag = new SetTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testStrutsScope2_clearTagStateSet() throws JspException {
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setName("chewie");
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
assertEquals(chewie, context.get("chewie"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SetTag freshTag = new SetTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testSetTrimBody() throws JspException, IOException {
|
||||
@@ -100,6 +256,13 @@ public class SetTagTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
assertEquals(trimmedBeginEndSpaceString, context.get("foo"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SetTag freshTag = new SetTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
|
||||
tag.setName("foo");
|
||||
tag.setValue(null);
|
||||
tag.setTrimBody(true);
|
||||
@@ -110,6 +273,11 @@ public class SetTagTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
assertEquals(trimmedBeginEndSpaceString, context.get("foo"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
|
||||
tag.setName("foo");
|
||||
tag.setValue(null);
|
||||
tag.setTrimBody(false);
|
||||
@@ -119,6 +287,69 @@ public class SetTagTest extends AbstractUITagTest {
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
assertEquals(beginEndSpaceString, context.get("foo"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testSetTrimBody_clearTagStateSet() throws JspException, IOException {
|
||||
final String beginEndSpaceString = " Preceding and trailing spaces. ";
|
||||
final String trimmedBeginEndSpaceString = beginEndSpaceString.trim();
|
||||
StrutsMockBodyContent mockBodyContent;
|
||||
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setName("foo");
|
||||
tag.setValue(null);
|
||||
// Do not set any value - default for tag should be true
|
||||
mockBodyContent = new StrutsMockBodyContent(new MockJspWriter());
|
||||
mockBodyContent.setString(beginEndSpaceString);
|
||||
tag.setBodyContent(mockBodyContent);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
assertEquals(trimmedBeginEndSpaceString, context.get("foo"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SetTag freshTag = new SetTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
|
||||
tag.setName("foo");
|
||||
tag.setValue(null);
|
||||
tag.setTrimBody(true);
|
||||
mockBodyContent = new StrutsMockBodyContent(new MockJspWriter());
|
||||
mockBodyContent.setString(beginEndSpaceString);
|
||||
tag.setBodyContent(mockBodyContent);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
assertEquals(trimmedBeginEndSpaceString, context.get("foo"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
|
||||
tag.setName("foo");
|
||||
tag.setValue(null);
|
||||
tag.setTrimBody(false);
|
||||
mockBodyContent = new StrutsMockBodyContent(new MockJspWriter());
|
||||
mockBodyContent.setString(beginEndSpaceString);
|
||||
tag.setBodyContent(mockBodyContent);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
assertEquals(beginEndSpaceString, context.get("foo"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testEmptyBody() throws JspException {
|
||||
@@ -133,8 +364,40 @@ public class SetTagTest extends AbstractUITagTest {
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
assertEquals(emptyBody, context.get(variableName));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SetTag freshTag = new SetTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testEmptyBody_clearTagStateSet() throws JspException {
|
||||
StrutsMockBodyContent mockBodyContent;
|
||||
String variableName = "foo";
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setName(variableName);
|
||||
tag.setValue(null);
|
||||
mockBodyContent = new StrutsMockBodyContent(new MockJspWriter());
|
||||
String emptyBody = "";
|
||||
mockBodyContent.setString(emptyBody);
|
||||
tag.setBodyContent(mockBodyContent);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
assertEquals(emptyBody, context.get(variableName));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SetTag freshTag = new SetTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
|
||||
@@ -67,6 +67,55 @@ public class SortIteratorTagTest extends AbstractTagTest {
|
||||
|
||||
assertFalse(sortedIterator.hasNext());
|
||||
tag.doEndTag();
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SortIteratorTag freshTag = new SortIteratorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testSortWithoutId_clearTagStateSet() throws Exception {
|
||||
SortIteratorTag tag = new SortIteratorTag();
|
||||
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setComparator("comparator");
|
||||
tag.setSource("source");
|
||||
|
||||
tag.setPageContext(pageContext);
|
||||
tag.doStartTag();
|
||||
|
||||
// if not an Iterator, just let the ClassCastException be thrown as error instead of failure
|
||||
Iterator sortedIterator = (Iterator) stack.findValue("top");
|
||||
|
||||
assertNotNull(sortedIterator);
|
||||
// 1
|
||||
assertTrue(sortedIterator.hasNext());
|
||||
assertEquals(sortedIterator.next(), new Integer(1));
|
||||
// 2
|
||||
assertTrue(sortedIterator.hasNext());
|
||||
assertEquals(sortedIterator.next(), new Integer(2));
|
||||
// 3.
|
||||
assertTrue(sortedIterator.hasNext());
|
||||
assertEquals(sortedIterator.next(), new Integer(3));
|
||||
// 4.
|
||||
assertTrue(sortedIterator.hasNext());
|
||||
assertEquals(sortedIterator.next(), new Integer(4));
|
||||
// 5
|
||||
assertTrue(sortedIterator.hasNext());
|
||||
assertEquals(sortedIterator.next(), new Integer(5));
|
||||
|
||||
assertFalse(sortedIterator.hasNext());
|
||||
tag.doEndTag();
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SortIteratorTag freshTag = new SortIteratorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testSortWithIdIteratorAvailableInStackTop() throws Exception {
|
||||
@@ -104,8 +153,59 @@ public class SortIteratorTagTest extends AbstractTagTest {
|
||||
}
|
||||
|
||||
tag.doEndTag();
|
||||
}
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SortIteratorTag freshTag = new SortIteratorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
public void testSortWithIdIteratorAvailableInStackTop_clearTagStateSet() throws Exception {
|
||||
|
||||
SortIteratorTag tag = new SortIteratorTag();
|
||||
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setVar("myId");
|
||||
tag.setComparator("comparator");
|
||||
tag.setSource("source");
|
||||
|
||||
tag.setPageContext(pageContext);
|
||||
tag.doStartTag();
|
||||
|
||||
{
|
||||
Iterator sortedIterator = (Iterator) stack.findValue("top");
|
||||
|
||||
assertNotNull(sortedIterator);
|
||||
// 1
|
||||
assertTrue(sortedIterator.hasNext());
|
||||
assertEquals(sortedIterator.next(), new Integer(1));
|
||||
// 2
|
||||
assertTrue(sortedIterator.hasNext());
|
||||
assertEquals(sortedIterator.next(), new Integer(2));
|
||||
// 3
|
||||
assertTrue(sortedIterator.hasNext());
|
||||
assertEquals(sortedIterator.next(), new Integer(3));
|
||||
// 4
|
||||
assertTrue(sortedIterator.hasNext());
|
||||
assertEquals(sortedIterator.next(), new Integer(4));
|
||||
// 5
|
||||
assertTrue(sortedIterator.hasNext());
|
||||
assertEquals(sortedIterator.next(), new Integer(5));
|
||||
|
||||
assertFalse(sortedIterator.hasNext());
|
||||
}
|
||||
|
||||
tag.doEndTag();
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SortIteratorTag freshTag = new SortIteratorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testSortWithIdIteratorAvailableInPageContext() throws Exception {
|
||||
SortIteratorTag tag = new SortIteratorTag();
|
||||
@@ -141,6 +241,58 @@ public class SortIteratorTagTest extends AbstractTagTest {
|
||||
}
|
||||
|
||||
tag.doEndTag();
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SortIteratorTag freshTag = new SortIteratorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testSortWithIdIteratorAvailableInPageContext_clearTagStateSet() throws Exception {
|
||||
SortIteratorTag tag = new SortIteratorTag();
|
||||
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setVar("myId");
|
||||
tag.setComparator("comparator");
|
||||
tag.setSource("source");
|
||||
|
||||
tag.setPageContext(pageContext);
|
||||
tag.doStartTag();
|
||||
|
||||
{
|
||||
Iterator sortedIterator = (Iterator) pageContext.getAttribute("myId");
|
||||
|
||||
assertNotNull(sortedIterator);
|
||||
// 1
|
||||
assertTrue(sortedIterator.hasNext());
|
||||
assertEquals(sortedIterator.next(), new Integer(1));
|
||||
// 2
|
||||
assertTrue(sortedIterator.hasNext());
|
||||
assertEquals(sortedIterator.next(), new Integer(2));
|
||||
// 3
|
||||
assertTrue(sortedIterator.hasNext());
|
||||
assertEquals(sortedIterator.next(), new Integer(3));
|
||||
// 4
|
||||
assertTrue(sortedIterator.hasNext());
|
||||
assertEquals(sortedIterator.next(), new Integer(4));
|
||||
// 5
|
||||
assertTrue(sortedIterator.hasNext());
|
||||
assertEquals(sortedIterator.next(), new Integer(5));
|
||||
|
||||
assertFalse(sortedIterator.hasNext());
|
||||
}
|
||||
|
||||
tag.doEndTag();
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SortIteratorTag freshTag = new SortIteratorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testSortWithIllegalSource() throws Exception {
|
||||
@@ -159,6 +311,8 @@ public class SortIteratorTagTest extends AbstractTagTest {
|
||||
// ok
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
// The doEndTag() call is expected not to complete. Cannot perform basic sanity check of clearTagStateForTagPoolingServers() behaviour.
|
||||
}
|
||||
|
||||
public void testSortWithIllegalComparator() throws Exception {
|
||||
@@ -178,6 +332,7 @@ public class SortIteratorTagTest extends AbstractTagTest {
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
// The doEndTag() call is expected not to complete. Cannot perform basic sanity check of clearTagStateForTagPoolingServers() behaviour.
|
||||
}
|
||||
|
||||
public Action getAction() {
|
||||
|
||||
@@ -51,6 +51,13 @@ public class SubsetIteratorTagTest extends AbstractTagTest {
|
||||
assertEquals(subsetIterator.next(), new Integer(3));
|
||||
assertEquals(subsetIterator.next(), new Integer(4));
|
||||
assertEquals(subsetIterator.next(), new Integer(5));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SubsetIteratorTag freshTag = new SubsetIteratorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
{ // Array as Source
|
||||
@@ -67,6 +74,65 @@ public class SubsetIteratorTagTest extends AbstractTagTest {
|
||||
assertEquals(subsetIterator.next(), new Integer(3));
|
||||
assertEquals(subsetIterator.next(), new Integer(4));
|
||||
assertEquals(subsetIterator.next(), new Integer(5));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SubsetIteratorTag freshTag = new SubsetIteratorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
}
|
||||
|
||||
public void testBasic_clearTagStateSet() throws Exception {
|
||||
{ // List as Source
|
||||
SubsetIteratorTag tag = new SubsetIteratorTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setSource("myList");
|
||||
|
||||
tag.doStartTag();
|
||||
Iterator subsetIterator = (Iterator) stack.findValue("top");
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals(subsetIterator.next(), new Integer(1));
|
||||
assertEquals(subsetIterator.next(), new Integer(2));
|
||||
assertEquals(subsetIterator.next(), new Integer(3));
|
||||
assertEquals(subsetIterator.next(), new Integer(4));
|
||||
assertEquals(subsetIterator.next(), new Integer(5));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SubsetIteratorTag freshTag = new SubsetIteratorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
{ // Array as Source
|
||||
SubsetIteratorTag tag = new SubsetIteratorTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setSource("myArray");
|
||||
|
||||
tag.doStartTag();
|
||||
Iterator subsetIterator = (Iterator) stack.findValue("top");
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals(subsetIterator.next(), new Integer(1));
|
||||
assertEquals(subsetIterator.next(), new Integer(2));
|
||||
assertEquals(subsetIterator.next(), new Integer(3));
|
||||
assertEquals(subsetIterator.next(), new Integer(4));
|
||||
assertEquals(subsetIterator.next(), new Integer(5));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SubsetIteratorTag freshTag = new SubsetIteratorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,6 +149,13 @@ public class SubsetIteratorTagTest extends AbstractTagTest {
|
||||
|
||||
assertEquals(subsetIterator.next(), new Integer(4));
|
||||
assertEquals(subsetIterator.next(), new Integer(5));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SubsetIteratorTag freshTag = new SubsetIteratorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
{ // Array as source
|
||||
@@ -97,6 +170,61 @@ public class SubsetIteratorTagTest extends AbstractTagTest {
|
||||
|
||||
assertEquals(subsetIterator.next(), new Integer(4));
|
||||
assertEquals(subsetIterator.next(), new Integer(5));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SubsetIteratorTag freshTag = new SubsetIteratorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
}
|
||||
|
||||
public void testWithStartAttribute_clearTagStateSet() throws Exception {
|
||||
{ // List as source
|
||||
SubsetIteratorTag tag = new SubsetIteratorTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setSource("myList");
|
||||
tag.setStart("3");
|
||||
|
||||
tag.doStartTag();
|
||||
Iterator subsetIterator = (Iterator) stack.findValue("top");
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals(subsetIterator.next(), new Integer(4));
|
||||
assertEquals(subsetIterator.next(), new Integer(5));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SubsetIteratorTag freshTag = new SubsetIteratorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
{ // Array as source
|
||||
SubsetIteratorTag tag = new SubsetIteratorTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setSource("myArray");
|
||||
tag.setStart("3");
|
||||
|
||||
tag.doStartTag();
|
||||
Iterator subsetIterator = (Iterator) stack.findValue("top");
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals(subsetIterator.next(), new Integer(4));
|
||||
assertEquals(subsetIterator.next(), new Integer(5));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SubsetIteratorTag freshTag = new SubsetIteratorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,6 +242,13 @@ public class SubsetIteratorTagTest extends AbstractTagTest {
|
||||
assertEquals(subsetIterator.next(), new Integer(1));
|
||||
assertEquals(subsetIterator.next(), new Integer(2));
|
||||
assertEquals(subsetIterator.next(), new Integer(3));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SubsetIteratorTag freshTag = new SubsetIteratorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
{ // array as source
|
||||
@@ -129,6 +264,63 @@ public class SubsetIteratorTagTest extends AbstractTagTest {
|
||||
assertEquals(subsetIterator.next(), new Integer(1));
|
||||
assertEquals(subsetIterator.next(), new Integer(2));
|
||||
assertEquals(subsetIterator.next(), new Integer(3));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SubsetIteratorTag freshTag = new SubsetIteratorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
}
|
||||
|
||||
public void testWithCountAttribute_clearTagStateSet() throws Exception {
|
||||
{ // List as source
|
||||
SubsetIteratorTag tag = new SubsetIteratorTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setSource("myList");
|
||||
tag.setCount("3");
|
||||
|
||||
tag.doStartTag();
|
||||
Iterator subsetIterator = (Iterator) stack.findValue("top");
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals(subsetIterator.next(), new Integer(1));
|
||||
assertEquals(subsetIterator.next(), new Integer(2));
|
||||
assertEquals(subsetIterator.next(), new Integer(3));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SubsetIteratorTag freshTag = new SubsetIteratorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
{ // array as source
|
||||
SubsetIteratorTag tag = new SubsetIteratorTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setSource("myArray");
|
||||
tag.setCount("3");
|
||||
|
||||
tag.doStartTag();
|
||||
Iterator subsetIterator = (Iterator) stack.findValue("top");
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals(subsetIterator.next(), new Integer(1));
|
||||
assertEquals(subsetIterator.next(), new Integer(2));
|
||||
assertEquals(subsetIterator.next(), new Integer(3));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SubsetIteratorTag freshTag = new SubsetIteratorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,6 +338,13 @@ public class SubsetIteratorTagTest extends AbstractTagTest {
|
||||
|
||||
assertEquals(subsetIterator.next(), new Integer("4"));
|
||||
assertEquals(subsetIterator.next(), new Integer("5"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SubsetIteratorTag freshTag = new SubsetIteratorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
{ // Array as source
|
||||
@@ -161,6 +360,63 @@ public class SubsetIteratorTagTest extends AbstractTagTest {
|
||||
|
||||
assertEquals(subsetIterator.next(), new Integer("4"));
|
||||
assertEquals(subsetIterator.next(), new Integer("5"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SubsetIteratorTag freshTag = new SubsetIteratorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
}
|
||||
|
||||
public void testWIthStartAndCountAttribute_clearTagStateSet() throws Exception {
|
||||
{ // List as source
|
||||
SubsetIteratorTag tag = new SubsetIteratorTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setSource("myList");
|
||||
tag.setStart("3");
|
||||
tag.setCount("3");
|
||||
|
||||
tag.doStartTag();
|
||||
Iterator subsetIterator = (Iterator) stack.findValue("top");
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals(subsetIterator.next(), new Integer("4"));
|
||||
assertEquals(subsetIterator.next(), new Integer("5"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SubsetIteratorTag freshTag = new SubsetIteratorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
{ // Array as source
|
||||
SubsetIteratorTag tag = new SubsetIteratorTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setSource("myArray");
|
||||
tag.setStart("3");
|
||||
tag.setCount("3");
|
||||
|
||||
tag.doStartTag();
|
||||
Iterator subsetIterator = (Iterator) stack.findValue("top");
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals(subsetIterator.next(), new Integer("4"));
|
||||
assertEquals(subsetIterator.next(), new Integer("5"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SubsetIteratorTag freshTag = new SubsetIteratorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,6 +441,13 @@ public class SubsetIteratorTagTest extends AbstractTagTest {
|
||||
assertEquals(subsetIterator2.next(), new Integer(3));
|
||||
assertEquals(subsetIterator2.next(), new Integer(4));
|
||||
assertEquals(subsetIterator2.next(), new Integer(5));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SubsetIteratorTag freshTag = new SubsetIteratorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
{ // Array as source
|
||||
@@ -207,6 +470,77 @@ public class SubsetIteratorTagTest extends AbstractTagTest {
|
||||
assertEquals(subsetIterator2.next(), new Integer(3));
|
||||
assertEquals(subsetIterator2.next(), new Integer(4));
|
||||
assertEquals(subsetIterator2.next(), new Integer(5));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SubsetIteratorTag freshTag = new SubsetIteratorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
}
|
||||
|
||||
public void testWithId_clearTagStateSet() throws Exception {
|
||||
{ // List as Source
|
||||
SubsetIteratorTag tag = new SubsetIteratorTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setSource("myList");
|
||||
tag.setVar("myPageContextId1");
|
||||
|
||||
tag.doStartTag();
|
||||
Iterator subsetIterator1 = (Iterator) stack.findValue("top");
|
||||
tag.doEndTag();
|
||||
|
||||
Iterator subsetIterator2 = (Iterator) pageContext.getAttribute("myPageContextId1");
|
||||
|
||||
assertNotNull(subsetIterator1);
|
||||
assertNotNull(subsetIterator2);
|
||||
assertEquals(subsetIterator1, subsetIterator2);
|
||||
assertEquals(subsetIterator2.next(), new Integer(1));
|
||||
assertEquals(subsetIterator2.next(), new Integer(2));
|
||||
assertEquals(subsetIterator2.next(), new Integer(3));
|
||||
assertEquals(subsetIterator2.next(), new Integer(4));
|
||||
assertEquals(subsetIterator2.next(), new Integer(5));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SubsetIteratorTag freshTag = new SubsetIteratorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
{ // Array as source
|
||||
SubsetIteratorTag tag = new SubsetIteratorTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setSource("myArray");
|
||||
tag.setVar("myPageContextId2");
|
||||
|
||||
tag.doStartTag();
|
||||
Iterator subsetIterator1 = (Iterator) stack.findValue("top");
|
||||
tag.doEndTag();
|
||||
|
||||
Iterator subsetIterator2 = (Iterator) pageContext.getAttribute("myPageContextId2");
|
||||
|
||||
assertNotNull(subsetIterator1);
|
||||
assertNotNull(subsetIterator2);
|
||||
assertEquals(subsetIterator1, subsetIterator2);
|
||||
assertEquals(subsetIterator2.next(), new Integer(1));
|
||||
assertEquals(subsetIterator2.next(), new Integer(2));
|
||||
assertEquals(subsetIterator2.next(), new Integer(3));
|
||||
assertEquals(subsetIterator2.next(), new Integer(4));
|
||||
assertEquals(subsetIterator2.next(), new Integer(5));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SubsetIteratorTag freshTag = new SubsetIteratorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,6 +557,13 @@ public class SubsetIteratorTagTest extends AbstractTagTest {
|
||||
|
||||
assertEquals(subsetIterator.next(), new Integer(2));
|
||||
assertEquals(subsetIterator.next(), new Integer(4));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SubsetIteratorTag freshTag = new SubsetIteratorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
{ // Array As source
|
||||
@@ -237,11 +578,65 @@ public class SubsetIteratorTagTest extends AbstractTagTest {
|
||||
|
||||
assertEquals(subsetIterator.next(), new Integer(2));
|
||||
assertEquals(subsetIterator.next(), new Integer(4));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SubsetIteratorTag freshTag = new SubsetIteratorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
}
|
||||
|
||||
public void testWithDecider_clearTagStateSet() throws Exception {
|
||||
{ // List as source
|
||||
SubsetIteratorTag tag = new SubsetIteratorTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setSource("myList");
|
||||
tag.setDecider("myDecider");
|
||||
|
||||
tag.doStartTag();
|
||||
Iterator subsetIterator = (Iterator) stack.findValue("top");
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals(subsetIterator.next(), new Integer(2));
|
||||
assertEquals(subsetIterator.next(), new Integer(4));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SubsetIteratorTag freshTag = new SubsetIteratorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
{ // Array As source
|
||||
SubsetIteratorTag tag = new SubsetIteratorTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setSource("myList");
|
||||
tag.setDecider("myDecider");
|
||||
|
||||
tag.doStartTag();
|
||||
Iterator subsetIterator = (Iterator) stack.findValue("top");
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals(subsetIterator.next(), new Integer(2));
|
||||
assertEquals(subsetIterator.next(), new Integer(4));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
SubsetIteratorTag freshTag = new SubsetIteratorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Action getAction() {
|
||||
return new ActionSupport() {
|
||||
public List getMyList() {
|
||||
|
||||
@@ -50,6 +50,7 @@ public class TextTagTest extends AbstractTagTest {
|
||||
private TextTag tag;
|
||||
|
||||
|
||||
@Override
|
||||
public Action getAction() {
|
||||
TestAction action = new TestAction();
|
||||
action.setFoo(fooValue);
|
||||
@@ -71,6 +72,39 @@ public class TextTagTest extends AbstractTagTest {
|
||||
|
||||
assertEquals(startStatus, BodyTag.EVAL_BODY_BUFFERED);
|
||||
assertEquals("Sample Of Default Message", writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
TextTag freshTag = new TextTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testDefaultMessageOk_clearTagStateSet() throws Exception {
|
||||
// NOTE:
|
||||
// simulate the condition
|
||||
// <s:text name="some.invalid.key">My Default Message</s:text>
|
||||
|
||||
StrutsMockBodyContent mockBodyContent = new StrutsMockBodyContent(new MockJspWriter());
|
||||
mockBodyContent.setString("Sample Of Default Message");
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setBodyContent(mockBodyContent);
|
||||
tag.setName("some.invalid.key.so.we.should.get.the.default.message");
|
||||
int startStatus = tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals(startStatus, BodyTag.EVAL_BODY_BUFFERED);
|
||||
assertEquals("Sample Of Default Message", writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
TextTag freshTag = new TextTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testExpressionsEvaluated() throws Exception {
|
||||
@@ -80,6 +114,32 @@ public class TextTagTest extends AbstractTagTest {
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
assertEquals(value, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
TextTag freshTag = new TextTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testExpressionsEvaluated_clearTagStateSet() throws Exception {
|
||||
String key = "expressionKey";
|
||||
String value = "Foo is " + fooValue;
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setName(key);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
assertEquals(value, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
TextTag freshTag = new TextTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testCorrectI18NKey() throws Exception {
|
||||
@@ -89,6 +149,32 @@ public class TextTagTest extends AbstractTagTest {
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
assertEquals(value, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
TextTag freshTag = new TextTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testCorrectI18NKey_clearTagStateSet() throws Exception {
|
||||
String key = "foo.bar.baz";
|
||||
String value = "This should start with foo";
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setName(key);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
assertEquals(value, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
TextTag freshTag = new TextTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testCorrectI18NKey2() throws Exception {
|
||||
@@ -98,6 +184,32 @@ public class TextTagTest extends AbstractTagTest {
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
assertEquals(value, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
TextTag freshTag = new TextTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testCorrectI18NKey2_clearTagStateSet() throws Exception {
|
||||
String key = "bar.baz";
|
||||
String value = "No foo here";
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setName(key);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
assertEquals(value, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
TextTag freshTag = new TextTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testMessageFormatWorks() throws Exception {
|
||||
@@ -121,6 +233,46 @@ public class TextTagTest extends AbstractTagTest {
|
||||
((Text) tag.component).addParameter(param3);
|
||||
tag.doEndTag();
|
||||
assertEquals(expected, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
TextTag freshTag = new TextTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testMessageFormatWorks_clearTagStateSet() throws Exception {
|
||||
String key = "messageFormatKey";
|
||||
String pattern = "Params are {0} {1} {2}";
|
||||
Object param1 = new Integer(12);
|
||||
Object param2 = new Date();
|
||||
Object param3 = "StringVal";
|
||||
List params = new ArrayList();
|
||||
params.add(param1);
|
||||
params.add(param2);
|
||||
params.add(param3);
|
||||
|
||||
MessageFormat format = new MessageFormat(pattern, ActionContext.getContext().getLocale());
|
||||
String expected = format.format(params.toArray());
|
||||
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setName(key);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
((Text) tag.component).addParameter(param1);
|
||||
((Text) tag.component).addParameter(param2);
|
||||
((Text) tag.component).addParameter(param3);
|
||||
tag.doEndTag();
|
||||
assertEquals(expected, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
TextTag freshTag = new TextTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testSimpleKeyValueWorks() throws JspException {
|
||||
@@ -130,6 +282,32 @@ public class TextTagTest extends AbstractTagTest {
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
assertEquals(value, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
TextTag freshTag = new TextTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testSimpleKeyValueWorks_clearTagStateSet() throws JspException {
|
||||
String key = "simpleKey";
|
||||
String value = "Simple Message";
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setName(key);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
assertEquals(value, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
TextTag freshTag = new TextTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
private Locale getForeignLocale() {
|
||||
@@ -169,6 +347,14 @@ public class TextTagTest extends AbstractTagTest {
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
assertEquals(value1, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
TextTag freshTag = new TextTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
|
||||
final StringBuffer buffer = writer.getBuffer();
|
||||
buffer.delete(0, buffer.length());
|
||||
ValueStack newStack = container.getInstance(ValueStackFactory.class).createValueStack();
|
||||
@@ -176,10 +362,56 @@ public class TextTagTest extends AbstractTagTest {
|
||||
newStack.push(container.inject(TestAction1.class));
|
||||
request.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, newStack);
|
||||
assertNotSame(ActionContext.getContext().getValueStack().peek(), newStack.peek());
|
||||
|
||||
tag.setName(key); // Required as WW-5124 fix clears tag state.
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
assertEquals(value2, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testTextTagUsesValueStackInRequestNotActionContext_clearTagStateSet() throws JspException {
|
||||
String key = "simpleKey";
|
||||
String value1 = "Simple Message";
|
||||
Locale foreignLocale = getForeignLocale();
|
||||
String value2 = getLocalizedMessage(foreignLocale);
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setName(key);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
assertEquals(value1, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
TextTag freshTag = new TextTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
|
||||
final StringBuffer buffer = writer.getBuffer();
|
||||
buffer.delete(0, buffer.length());
|
||||
ValueStack newStack = container.getInstance(ValueStackFactory.class).createValueStack();
|
||||
newStack.getContext().put(ActionContext.LOCALE, foreignLocale);
|
||||
newStack.getContext().put(ActionContext.CONTAINER, container);
|
||||
newStack.push(container.inject(TestAction1.class));
|
||||
request.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, newStack);
|
||||
assertNotSame(ActionContext.getContext().getValueStack().peek(), newStack.peek());
|
||||
tag.setName(key); // Required as WW-5124 fix clears tag state.
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
assertEquals(value2, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testTextTagUsesLocaleFromValueStack() throws JspException {
|
||||
@@ -198,6 +430,13 @@ public class TextTagTest extends AbstractTagTest {
|
||||
tag.doEndTag();
|
||||
assertEquals(value_default, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
TextTag freshTag = new TextTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
|
||||
final StringBuffer buffer = writer.getBuffer();
|
||||
buffer.delete(0, buffer.length());
|
||||
String value_int = getLocalizedMessage(foreignLocale);
|
||||
@@ -207,9 +446,64 @@ public class TextTagTest extends AbstractTagTest {
|
||||
assertNotSame(newStack.getActionContext().getLocale(), ActionContext.getContext().getLocale());
|
||||
request.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, newStack);
|
||||
assertEquals(ActionContext.getContext().getValueStack().peek(), newStack.peek());
|
||||
tag.setName(key); // Required as WW-5124 fix clears tag state.
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
assertEquals(value_int, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testTextTagUsesLocaleFromValueStack_clearTagStateSet() throws JspException {
|
||||
stack.pop();
|
||||
stack.push(container.inject(TestAction1.class));
|
||||
|
||||
Locale defaultLocale = getDefaultLocale();
|
||||
Locale foreignLocale = getForeignLocale();
|
||||
assertNotSame(defaultLocale, foreignLocale);
|
||||
|
||||
ActionContext.getContext().setLocale(defaultLocale);
|
||||
String key = "simpleKey";
|
||||
String value_default = getLocalizedMessage(defaultLocale);
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setName(key);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
assertEquals(value_default, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
TextTag freshTag = new TextTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
|
||||
final StringBuffer buffer = writer.getBuffer();
|
||||
buffer.delete(0, buffer.length());
|
||||
String value_int = getLocalizedMessage(foreignLocale);
|
||||
assertFalse(value_default.equals(value_int));
|
||||
ValueStack newStack = container.getInstance(ValueStackFactory.class).createValueStack(stack);
|
||||
newStack.getContext().put(ActionContext.LOCALE, foreignLocale);
|
||||
newStack.getContext().put(ActionContext.CONTAINER, container);
|
||||
assertNotSame(newStack.getContext().get(ActionContext.LOCALE), ActionContext.getContext().getLocale());
|
||||
request.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, newStack);
|
||||
assertEquals(ActionContext.getContext().getValueStack().peek(), newStack.peek());
|
||||
tag.setName(key); // Required as WW-5124 fix clears tag state.
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
assertEquals(value_int, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testWithNoMessageAndBodyIsNotEmptyBodyIsReturned() throws Exception {
|
||||
@@ -223,6 +517,36 @@ public class TextTagTest extends AbstractTagTest {
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
assertEquals(bodyText, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
TextTag freshTag = new TextTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testWithNoMessageAndBodyIsNotEmptyBodyIsReturned_clearTagStateSet() throws Exception {
|
||||
final String key = "key.does.not.exist";
|
||||
final String bodyText = "body text";
|
||||
tag.setName(key);
|
||||
|
||||
StrutsBodyContent bodyContent = new StrutsBodyContent(null);
|
||||
bodyContent.print(bodyText);
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setBodyContent(bodyContent);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
assertEquals(bodyText, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
TextTag freshTag = new TextTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testWithNoMessageAndNoDefaultKeyReturned() throws JspException {
|
||||
@@ -231,6 +555,31 @@ public class TextTagTest extends AbstractTagTest {
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
assertEquals(key, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
TextTag freshTag = new TextTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testWithNoMessageAndNoDefaultKeyReturned_clearTagStateSet() throws JspException {
|
||||
final String key = "key.does.not.exist";
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setName(key);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
assertEquals(key, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
TextTag freshTag = new TextTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testNoNameDefined() throws Exception {
|
||||
@@ -242,6 +591,8 @@ public class TextTagTest extends AbstractTagTest {
|
||||
} catch (StrutsException e) {
|
||||
assertEquals(msg, e.getMessage());
|
||||
}
|
||||
|
||||
// The doEndTag() call is expected not to complete. Cannot perform basic sanity check of clearTagStateForTagPoolingServers() behaviour.
|
||||
}
|
||||
|
||||
public void testBlankNameDefined() throws Exception {
|
||||
@@ -249,6 +600,30 @@ public class TextTagTest extends AbstractTagTest {
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
assertEquals("", writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
TextTag freshTag = new TextTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testBlankNameDefined_clearTagStateSet() throws Exception {
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setName("");
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
assertEquals("", writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
TextTag freshTag = new TextTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testPutId() throws Exception {
|
||||
@@ -259,6 +634,33 @@ public class TextTagTest extends AbstractTagTest {
|
||||
tag.doEndTag();
|
||||
assertEquals("", writer.toString());
|
||||
assertEquals("No foo here", stack.findString("myId")); // is in stack now
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
TextTag freshTag = new TextTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testPutId_clearTagStateSet() throws Exception {
|
||||
assertEquals(null, stack.findString("myId")); // nothing in stack
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setVar("myId");
|
||||
tag.setName("bar.baz");
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
assertEquals("", writer.toString());
|
||||
assertEquals("No foo here", stack.findString("myId")); // is in stack now
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
TextTag freshTag = new TextTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testEscapeHtml() throws Exception {
|
||||
@@ -269,6 +671,33 @@ public class TextTagTest extends AbstractTagTest {
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
assertEquals(value, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
TextTag freshTag = new TextTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testEscapeHtml_clearTagStateSet() throws Exception {
|
||||
final String key = "foo.escape.html";
|
||||
final String value = "1 < 2";
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setName(key);
|
||||
tag.setEscapeHtml(true);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
assertEquals(value, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
TextTag freshTag = new TextTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testEscapeXml() throws Exception {
|
||||
@@ -279,6 +708,33 @@ public class TextTagTest extends AbstractTagTest {
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
assertEquals(value, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
TextTag freshTag = new TextTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testEscapeXml_clearTagStateSet() throws Exception {
|
||||
final String key = "foo.escape.xml";
|
||||
final String value = "<>'"&";
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setName(key);
|
||||
tag.setEscapeXml(true);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
assertEquals(value, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
TextTag freshTag = new TextTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testEscapeJavaScript() throws Exception {
|
||||
@@ -289,6 +745,33 @@ public class TextTagTest extends AbstractTagTest {
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
assertEquals(value, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
TextTag freshTag = new TextTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testEscapeJavaScript_clearTagStateSet() throws Exception {
|
||||
final String key = "foo.escape.javascript";
|
||||
final String value = "\\t\\b\\n\\f\\r\\\"\\\'\\/\\\\";
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setName(key);
|
||||
tag.setEscapeJavaScript(true);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
assertEquals(value, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
TextTag freshTag = new TextTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testEscapeCsv() throws Exception {
|
||||
@@ -299,8 +782,41 @@ public class TextTagTest extends AbstractTagTest {
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
assertEquals(value, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
TextTag freshTag = new TextTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testEscapeCsv_clearTagStateSet() throws Exception {
|
||||
final String key = "foo.escape.csv";
|
||||
final String value = "\"something,\"\",\"\"\"";
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setName(key);
|
||||
tag.setEscapeCsv(true);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
assertEquals(value, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
TextTag freshTag = new TextTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
/**
|
||||
* todo remove ActionContext set after LocalizedTextUtil is fixed to not use ThreadLocal
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
tag = new TextTag();
|
||||
@@ -308,6 +824,7 @@ public class TextTagTest extends AbstractTagTest {
|
||||
ActionContext.of(stack.getContext()).bind();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -45,6 +45,35 @@ public class ActionErrorTagTest extends AbstractUITagTest {
|
||||
|
||||
//assertEquals("", writer.toString());
|
||||
verify(ActionErrorTagTest.class.getResource("actionerror-1.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionErrorTag freshTag = new ActionErrorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
// AcionErrorTag has no additional state set here, so it compares as equal with the default tag clear state as well.
|
||||
assertTrue("Tag state after doEndTag() under default tag clear state is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testNoActionErrors_clearTagStateSet() throws Exception {
|
||||
ActionErrorTag tag = new ActionErrorTag();
|
||||
((InternalActionSupport)action).setHasActionErrors(false);
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
//assertEquals("", writer.toString());
|
||||
verify(ActionErrorTagTest.class.getResource("actionerror-1.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionErrorTag freshTag = new ActionErrorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testActionErrorsEscape() throws Exception {
|
||||
@@ -61,6 +90,40 @@ public class ActionErrorTagTest extends AbstractUITagTest {
|
||||
|
||||
assertEquals(normalize("<ul class=\"errorMessage\"><li><span><p>hey</p></span></li></ul>", true),
|
||||
normalize(writer.toString(), true));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionErrorTag freshTag = new ActionErrorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
// AcionErrorTag sets escape true by default and has no additional state set here, so it compares as equal with the default tag clear state as well.
|
||||
assertTrue("Tag state after doEndTag() under default tag clear state is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testActionErrorsEscape_clearTagStateSet() throws Exception {
|
||||
|
||||
ActionErrorTag tag = new ActionErrorTag();
|
||||
TestAction testAction = new TestAction();
|
||||
testAction.addActionError("<p>hey</p>");
|
||||
stack.pop();
|
||||
stack.push(testAction);
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setEscape(true);
|
||||
tag.setPageContext(pageContext);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals(normalize("<ul class=\"errorMessage\"><li><span><p>hey</p></span></li></ul>", true),
|
||||
normalize(writer.toString(), true));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionErrorTag freshTag = new ActionErrorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testActionErrorsDontEscape() throws Exception {
|
||||
@@ -77,6 +140,39 @@ public class ActionErrorTagTest extends AbstractUITagTest {
|
||||
|
||||
assertEquals(normalize("<ul class=\"errorMessage\"><li><span><p>hey</p></span></li></ul>", true),
|
||||
normalize(writer.toString(), true));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionErrorTag freshTag = new ActionErrorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testActionErrorsDontEscape_clearTagStateSet() throws Exception {
|
||||
|
||||
ActionErrorTag tag = new ActionErrorTag();
|
||||
TestAction testAction = new TestAction();
|
||||
testAction.addActionError("<p>hey</p>");
|
||||
stack.pop();
|
||||
stack.push(testAction);
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setEscape(false);
|
||||
tag.setPageContext(pageContext);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals(normalize("<ul class=\"errorMessage\"><li><span><p>hey</p></span></li></ul>", true),
|
||||
normalize(writer.toString(), true));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionErrorTag freshTag = new ActionErrorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testHaveActionErrors() throws Exception {
|
||||
@@ -89,6 +185,35 @@ public class ActionErrorTagTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(ActionErrorTagTest.class.getResource("actionerror-2.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionErrorTag freshTag = new ActionErrorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testHaveActionErrors_clearTagStateSet() throws Exception {
|
||||
|
||||
ActionErrorTag tag = new ActionErrorTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setId("someid");
|
||||
((InternalActionSupport)action).setHasActionErrors(true);
|
||||
tag.setPageContext(pageContext);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(ActionErrorTagTest.class.getResource("actionerror-2.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionErrorTag freshTag = new ActionErrorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testNullError() throws Exception {
|
||||
@@ -102,6 +227,36 @@ public class ActionErrorTagTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(ActionErrorTagTest.class.getResource("actionerror-2.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionErrorTag freshTag = new ActionErrorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testNullError_clearTagStateSet() throws Exception {
|
||||
|
||||
ActionErrorTag tag = new ActionErrorTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setId("someid");
|
||||
((InternalActionSupport)action).setHasActionErrors(true);
|
||||
((InternalActionSupport)action).addActionError(null);
|
||||
tag.setPageContext(pageContext);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(ActionErrorTagTest.class.getResource("actionerror-2.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionErrorTag freshTag = new ActionErrorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testEmptyErrorList() throws Exception {
|
||||
@@ -115,9 +270,39 @@ public class ActionErrorTagTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
assertTrue(StringUtils.isBlank(writer.toString()));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionErrorTag freshTag = new ActionErrorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testEmptyErrorList_clearTagStateSet() throws Exception {
|
||||
|
||||
ActionErrorTag tag = new ActionErrorTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setId("someid");
|
||||
((InternalActionSupport)action).setHasActionErrors(true);
|
||||
((InternalActionSupport)action).setJustNullElement(true);
|
||||
tag.setPageContext(pageContext);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
assertTrue(StringUtils.isBlank(writer.toString()));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionErrorTag freshTag = new ActionErrorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Action getAction() {
|
||||
return new InternalActionSupport();
|
||||
}
|
||||
@@ -138,10 +323,12 @@ public class ActionErrorTagTest extends AbstractUITagTest {
|
||||
yesActionErrors = aYesActionErrors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasActionErrors() {
|
||||
return yesActionErrors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection getActionErrors() {
|
||||
if (justNullElement) {
|
||||
return Arrays.asList(null);
|
||||
|
||||
@@ -45,6 +45,35 @@ public class ActionMessageTagTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(ActionMessageTagTest.class.getResource("actionmessage-1.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionMessageTag freshTag = new ActionMessageTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
// AcionMessageTag has no additional state set here, so it compares as equal with the default tag clear state as well.
|
||||
assertTrue("Tag state after doEndTag() under default tag clear state is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testNoActionMessages_clearTagStateSet() throws Exception {
|
||||
|
||||
ActionMessageTag tag = new ActionMessageTag();
|
||||
((InternalActionSupport)action).setHasActionMessage(false);
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(ActionMessageTagTest.class.getResource("actionmessage-1.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionMessageTag freshTag = new ActionMessageTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testActionMessageEscape() throws Exception {
|
||||
@@ -61,6 +90,40 @@ public class ActionMessageTagTest extends AbstractUITagTest {
|
||||
|
||||
assertEquals(normalize("<ul class=\"actionMessage\"><li><span><p>hey</p></span></li></ul>", true),
|
||||
normalize(writer.toString(), true));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionMessageTag freshTag = new ActionMessageTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
// AcionMessageTag sets escape true by default and has no additional state set here, so it compares as equal with the default tag clear state as well.
|
||||
assertTrue("Tag state after doEndTag() under default tag clear state is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testActionMessageEscape_clearTagStateSet() throws Exception {
|
||||
|
||||
ActionMessageTag tag = new ActionMessageTag();
|
||||
TestAction testAction = new TestAction();
|
||||
testAction.addActionMessage("<p>hey</p>");
|
||||
stack.pop();
|
||||
stack.push(testAction);
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setEscape(true);
|
||||
tag.setPageContext(pageContext);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals(normalize("<ul class=\"actionMessage\"><li><span><p>hey</p></span></li></ul>", true),
|
||||
normalize(writer.toString(), true));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionMessageTag freshTag = new ActionMessageTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testActionErrorsDontEscape() throws Exception {
|
||||
@@ -77,8 +140,40 @@ public class ActionMessageTagTest extends AbstractUITagTest {
|
||||
|
||||
assertEquals(normalize("<ul class=\"actionMessage\"><li><span><p>hey</p></span></li></ul>", true),
|
||||
normalize(writer.toString(), true));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionMessageTag freshTag = new ActionMessageTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testActionErrorsDontEscape_clearTagStateSet() throws Exception {
|
||||
|
||||
ActionMessageTag tag = new ActionMessageTag();
|
||||
TestAction testAction = new TestAction();
|
||||
testAction.addActionMessage("<p>hey</p>");
|
||||
stack.pop();
|
||||
stack.push(testAction);
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setEscape(false);
|
||||
tag.setPageContext(pageContext);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals(normalize("<ul class=\"actionMessage\"><li><span><p>hey</p></span></li></ul>", true),
|
||||
normalize(writer.toString(), true));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionMessageTag freshTag = new ActionMessageTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testYesActionMessages() throws Exception {
|
||||
|
||||
@@ -90,6 +185,35 @@ public class ActionMessageTagTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(ActionMessageTagTest.class.getResource("actionmessage-2.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionMessageTag freshTag = new ActionMessageTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testYesActionMessages_clearTagStateSet() throws Exception {
|
||||
|
||||
ActionMessageTag tag = new ActionMessageTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setId("someid");
|
||||
((InternalActionSupport)action).setHasActionMessage(true);
|
||||
tag.setPageContext(pageContext);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(ActionMessageTagTest.class.getResource("actionmessage-2.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionMessageTag freshTag = new ActionMessageTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testYesActionMessagesWithEmptyMessages() throws Exception {
|
||||
@@ -102,7 +226,37 @@ public class ActionMessageTagTest extends AbstractUITagTest {
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
|
||||
assertTrue(StringUtils.isBlank(writer.toString()));
|
||||
assertTrue(StringUtils.isBlank(writer.toString()));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionMessageTag freshTag = new ActionMessageTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testYesActionMessagesWithEmptyMessages_clearTagStateSet() throws Exception {
|
||||
|
||||
ActionMessageTag tag = new ActionMessageTag();
|
||||
tag.setId("someid");
|
||||
InternalActionSupport internalActionSupport = (InternalActionSupport) action;
|
||||
internalActionSupport.setJustNullElement(true);
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
assertTrue(StringUtils.isBlank(writer.toString()));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionMessageTag freshTag = new ActionMessageTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testNullMessage() throws Exception {
|
||||
@@ -116,8 +270,39 @@ public class ActionMessageTagTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(ActionMessageTagTest.class.getResource("actionmessage-2.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionMessageTag freshTag = new ActionMessageTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testNullMessage_clearTagStateSet() throws Exception {
|
||||
|
||||
ActionMessageTag tag = new ActionMessageTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setId("someid");
|
||||
((InternalActionSupport)action).setHasActionMessage(true);
|
||||
((InternalActionSupport)action).addActionMessage(null);
|
||||
tag.setPageContext(pageContext);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(ActionMessageTagTest.class.getResource("actionmessage-2.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ActionMessageTag freshTag = new ActionMessageTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Action getAction() {
|
||||
return new InternalActionSupport();
|
||||
}
|
||||
@@ -142,6 +327,7 @@ public class ActionMessageTagTest extends AbstractUITagTest {
|
||||
this.justNullElement = justNullElement;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection getActionMessages() {
|
||||
if (justNullElement) {
|
||||
return Arrays.asList(null);
|
||||
@@ -157,6 +343,7 @@ public class ActionMessageTagTest extends AbstractUITagTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasActionMessages() {
|
||||
return canHaveActionMessage;
|
||||
}
|
||||
|
||||
@@ -47,6 +47,34 @@ public class AnchorTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verifyResource("href-1.txt");
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
AnchorTag freshTag = new AnchorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testSimple_clearTagStateSet() throws Exception {
|
||||
createAction();
|
||||
|
||||
AnchorTag tag = createTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setHref("a");
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verifyResource("href-1.txt");
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
AnchorTag freshTag = new AnchorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testSimpleBadQuote() throws Exception {
|
||||
@@ -58,6 +86,34 @@ public class AnchorTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verifyResource("href-2.txt");
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
AnchorTag freshTag = new AnchorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testSimpleBadQuote_clearTagStateSet() throws Exception {
|
||||
createAction();
|
||||
|
||||
AnchorTag tag = createTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setHref("a\"");
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verifyResource("href-2.txt");
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
AnchorTag freshTag = new AnchorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testDynamicAttribute() throws Exception {
|
||||
@@ -72,6 +128,37 @@ public class AnchorTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verifyResource("Anchor-2.txt");
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
AnchorTag freshTag = new AnchorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testDynamicAttribute_clearTagStateSet() throws Exception {
|
||||
createAction();
|
||||
|
||||
AnchorTag tag = createTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setHref("a");
|
||||
|
||||
tag.setDynamicAttribute("uri", "dynAttrName", "dynAttrValue");
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verifyResource("Anchor-2.txt");
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
AnchorTag freshTag = new AnchorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testDynamicAttributeAsExpression() throws Exception {
|
||||
@@ -86,6 +173,37 @@ public class AnchorTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verifyResource("Anchor-3.txt");
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
AnchorTag freshTag = new AnchorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testDynamicAttributeAsExpression_clearTagStateSet() throws Exception {
|
||||
createAction();
|
||||
|
||||
AnchorTag tag = createTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setHref("a");
|
||||
|
||||
tag.setDynamicAttribute("uri", "placeholder", "%{foo}");
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verifyResource("Anchor-3.txt");
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
AnchorTag freshTag = new AnchorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
private void createAction() {
|
||||
|
||||
@@ -40,6 +40,7 @@ public class CheckboxListTest extends AbstractUITagTest {
|
||||
* @return A Map of PropertyHolders values bound to {@link org.apache.struts2.views.jsp.AbstractUITagTest.PropertyHolder#getName()}
|
||||
* as key.
|
||||
*/
|
||||
@Override
|
||||
protected Map<String, PropertyHolder> initializedGenericTagTestProperties() {
|
||||
Map<String, PropertyHolder> result = super.initializedGenericTagTestProperties();
|
||||
new PropertyHolder("value", "hello").addToMap(result);
|
||||
@@ -98,6 +99,49 @@ public class CheckboxListTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(CheckboxListTag.class.getResource("CheckboxList-2.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
CheckboxListTag freshTag = new CheckboxListTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testMultiple_clearTagStateSet() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
Collection<String> collection = new ArrayList<String>(2);
|
||||
collection.add("hello");
|
||||
collection.add("foo");
|
||||
testAction.setCollection(collection);
|
||||
testAction.setList(new String[][]{
|
||||
{"hello", "world"},
|
||||
{"foo", "bar"},
|
||||
{"cat", "dog"}
|
||||
});
|
||||
|
||||
CheckboxListTag tag = new CheckboxListTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setLabel("mylabel");
|
||||
tag.setName("collection");
|
||||
tag.setList("list");
|
||||
tag.setListKey("top[0]");
|
||||
tag.setListValue("top[1]");
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(CheckboxListTag.class.getResource("CheckboxList-2.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
CheckboxListTag freshTag = new CheckboxListTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testMultipleWithDisabledOn() throws Exception {
|
||||
@@ -125,6 +169,50 @@ public class CheckboxListTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(CheckboxListTag.class.getResource("CheckboxList-3.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
CheckboxListTag freshTag = new CheckboxListTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testMultipleWithDisabledOn_clearTagStateSet() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
Collection<String> collection = new ArrayList<String>(2);
|
||||
collection.add("hello");
|
||||
collection.add("foo");
|
||||
testAction.setCollection(collection);
|
||||
testAction.setList(new String[][]{
|
||||
{"hello", "world"},
|
||||
{"foo", "bar"},
|
||||
{"cat", "dog"}
|
||||
});
|
||||
|
||||
CheckboxListTag tag = new CheckboxListTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setLabel("mylabel");
|
||||
tag.setName("collection");
|
||||
tag.setList("list");
|
||||
tag.setListKey("top[0]");
|
||||
tag.setListValue("top[1]");
|
||||
tag.setDisabled("true");
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(CheckboxListTag.class.getResource("CheckboxList-3.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
CheckboxListTag freshTag = new CheckboxListTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testSimple() throws Exception {
|
||||
@@ -150,6 +238,48 @@ public class CheckboxListTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(CheckboxListTag.class.getResource("CheckboxList-1.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
CheckboxListTag freshTag = new CheckboxListTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testSimple_clearTagStateSet() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
testAction.setFoo("hello");
|
||||
testAction.setList(new String[][]{
|
||||
{"hello", "world"},
|
||||
{"foo", "bar"},
|
||||
{"baz", null}
|
||||
});
|
||||
|
||||
CheckboxListTag tag = new CheckboxListTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setLabel("mylabel");
|
||||
tag.setName("foo");
|
||||
tag.setList("list");
|
||||
tag.setListKey("top[0]");
|
||||
tag.setListValue("top[1]");
|
||||
tag.setOnchange("alert('foo');");
|
||||
tag.setTitle("mytitle");
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(CheckboxListTag.class.getResource("CheckboxList-1.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
CheckboxListTag freshTag = new CheckboxListTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testSimpleWithDisableOn() throws Exception {
|
||||
@@ -174,5 +304,46 @@ public class CheckboxListTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(CheckboxListTag.class.getResource("CheckboxList-4.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
CheckboxListTag freshTag = new CheckboxListTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testSimpleWithDisableOn_clearTagStateSet() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
testAction.setFoo("hello");
|
||||
testAction.setList(new String[][]{
|
||||
{"hello", "world"},
|
||||
{"foo", "bar"}
|
||||
});
|
||||
|
||||
CheckboxListTag tag = new CheckboxListTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setLabel("mylabel");
|
||||
tag.setName("foo");
|
||||
tag.setList("list");
|
||||
tag.setListKey("top[0]");
|
||||
tag.setListValue("top[1]");
|
||||
tag.setOnchange("alert('foo');");
|
||||
tag.setDisabled("true");
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(CheckboxListTag.class.getResource("CheckboxList-4.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
CheckboxListTag freshTag = new CheckboxListTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,6 @@
|
||||
package org.apache.struts2.views.jsp.ui;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.apache.struts2.TestAction;
|
||||
import org.apache.struts2.views.jsp.AbstractUITagTest;
|
||||
@@ -41,6 +39,7 @@ public class CheckboxTest extends AbstractUITagTest {
|
||||
* @return A Map of PropertyHolders values bound to {@link org.apache.struts2.views.jsp.AbstractUITagTest.PropertyHolder#getName()}
|
||||
* as key.
|
||||
*/
|
||||
@Override
|
||||
protected Map initializedGenericTagTestProperties() {
|
||||
Map result = super.initializedGenericTagTestProperties();
|
||||
new PropertyHolder("value", "true").addToMap(result);
|
||||
@@ -74,6 +73,42 @@ public class CheckboxTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(CheckboxTag.class.getResource("Checkbox-1.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
CheckboxTag freshTag = new CheckboxTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testChecked_clearTagStateSet() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
testAction.setFoo("true");
|
||||
|
||||
CheckboxTag tag = new CheckboxTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setId("someId");
|
||||
tag.setLabel("mylabel");
|
||||
tag.setName("foo");
|
||||
tag.setFieldValue("baz");
|
||||
tag.setOnfocus("test();");
|
||||
tag.setTitle("mytitle");
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(CheckboxTag.class.getResource("Checkbox-1.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
CheckboxTag freshTag = new CheckboxTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testCheckedWithTopLabelPosition() throws Exception {
|
||||
@@ -94,6 +129,43 @@ public class CheckboxTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(CheckboxTag.class.getResource("Checkbox-4.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
CheckboxTag freshTag = new CheckboxTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testCheckedWithTopLabelPosition_clearTagStateSet() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
testAction.setFoo("true");
|
||||
|
||||
CheckboxTag tag = new CheckboxTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setId("someId");
|
||||
tag.setLabel("mylabel");
|
||||
tag.setName("foo");
|
||||
tag.setFieldValue("baz");
|
||||
tag.setOnfocus("test();");
|
||||
tag.setTitle("mytitle");
|
||||
tag.setLabelposition("top");
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(CheckboxTag.class.getResource("Checkbox-4.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
CheckboxTag freshTag = new CheckboxTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testCheckedWithLeftLabelPosition() throws Exception {
|
||||
@@ -114,6 +186,43 @@ public class CheckboxTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(CheckboxTag.class.getResource("Checkbox-5.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
CheckboxTag freshTag = new CheckboxTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testCheckedWithLeftLabelPosition_clearTagStateSet() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
testAction.setFoo("true");
|
||||
|
||||
CheckboxTag tag = new CheckboxTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setId("someId");
|
||||
tag.setLabel("mylabel");
|
||||
tag.setName("foo");
|
||||
tag.setFieldValue("baz");
|
||||
tag.setOnfocus("test();");
|
||||
tag.setTitle("mytitle");
|
||||
tag.setLabelposition("left");
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(CheckboxTag.class.getResource("Checkbox-5.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
CheckboxTag freshTag = new CheckboxTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testCheckedWithError() throws Exception {
|
||||
@@ -136,6 +245,45 @@ public class CheckboxTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(CheckboxTag.class.getResource("Checkbox-3.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
CheckboxTag freshTag = new CheckboxTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testCheckedWithError_clearTagStateSet() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
testAction.setFoo("true");
|
||||
testAction.addFieldError("foo", "Some Foo Error");
|
||||
testAction.addFieldError("foo", "Another Foo Error");
|
||||
|
||||
CheckboxTag tag = new CheckboxTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setLabel("mylabel");
|
||||
tag.setName("foo");
|
||||
tag.setFieldValue("baz");
|
||||
tag.setOndblclick("test();");
|
||||
tag.setOnclick("test();");
|
||||
tag.setTitle("mytitle");
|
||||
tag.setCssErrorClass("myErrorClass");
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(CheckboxTag.class.getResource("Checkbox-3.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
CheckboxTag freshTag = new CheckboxTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testCheckedWithErrorStyle() throws Exception {
|
||||
@@ -158,6 +306,45 @@ public class CheckboxTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(CheckboxTag.class.getResource("Checkbox-33.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
CheckboxTag freshTag = new CheckboxTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testCheckedWithErrorStyle_clearTagStateSet() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
testAction.setFoo("true");
|
||||
testAction.addFieldError("foo", "Some Foo Error");
|
||||
testAction.addFieldError("foo", "Another Foo Error");
|
||||
|
||||
CheckboxTag tag = new CheckboxTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setLabel("mylabel");
|
||||
tag.setName("foo");
|
||||
tag.setFieldValue("baz");
|
||||
tag.setOndblclick("test();");
|
||||
tag.setOnclick("test();");
|
||||
tag.setTitle("mytitle");
|
||||
tag.setCssErrorStyle("color:red");
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(CheckboxTag.class.getResource("Checkbox-33.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
CheckboxTag freshTag = new CheckboxTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testUnchecked() throws Exception {
|
||||
@@ -175,8 +362,42 @@ public class CheckboxTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(CheckboxTag.class.getResource("Checkbox-2.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
CheckboxTag freshTag = new CheckboxTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
|
||||
public void testUnchecked_clearTagStateSet() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
testAction.setFoo("false");
|
||||
|
||||
CheckboxTag tag = new CheckboxTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setLabel("mylabel");
|
||||
tag.setName("foo");
|
||||
tag.setFieldValue("baz");
|
||||
tag.setTitle("mytitle");
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(CheckboxTag.class.getResource("Checkbox-2.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
CheckboxTag freshTag = new CheckboxTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testDisabled() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
testAction.setFoo("true");
|
||||
@@ -193,6 +414,41 @@ public class CheckboxTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(CheckboxTag.class.getResource("Checkbox-6.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
CheckboxTag freshTag = new CheckboxTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testDisabled_clearTagStateSet() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
testAction.setFoo("true");
|
||||
|
||||
CheckboxTag tag = new CheckboxTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setLabel("mylabel");
|
||||
tag.setName("foo");
|
||||
tag.setFieldValue("baz");
|
||||
tag.setTitle("mytitle");
|
||||
tag.setDisabled("true");
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(CheckboxTag.class.getResource("Checkbox-6.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
CheckboxTag freshTag = new CheckboxTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testSubmitUncheckedAsFalse() throws Exception {
|
||||
|
||||
@@ -79,6 +79,48 @@ public class ComboBoxTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(ComboBoxTag.class.getResource("ComboBox-1.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ComboBoxTag freshTag = new ComboBoxTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testSimple_clearTagStateSet() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
testAction.setFoo("hello");
|
||||
|
||||
ArrayList collection = new ArrayList();
|
||||
collection.add("foo");
|
||||
collection.add("bar");
|
||||
collection.add("baz");
|
||||
testAction.setCollection(collection);
|
||||
|
||||
ComboBoxTag tag = new ComboBoxTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setLabel("mylabel");
|
||||
tag.setName("foo");
|
||||
tag.setId("cb");
|
||||
tag.setList("collection");
|
||||
|
||||
stack.getActionContext().getSession().put("nonce", "r4nd0m");
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(ComboBoxTag.class.getResource("ComboBox-1.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ComboBoxTag freshTag = new ComboBoxTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testWithEmptyOptionAndHeader() throws Exception {
|
||||
@@ -106,6 +148,50 @@ public class ComboBoxTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(ComboBoxTag.class.getResource("ComboBox-2.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ComboBoxTag freshTag = new ComboBoxTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testWithEmptyOptionAndHeader_clearTagStateSet() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
testAction.setFoo("banana");
|
||||
|
||||
List l = new ArrayList();
|
||||
l.add("apple");
|
||||
l.add("banana");
|
||||
l.add("pineaple");
|
||||
l.add("grapes");
|
||||
testAction.setCollection(l);
|
||||
|
||||
ComboBoxTag tag = new ComboBoxTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setLabel("My Favourite Fruit");
|
||||
tag.setName("myFavouriteFruit");
|
||||
tag.setEmptyOption("true");
|
||||
tag.setHeaderKey("-1");
|
||||
tag.setHeaderValue("--- Please Select ---");
|
||||
tag.setList("collection");
|
||||
tag.setValue("%{foo}");
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(ComboBoxTag.class.getResource("ComboBox-2.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ComboBoxTag freshTag = new ComboBoxTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testWithMap() throws Exception {
|
||||
@@ -133,6 +219,50 @@ public class ComboBoxTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(ComboBoxTag.class.getResource("ComboBox-3.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ComboBoxTag freshTag = new ComboBoxTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testWithMap_clearTagStateSet() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
testAction.setFoo("banana");
|
||||
|
||||
Map m = new LinkedHashMap();
|
||||
m.put("apple", "apple");
|
||||
m.put("banana", "banana");
|
||||
m.put("pineaple", "pineaple");
|
||||
m.put("grapes", "grapes");
|
||||
testAction.setMap(m);
|
||||
|
||||
ComboBoxTag tag = new ComboBoxTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setLabel("My Favourite Fruit");
|
||||
tag.setName("myFavouriteFruit");
|
||||
tag.setHeaderKey("-1");
|
||||
tag.setHeaderValue("--- Please Select ---");
|
||||
tag.setEmptyOption("true");
|
||||
tag.setList("map");
|
||||
tag.setValue("%{foo}");
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(ComboBoxTag.class.getResource("ComboBox-3.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ComboBoxTag freshTag = new ComboBoxTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testJsCallNamingUsesEscapedId() throws Exception {
|
||||
@@ -154,6 +284,44 @@ public class ComboBoxTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(ComboBoxTag.class.getResource("ComboBox-4.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ComboBoxTag freshTag = new ComboBoxTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testJsCallNamingUsesEscapedId_clearTagStateSet() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
testAction.setFoo("hello");
|
||||
|
||||
ArrayList collection = new ArrayList();
|
||||
collection.add("foo");
|
||||
testAction.setCollection(collection);
|
||||
|
||||
ComboBoxTag tag = new ComboBoxTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setLabel("mylabel");
|
||||
tag.setName("foo");
|
||||
tag.setId("cb['\".\"'] = bc(){};//");
|
||||
tag.setList("collection");
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(ComboBoxTag.class.getResource("ComboBox-4.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ComboBoxTag freshTag = new ComboBoxTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package org.apache.struts2.views.jsp.ui;
|
||||
|
||||
import org.apache.struts2.TestAction;
|
||||
import org.apache.struts2.components.Component;
|
||||
import org.apache.struts2.views.jsp.AbstractUITagTest;
|
||||
|
||||
|
||||
@@ -46,6 +45,44 @@ public class ComponentTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(ComponentTag.class.getResource("Component-2.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
TextFieldTag freshTag = new TextFieldTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that id attribute is evaludated against the Ognl Stack.
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testIdIsEvaluatedAgainstStack1_clearTagStateSet() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
testAction.setFoo("myFooValue");
|
||||
|
||||
TextFieldTag tag = new TextFieldTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setLabel("mylabel");
|
||||
tag.setName("myname");
|
||||
tag.setValue("foo");
|
||||
tag.setId("%{foo}");
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(ComponentTag.class.getResource("Component-2.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
TextFieldTag freshTag = new TextFieldTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testIdIsEvaludatedAgainstStack2() throws Exception {
|
||||
@@ -63,8 +100,41 @@ public class ComponentTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(ComponentTag.class.getResource("Component-3.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
TextFieldTag freshTag = new TextFieldTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testIdIsEvaludatedAgainstStack2_clearTagStateSet() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
testAction.setFoo("myFooValue");
|
||||
|
||||
TextFieldTag tag = new TextFieldTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setLabel("mylabel");
|
||||
tag.setName("myname");
|
||||
tag.setValue("foo");
|
||||
tag.setId("foo");
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(ComponentTag.class.getResource("Component-3.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
TextFieldTag freshTag = new TextFieldTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
/**
|
||||
* Note -- this test uses empty.vm, so it's basically clear
|
||||
@@ -83,6 +153,42 @@ public class ComponentTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(ComponentTag.class.getResource("Component-1.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ComponentTag freshTag = new ComponentTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
/**
|
||||
* Note -- this test uses empty.vm, so it's basically clear
|
||||
*/
|
||||
public void testSimple_clearTagStateSet() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
testAction.setFoo("bar");
|
||||
|
||||
ComponentTag tag = new ComponentTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setLabel("mylabel");
|
||||
tag.setName("myname");
|
||||
tag.setValue("foo");
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(ComponentTag.class.getResource("Component-1.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ComponentTag freshTag = new ComponentTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,6 +217,51 @@ public class ComponentTest extends AbstractUITagTest {
|
||||
|
||||
// System.out.println(writer);
|
||||
verify(ComponentTag.class.getResource("Component-param.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ComponentTag freshTag = new ComponentTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
/**
|
||||
* executes a component test passing in a custom parameter. it also executes calling a custom template using an
|
||||
* absolute reference.
|
||||
*/
|
||||
public void testWithParam_clearTagStateSet() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
testAction.setFoo("bar");
|
||||
|
||||
ComponentTag tag = new ComponentTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setLabel("mylabel");
|
||||
tag.setName("myname");
|
||||
tag.setValue("foo");
|
||||
tag.setTheme("test");
|
||||
tag.setTemplate("Component");
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.getComponent().addParameter("hello", "world");
|
||||
tag.getComponent().addParameter("argle", "bargle");
|
||||
tag.getComponent().addParameter("glip", "glop");
|
||||
tag.getComponent().addParameter("array", new String[]{"a", "b", "c"});
|
||||
tag.getComponent().addParameter("objClass", tag.getClass().getName());
|
||||
tag.doEndTag();
|
||||
|
||||
// System.out.println(writer);
|
||||
verify(ComponentTag.class.getResource("Component-param.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ComponentTag freshTag = new ComponentTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testTagAttributeExclusion() throws Exception {
|
||||
@@ -122,6 +273,9 @@ public class ComponentTest extends AbstractUITagTest {
|
||||
tag.doStartTag();
|
||||
|
||||
assertTrue(tag.includeContext);
|
||||
|
||||
// Calling tag.doEndTag() results in an exception.
|
||||
// Aa a result, a basic sanity check of clearTagStateForTagPoolingServers() cannot be called.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,6 +33,8 @@ import java.time.format.DateTimeFormatter;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
import org.apache.struts2.components.Component;
|
||||
import org.apache.struts2.components.DateTextField;
|
||||
|
||||
/**
|
||||
* Unit test for {@link org.apache.struts2.components.Date}.
|
||||
@@ -54,6 +56,37 @@ public class DateTagTest extends AbstractTagTest {
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
assertEquals(formatted, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DateTag freshTag = new DateTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testCustomFormat_clearTagStateSet() throws Exception {
|
||||
String format = "yyyy/MM/dd hh:mm:ss";
|
||||
Date now = new Date();
|
||||
String formatted = new SimpleDateFormat(format).format(now);
|
||||
context.put("myDate", now);
|
||||
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setName("myDate");
|
||||
tag.setNice(false);
|
||||
tag.setFormat(format);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
assertEquals(formatted, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DateTag freshTag = new DateTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testCustomGlobalFormatFormat() throws Exception {
|
||||
@@ -84,8 +117,43 @@ public class DateTagTest extends AbstractTagTest {
|
||||
tag.setFormat(format);
|
||||
tag.setTimezone("GMT+1");
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
assertEquals(formatted, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DateTag freshTag = new DateTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testCustomFormatWithTimezone_clearTagStateSet() throws Exception {
|
||||
String format = "yyyy/MM/dd hh:mm:ss";
|
||||
Date now = Calendar.getInstance(TimeZone.getTimeZone("GMT+1")).getTime();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(format);
|
||||
sdf.setTimeZone(TimeZone.getTimeZone("GMT+1"));
|
||||
String formatted = sdf.format(now);
|
||||
context.put("myDate", now);
|
||||
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setName("myDate");
|
||||
tag.setNice(false);
|
||||
tag.setFormat(format);
|
||||
tag.setTimezone("GMT+1");
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
assertEquals(formatted, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DateTag freshTag = new DateTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testCustomFormatWithTimezoneAsExpression() throws Exception {
|
||||
@@ -104,6 +172,41 @@ public class DateTagTest extends AbstractTagTest {
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
assertEquals(formatted, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DateTag freshTag = new DateTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testCustomFormatWithTimezoneAsExpression_clearTagStateSet() throws Exception {
|
||||
String format = "yyyy/MM/dd hh:mm:ss";
|
||||
Date now = Calendar.getInstance(TimeZone.getTimeZone("GMT+2")).getTime();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(format);
|
||||
sdf.setTimeZone(TimeZone.getTimeZone("GMT+2"));
|
||||
String formatted = sdf.format(now);
|
||||
context.put("myDate", now);
|
||||
context.put("myTimezone", "GMT+2");
|
||||
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setName("myDate");
|
||||
tag.setNice(false);
|
||||
tag.setFormat(format);
|
||||
tag.setTimezone("myTimezone");
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
assertEquals(formatted, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DateTag freshTag = new DateTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testCustomFormatCalendar() throws Exception {
|
||||
@@ -118,6 +221,37 @@ public class DateTagTest extends AbstractTagTest {
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
assertEquals(formatted, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DateTag freshTag = new DateTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testCustomFormatCalendar_clearTagStateSet() throws Exception {
|
||||
String format = "yyyy/MM/dd hh:mm:ss";
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
String formatted = new SimpleDateFormat(format).format(calendar.getTime());
|
||||
context.put("myDate", calendar);
|
||||
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setName("myDate");
|
||||
tag.setNice(false);
|
||||
tag.setFormat(format);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
assertEquals(formatted, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DateTag freshTag = new DateTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testCustomFormatLong() throws Exception {
|
||||
@@ -133,6 +267,38 @@ public class DateTagTest extends AbstractTagTest {
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
assertEquals(formatted, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DateTag freshTag = new DateTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testCustomFormatLong_clearTagStateSet() throws Exception {
|
||||
String format = "yyyy/MM/dd hh:mm:ss";
|
||||
Date date = new Date();
|
||||
String formatted = new SimpleDateFormat(format).format(date);
|
||||
// long
|
||||
context.put("myDate", date.getTime());
|
||||
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setName("myDate");
|
||||
tag.setNice(false);
|
||||
tag.setFormat(format);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
assertEquals(formatted, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DateTag freshTag = new DateTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testCustomFormatLocalDateTime() throws Exception {
|
||||
@@ -174,6 +340,36 @@ public class DateTagTest extends AbstractTagTest {
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
assertEquals(formatted, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DateTag freshTag = new DateTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testDefaultFormat_clearTagStateSet() throws Exception {
|
||||
Date now = new Date();
|
||||
String formatted = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM,
|
||||
ActionContext.getContext().getLocale()).format(now);
|
||||
|
||||
context.put("myDate", now);
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setName("myDate");
|
||||
tag.setNice(false);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
assertEquals(formatted, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DateTag freshTag = new DateTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testCustomFormatAndComponent() throws Exception {
|
||||
@@ -197,6 +393,46 @@ public class DateTagTest extends AbstractTagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals(formatted, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DateTag freshTag = new DateTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testCustomFormatAndComponent_clearTagStateSet() throws Exception {
|
||||
String format = "yyyy/MM/dd hh:mm:ss";
|
||||
Date now = new Date();
|
||||
String formatted = new SimpleDateFormat(format).format(now);
|
||||
context.put("myDate", now);
|
||||
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setName("myDate");
|
||||
tag.setFormat(format);
|
||||
tag.setNice(false);
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
|
||||
// component test must be done between start and end tag
|
||||
org.apache.struts2.components.Date component = (org.apache.struts2.components.Date) tag.getComponent();
|
||||
assertEquals("myDate", component.getName());
|
||||
assertEquals(format, component.getFormat());
|
||||
assertEquals(false, component.isNice());
|
||||
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals(formatted, writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DateTag freshTag = new DateTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testSetId() throws Exception {
|
||||
@@ -212,6 +448,38 @@ public class DateTagTest extends AbstractTagTest {
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
assertEquals(formatted, context.get("myId"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DateTag freshTag = new DateTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testSetId_clearTagStateSet() throws Exception {
|
||||
String format = "yyyy/MM/dd hh:mm:ss";
|
||||
Date now = new Date();
|
||||
String formatted = new SimpleDateFormat(format).format(now);
|
||||
context.put("myDate", now);
|
||||
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setName("myDate");
|
||||
tag.setNice(false);
|
||||
tag.setFormat(format);
|
||||
tag.setVar("myId");
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
assertEquals(formatted, context.get("myId"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DateTag freshTag = new DateTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testFutureNiceHour() throws Exception {
|
||||
@@ -227,6 +495,38 @@ public class DateTagTest extends AbstractTagTest {
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
assertEquals("in one hour", writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DateTag freshTag = new DateTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testFutureNiceHour_clearTagStateSet() throws Exception {
|
||||
Date now = new Date();
|
||||
Calendar future = Calendar.getInstance();
|
||||
future.setTime(now);
|
||||
future.add(Calendar.HOUR, 1);
|
||||
future.add(Calendar.SECOND, 5); // always add a little slack otherwise we could calculate wrong
|
||||
|
||||
context.put("myDate", future.getTime());
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setName("myDate");
|
||||
tag.setNice(true);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
assertEquals("in one hour", writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DateTag freshTag = new DateTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testPastNiceHour() throws Exception {
|
||||
@@ -242,6 +542,38 @@ public class DateTagTest extends AbstractTagTest {
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
assertEquals("one hour ago", writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DateTag freshTag = new DateTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testPastNiceHour_clearTagStateSet() throws Exception {
|
||||
Date now = new Date();
|
||||
Calendar future = Calendar.getInstance();
|
||||
future.setTime(now);
|
||||
future.add(Calendar.HOUR, -1);
|
||||
future.add(Calendar.SECOND, -5); // always add a little slack otherwise we could calculate wrong
|
||||
|
||||
context.put("myDate", future.getTime());
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setName("myDate");
|
||||
tag.setNice(true);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
assertEquals("one hour ago", writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DateTag freshTag = new DateTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testFutureNiceHourMinSec() throws Exception {
|
||||
@@ -258,6 +590,39 @@ public class DateTagTest extends AbstractTagTest {
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
assertEquals("in 2 hours, 33 minutes", writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DateTag freshTag = new DateTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testFutureNiceHourMinSec_clearTagStateSet() throws Exception {
|
||||
Date now = new Date();
|
||||
Calendar future = Calendar.getInstance();
|
||||
future.setTime(now);
|
||||
future.add(Calendar.HOUR, 2);
|
||||
future.add(Calendar.MINUTE, 33);
|
||||
future.add(Calendar.SECOND, 5); // always add a little slack otherwise we could calculate wrong
|
||||
|
||||
context.put("myDate", future.getTime());
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setName("myDate");
|
||||
tag.setNice(true);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
assertEquals("in 2 hours, 33 minutes", writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DateTag freshTag = new DateTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testPastNiceHourMin() throws Exception {
|
||||
@@ -274,6 +639,39 @@ public class DateTagTest extends AbstractTagTest {
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
assertEquals("4 hours, 55 minutes ago", writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DateTag freshTag = new DateTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testPastNiceHourMin_clearTagStateSet() throws Exception {
|
||||
Date now = new Date();
|
||||
Calendar past = Calendar.getInstance();
|
||||
past.setTime(now);
|
||||
past.add(Calendar.HOUR, -4);
|
||||
past.add(Calendar.MINUTE, -55);
|
||||
past.add(Calendar.SECOND, -5); // always add a little slack otherwise we could calculate wrong
|
||||
|
||||
context.put("myDate", past.getTime());
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setName("myDate");
|
||||
tag.setNice(true);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
assertEquals("4 hours, 55 minutes ago", writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DateTag freshTag = new DateTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testFutureLessOneMin() throws Exception {
|
||||
@@ -289,6 +687,38 @@ public class DateTagTest extends AbstractTagTest {
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
assertEquals("in an instant", writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DateTag freshTag = new DateTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testFutureLessOneMin_clearTagStateSet() throws Exception {
|
||||
Date now = new Date();
|
||||
Calendar future = Calendar.getInstance();
|
||||
future.setTime(now);
|
||||
future.add(Calendar.SECOND, 47);
|
||||
future.add(Calendar.SECOND, 5); // always add a little slack otherwise we could calculate wrong
|
||||
|
||||
context.put("myDate", future.getTime());
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setName("myDate");
|
||||
tag.setNice(true);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
assertEquals("in an instant", writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DateTag freshTag = new DateTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testFutureLessOneHour() throws Exception {
|
||||
@@ -304,6 +734,38 @@ public class DateTagTest extends AbstractTagTest {
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
assertEquals("in 36 minutes", writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DateTag freshTag = new DateTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testFutureLessOneHour_clearTagStateSet() throws Exception {
|
||||
Date now = new Date();
|
||||
Calendar future = Calendar.getInstance();
|
||||
future.setTime(now);
|
||||
future.add(Calendar.MINUTE, 36);
|
||||
future.add(Calendar.SECOND, 5); // always add a little slack otherwise we could calculate wrong
|
||||
|
||||
context.put("myDate", future.getTime());
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setName("myDate");
|
||||
tag.setNice(true);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
assertEquals("in 36 minutes", writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DateTag freshTag = new DateTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testFutureLessOneYear() throws Exception {
|
||||
@@ -319,6 +781,38 @@ public class DateTagTest extends AbstractTagTest {
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
assertEquals("in 40 days", writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DateTag freshTag = new DateTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testFutureLessOneYear_clearTagStateSet() throws Exception {
|
||||
Date now = new Date();
|
||||
Calendar future = Calendar.getInstance();
|
||||
future.setTime(now);
|
||||
future.add(Calendar.HOUR, 40 * 24);
|
||||
future.add(Calendar.SECOND, 5); // always add a little slack otherwise we could calculate wrong
|
||||
|
||||
context.put("myDate", future.getTime());
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setName("myDate");
|
||||
tag.setNice(true);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
assertEquals("in 40 days", writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DateTag freshTag = new DateTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testFutureTwoYears() throws Exception {
|
||||
@@ -338,6 +832,42 @@ public class DateTagTest extends AbstractTagTest {
|
||||
// hmmm the Date component isn't the best to calculate the excat difference so we'll just check
|
||||
// that it starts with in 2 years
|
||||
assertTrue(writer.toString().startsWith("in 2 years"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DateTag freshTag = new DateTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testFutureTwoYears_clearTagStateSet() throws Exception {
|
||||
Date now = new Date();
|
||||
Calendar future = Calendar.getInstance();
|
||||
future.setTime(now);
|
||||
future.add(Calendar.YEAR, 2);
|
||||
future.add(Calendar.DATE, 1);
|
||||
future.add(Calendar.SECOND, 5); // always add a little slack otherwise we could calculate wrong
|
||||
|
||||
context.put("myDate", future.getTime());
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setName("myDate");
|
||||
tag.setNice(true);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
// hmmm the Date component isn't the best to calculate the excat difference so we'll just check
|
||||
// that it starts with in 2 years
|
||||
assertTrue(writer.toString().startsWith("in 2 years"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DateTag freshTag = new DateTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testNoDateObjectInContext() throws Exception {
|
||||
@@ -348,14 +878,96 @@ public class DateTagTest extends AbstractTagTest {
|
||||
tag.doEndTag();
|
||||
//should return a blank
|
||||
assertEquals("", writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DateTag freshTag = new DateTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testNoDateObjectInContext_clearTagStateSet() throws Exception {
|
||||
context.put("myDate", "this is not a java.util.Date object");
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setName("myDate");
|
||||
tag.setNice(true);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
//should return a blank
|
||||
assertEquals("", writer.toString());
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DateTag freshTag = new DateTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
/**
|
||||
* Artificial code coverage test for {@link DateTextFieldTag} within the DateTagTest
|
||||
* since that tag does not have its own unit tests, and it also appears to be
|
||||
* a broken tag. The code coverage tests can be moved if the tag is fixed, or
|
||||
* removed if the tag is dropped.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testDateTextFieldTag_artificialCoverageTest() throws Exception {
|
||||
final String format = "yyyy/MM/dd hh:mm:ss";
|
||||
DateTextFieldTag dateTextFieldTag = createDateTextFieldTag();
|
||||
dateTextFieldTag.setFormat(format);
|
||||
dateTextFieldTag.doStartTag();
|
||||
// Cannot call doEndTag(), as the missing datetextfield.ftl causes an exception.
|
||||
dateTextFieldTag.populateParams();
|
||||
|
||||
Component bean = dateTextFieldTag.getBean(stack, request, response);
|
||||
assertNotNull("DateTextField component instance is null ?", bean);
|
||||
assertTrue("DateTextField component not a DateTextField ?", bean instanceof DateTextField);
|
||||
|
||||
dateTextFieldTag.setPerformClearTagStateForTagPoolingServers(false);
|
||||
dateTextFieldTag.clearTagStateForTagPoolingServers();
|
||||
dateTextFieldTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
dateTextFieldTag.clearTagStateForTagPoolingServers();
|
||||
dateTextFieldTag.release();
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after forced clearing of tag state.
|
||||
DateTextFieldTag freshTag = new DateTextFieldTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(dateTextFieldTag, freshTag));
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method to create a new {@link DateTextFieldTag} instance for code coverage tests.
|
||||
*
|
||||
* Note: There is no datetextfield.ftl template for the tag, so it does not appear that it can
|
||||
* actually be used in practice. We can perform basic coverage tests from within this
|
||||
* unit test class until the {@link DateTextFieldTag} is fixed or removed.
|
||||
*
|
||||
* @return a basic {@link DateTextFieldTag} instance
|
||||
* @throws Exception
|
||||
*/
|
||||
private DateTextFieldTag createDateTextFieldTag() throws Exception {
|
||||
DateTextFieldTag tag = new DateTextFieldTag();
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setName("myDate");
|
||||
tag.setId("myDate");
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
tag = new DateTag();
|
||||
tag.setPageContext(pageContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
tag = null;
|
||||
|
||||
@@ -57,6 +57,37 @@ public class DebugTagTest extends AbstractUITagTest {
|
||||
assertTrue("Nonce value not included", result.contains("nonce=\"r4nd0m\""));
|
||||
assertTrue(StringUtils.isNotEmpty(result));
|
||||
assertTrue("Property 'checkStackProperty' should be in Debug Tag output", StringUtils.contains(result, "<td>checkStackProperty</td>"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DebugTag freshTag = new DebugTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
// DebugTag has no additional state, so it compares as equal with the default tag clear state as well.
|
||||
assertTrue("Tag state after doEndTag() under default tag clear state is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testDevModeEnabled_clearTagStateSet() throws Exception {
|
||||
setDevMode(true);
|
||||
stack.getActionContext().getSession().put("nonce", "r4nd0m");
|
||||
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
String result = writer.toString();
|
||||
|
||||
assertTrue("Nonce value not included", result.contains("nonce=\"r4nd0m\""));
|
||||
assertTrue(StringUtils.isNotEmpty(result));
|
||||
assertTrue("Property 'checkStackProperty' should be in Debug Tag output", StringUtils.contains(result, "<td>checkStackProperty</td>"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DebugTag freshTag = new DebugTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testDevModeDisabled() throws Exception {
|
||||
@@ -65,6 +96,32 @@ public class DebugTagTest extends AbstractUITagTest {
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
assertTrue("nothing to see here, devMode=false", StringUtils.isEmpty(writer.toString()));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DebugTag freshTag = new DebugTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
// DebugTag has no additional state, so it compares as equal with the default tag clear state as well.
|
||||
assertTrue("Tag state after doEndTag() under default tag clear state is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testDevModeDisabled_clearTagStateSet() throws Exception {
|
||||
setDevMode(false);
|
||||
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
assertTrue("nothing to see here, devMode=false", StringUtils.isEmpty(writer.toString()));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DebugTag freshTag = new DebugTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testTagAttributeOverrideDevModeTrue() throws Exception {
|
||||
@@ -76,6 +133,39 @@ public class DebugTagTest extends AbstractUITagTest {
|
||||
String result = writer.toString();
|
||||
assertTrue(StringUtils.isNotEmpty(result));
|
||||
assertTrue("Property 'checkStackProperty' should be in Debug Tag output", StringUtils.contains(result, "<td>checkStackProperty</td>"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DebugTag freshTag = new DebugTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
// DebugTag has no additional state, so it compares as equal with the default tag clear state as well.
|
||||
assertTrue("Tag state after doEndTag() under default tag clear state is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
|
||||
PrepareOperations.clearDevModeOverride(); // Clear DevMode override. Avoid ThreadLocal side-effects if test thread re-used.
|
||||
}
|
||||
|
||||
public void testTagAttributeOverrideDevModeTrue_clearTagStateSet() throws Exception {
|
||||
setDevMode(false);
|
||||
|
||||
PrepareOperations.overrideDevMode(true);
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
String result = writer.toString();
|
||||
assertTrue(StringUtils.isNotEmpty(result));
|
||||
assertTrue("Property 'checkStackProperty' should be in Debug Tag output", StringUtils.contains(result, "<td>checkStackProperty</td>"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DebugTag freshTag = new DebugTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
|
||||
PrepareOperations.clearDevModeOverride(); // Clear DevMode override. Avoid ThreadLocal side-effects if test thread re-used.
|
||||
}
|
||||
|
||||
public void testTagAttributeOverrideDevModeFalse() throws Exception {
|
||||
@@ -85,6 +175,37 @@ public class DebugTagTest extends AbstractUITagTest {
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
assertTrue("nothing to see here, devMode=false and overrideDevMode=false", StringUtils.isEmpty(writer.toString()));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DebugTag freshTag = new DebugTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
// DebugTag has no additional state, so it compares as equal with the default tag clear state as well.
|
||||
assertTrue("Tag state after doEndTag() under default tag clear state is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
|
||||
PrepareOperations.clearDevModeOverride(); // Clear DevMode override. Avoid ThreadLocal side-effects if test thread re-used.
|
||||
}
|
||||
|
||||
public void testTagAttributeOverrideDevModeFalse_clearTagStateSet() throws Exception {
|
||||
setDevMode(false);
|
||||
|
||||
PrepareOperations.overrideDevMode(false);
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
assertTrue("nothing to see here, devMode=false and overrideDevMode=false", StringUtils.isEmpty(writer.toString()));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DebugTag freshTag = new DebugTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
|
||||
PrepareOperations.clearDevModeOverride(); // Clear DevMode override. Avoid ThreadLocal side-effects if test thread re-used.
|
||||
}
|
||||
|
||||
private void setDevMode(final boolean devMode) {
|
||||
|
||||
@@ -94,6 +94,88 @@ public class DoubleSelectTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(SelectTag.class.getResource("DoubleSelect-1.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DoubleSelectTag freshTag = new DoubleSelectTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testDouble_clearTagStateSet() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
|
||||
Region antwerp = new Region("Antwerp", "AN");
|
||||
Region gent = new Region("Gent", "GN");
|
||||
Region brugge = new Region("Brugge", "BRG");
|
||||
ArrayList belgiumRegions = new ArrayList();
|
||||
belgiumRegions.add(antwerp);
|
||||
belgiumRegions.add(gent);
|
||||
belgiumRegions.add(brugge);
|
||||
Country belgium = new Country("Belgium", "BE", belgiumRegions);
|
||||
|
||||
Region paris = new Region("Paris", "PA");
|
||||
Region bordeaux = new Region("Bordeaux", "BOR");
|
||||
ArrayList franceRegions = new ArrayList();
|
||||
franceRegions.add(paris);
|
||||
franceRegions.add(bordeaux);
|
||||
Country france = new Country("France", "FR", franceRegions);
|
||||
|
||||
Collection collection = new ArrayList(2);
|
||||
collection.add("AN");
|
||||
testAction.setCollection(collection);
|
||||
|
||||
List countries = new ArrayList();
|
||||
countries.add(belgium);
|
||||
countries.add(france);
|
||||
|
||||
testAction.setList2(countries);
|
||||
|
||||
DoubleSelectTag tag = new DoubleSelectTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setLabel("mylabel");
|
||||
tag.setName("foo");
|
||||
tag.setDoubleName("region");
|
||||
|
||||
tag.setList("list2");
|
||||
tag.setDoubleList("regions");
|
||||
|
||||
tag.setListKey("iso");
|
||||
tag.setDoubleListKey("key");
|
||||
tag.setListValue("name");
|
||||
tag.setDoubleListValue("name");
|
||||
|
||||
tag.setFormName("inputForm");
|
||||
|
||||
tag.setOnmousedown("window.status='onmousedown';");
|
||||
tag.setOnmousemove("window.status='onmousemove';");
|
||||
tag.setOnmouseout("window.status='onmouseout';");
|
||||
tag.setOnmouseover("window.status='onmouseover';");
|
||||
tag.setOnmouseup("window.status='onmouseup';");
|
||||
|
||||
//css style and class
|
||||
tag.setCssClass("c1");
|
||||
tag.setCssStyle("s1");
|
||||
tag.setDoubleCssClass("c2");
|
||||
tag.setDoubleCssStyle("s2");
|
||||
|
||||
stack.getActionContext().getSession().put("nonce", "r4nd0m");
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(SelectTag.class.getResource("DoubleSelect-1.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DoubleSelectTag freshTag = new DoubleSelectTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testOnchange() throws Exception {
|
||||
@@ -158,8 +240,88 @@ public class DoubleSelectTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(SelectTag.class.getResource("DoubleSelect-4.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DoubleSelectTag freshTag = new DoubleSelectTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testOnchange_clearTagStateSet() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
|
||||
Region antwerp = new Region("Antwerp", "AN");
|
||||
Region gent = new Region("Gent", "GN");
|
||||
Region brugge = new Region("Brugge", "BRG");
|
||||
ArrayList belgiumRegions = new ArrayList();
|
||||
belgiumRegions.add(antwerp);
|
||||
belgiumRegions.add(gent);
|
||||
belgiumRegions.add(brugge);
|
||||
Country belgium = new Country("Belgium", "BE", belgiumRegions);
|
||||
|
||||
Region paris = new Region("Paris", "PA");
|
||||
Region bordeaux = new Region("Bordeaux", "BOR");
|
||||
ArrayList franceRegions = new ArrayList();
|
||||
franceRegions.add(paris);
|
||||
franceRegions.add(bordeaux);
|
||||
Country france = new Country("France", "FR", franceRegions);
|
||||
|
||||
Collection collection = new ArrayList(2);
|
||||
collection.add("AN");
|
||||
testAction.setCollection(collection);
|
||||
|
||||
List countries = new ArrayList();
|
||||
countries.add(belgium);
|
||||
countries.add(france);
|
||||
|
||||
testAction.setList2(countries);
|
||||
|
||||
DoubleSelectTag tag = new DoubleSelectTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setLabel("mylabel");
|
||||
tag.setName("foo");
|
||||
tag.setDoubleName("region");
|
||||
|
||||
tag.setList("list2");
|
||||
tag.setDoubleList("regions");
|
||||
|
||||
tag.setListKey("iso");
|
||||
tag.setDoubleListKey("key");
|
||||
tag.setListValue("name");
|
||||
tag.setDoubleListValue("name");
|
||||
|
||||
tag.setFormName("inputForm");
|
||||
|
||||
tag.setOnmousedown("window.status='onmousedown';");
|
||||
tag.setOnmousemove("window.status='onmousemove';");
|
||||
tag.setOnmouseout("window.status='onmouseout';");
|
||||
tag.setOnmouseover("window.status='onmouseover';");
|
||||
tag.setOnmouseup("window.status='onmouseup';");
|
||||
tag.setOnchange("window.status='onchange';");
|
||||
|
||||
//css style and class
|
||||
tag.setCssClass("c1");
|
||||
tag.setCssStyle("s1");
|
||||
tag.setDoubleCssClass("c2");
|
||||
tag.setDoubleCssStyle("s2");
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(SelectTag.class.getResource("DoubleSelect-4.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DoubleSelectTag freshTag = new DoubleSelectTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testDoubleWithDefaultSelectedValues() throws Exception {
|
||||
|
||||
@@ -221,7 +383,83 @@ public class DoubleSelectTest extends AbstractUITagTest {
|
||||
|
||||
verify(SelectTag.class.getResource("DoubleSelect-2.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DoubleSelectTag freshTag = new DoubleSelectTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testDoubleWithDefaultSelectedValues_clearTagStateSet() throws Exception {
|
||||
|
||||
TestAction testAction = (TestAction) action;
|
||||
|
||||
Region antwerp = new Region("Antwerp", "AN");
|
||||
Region gent = new Region("Gent", "GN");
|
||||
Region brugge = new Region("Brugge", "BRG");
|
||||
ArrayList belgiumRegions = new ArrayList();
|
||||
belgiumRegions.add(antwerp);
|
||||
belgiumRegions.add(gent);
|
||||
belgiumRegions.add(brugge);
|
||||
Country belgium = new Country("Belgium", "BE", belgiumRegions);
|
||||
|
||||
Region paris = new Region("Paris", "PA");
|
||||
Region bordeaux = new Region("Bordeaux", "BOR");
|
||||
ArrayList franceRegions = new ArrayList();
|
||||
franceRegions.add(paris);
|
||||
franceRegions.add(bordeaux);
|
||||
Country france = new Country("France", "FR", franceRegions);
|
||||
|
||||
Collection collection = new ArrayList(2);
|
||||
collection.add("AN");
|
||||
testAction.setCollection(collection);
|
||||
|
||||
List countries = new ArrayList();
|
||||
countries.add(belgium);
|
||||
countries.add(france);
|
||||
|
||||
testAction.setList2(countries);
|
||||
|
||||
DoubleSelectTag tag = new DoubleSelectTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setLabel("mylabel");
|
||||
tag.setName("foo");
|
||||
tag.setDoubleName("region");
|
||||
|
||||
tag.setValue("'FR'");
|
||||
tag.setDoubleValue("'BOR'");
|
||||
|
||||
tag.setList("list2");
|
||||
tag.setDoubleList("regions");
|
||||
|
||||
tag.setListKey("iso");
|
||||
tag.setDoubleListKey("key");
|
||||
tag.setListValue("name");
|
||||
tag.setDoubleListValue("name");
|
||||
|
||||
tag.setFormName("inputForm");
|
||||
|
||||
tag.setOnmousedown("window.status='onmousedown';");
|
||||
tag.setOnmousemove("window.status='onmousemove';");
|
||||
tag.setOnmouseout("window.status='onmouseout';");
|
||||
tag.setOnmouseover("window.status='onmouseover';");
|
||||
tag.setOnmouseup("window.status='onmouseup';");
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(SelectTag.class.getResource("DoubleSelect-2.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DoubleSelectTag freshTag = new DoubleSelectTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testDoubleWithDotName() throws Exception {
|
||||
@@ -279,6 +517,80 @@ public class DoubleSelectTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(SelectTag.class.getResource("DoubleSelect-3.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DoubleSelectTag freshTag = new DoubleSelectTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testDoubleWithDotName_clearTagStateSet() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
|
||||
Region antwerp = new Region("Antwerp", "AN");
|
||||
Region gent = new Region("Gent", "GN");
|
||||
Region brugge = new Region("Brugge", "BRG");
|
||||
ArrayList belgiumRegions = new ArrayList();
|
||||
belgiumRegions.add(antwerp);
|
||||
belgiumRegions.add(gent);
|
||||
belgiumRegions.add(brugge);
|
||||
Country belgium = new Country("Belgium", "BE", belgiumRegions);
|
||||
|
||||
Region paris = new Region("Paris", "PA");
|
||||
Region bordeaux = new Region("Bordeaux", "BOR");
|
||||
ArrayList franceRegions = new ArrayList();
|
||||
franceRegions.add(paris);
|
||||
franceRegions.add(bordeaux);
|
||||
Country france = new Country("France", "FR", franceRegions);
|
||||
|
||||
Collection collection = new ArrayList(2);
|
||||
collection.add("AN");
|
||||
testAction.setCollection(collection);
|
||||
|
||||
List countries = new ArrayList();
|
||||
countries.add(belgium);
|
||||
countries.add(france);
|
||||
|
||||
testAction.setList2(countries);
|
||||
|
||||
DoubleSelectTag tag = new DoubleSelectTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setLabel("mylabel");
|
||||
tag.setName("foo.bar");
|
||||
tag.setDoubleName("region");
|
||||
|
||||
tag.setList("list2");
|
||||
tag.setDoubleList("regions");
|
||||
|
||||
tag.setListKey("iso");
|
||||
tag.setDoubleListKey("key");
|
||||
tag.setListValue("name");
|
||||
tag.setDoubleListValue("name");
|
||||
|
||||
tag.setFormName("inputForm");
|
||||
|
||||
tag.setOnmousedown("window.status='onmousedown';");
|
||||
tag.setOnmousemove("window.status='onmousemove';");
|
||||
tag.setOnmouseout("window.status='onmouseout';");
|
||||
tag.setOnmouseover("window.status='onmouseover';");
|
||||
tag.setOnmouseup("window.status='onmouseup';");
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(SelectTag.class.getResource("DoubleSelect-3.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
DoubleSelectTag freshTag = new DoubleSelectTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testGenericSimple() throws Exception {
|
||||
|
||||
@@ -46,6 +46,34 @@ public class FieldErrorTagTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(FieldErrorTagTest.class.getResource("fielderror-1.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
FieldErrorTag freshTag = new FieldErrorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
// FieldErrorTag has no non=default state set here, so it compares as equal with the default tag clear state as well.
|
||||
assertTrue("Tag state after doEndTag() under default tag clear state is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testWithoutParamsWithFieldErrors_clearTagStateSet() throws Exception {
|
||||
FieldErrorTag tag = new FieldErrorTag();
|
||||
((InternalAction)action).setHaveFieldErrors(true);
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(FieldErrorTagTest.class.getResource("fielderror-1.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
FieldErrorTag freshTag = new FieldErrorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testWithoutParamsWithoutFieldErrors() throws Exception {
|
||||
@@ -56,6 +84,34 @@ public class FieldErrorTagTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(FieldErrorTagTest.class.getResource("fielderror-2.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
FieldErrorTag freshTag = new FieldErrorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
// FieldErrorTag has no non=default state set here, so it compares as equal with the default tag clear state as well.
|
||||
assertTrue("Tag state after doEndTag() under default tag clear state is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testWithoutParamsWithoutFieldErrors_clearTagStateSet() throws Exception {
|
||||
FieldErrorTag tag = new FieldErrorTag();
|
||||
((InternalAction)action).setHaveFieldErrors(false);
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(FieldErrorTagTest.class.getResource("fielderror-2.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
FieldErrorTag freshTag = new FieldErrorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testFieldErrorsEscape() throws Exception {
|
||||
@@ -72,6 +128,40 @@ public class FieldErrorTagTest extends AbstractUITagTest {
|
||||
|
||||
assertEquals(normalize("<ul class=\"errorMessage\"><li><span><p>hey</p></span></li></ul>", true),
|
||||
normalize(writer.toString(), true));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
FieldErrorTag freshTag = new FieldErrorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
// FieldErrorTag has no non=default state set here and escape is true by default, so it compares as equal with the default tag clear state as well.
|
||||
assertTrue("Tag state after doEndTag() under default tag clear state is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testFieldErrorsEscape_clearTagStateSet() throws Exception {
|
||||
|
||||
FieldErrorTag tag = new FieldErrorTag();
|
||||
TestAction testAction = new TestAction();
|
||||
testAction.addFieldError("f", "<p>hey</p>");
|
||||
stack.pop();
|
||||
stack.push(testAction);
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setEscape(true);
|
||||
tag.setPageContext(pageContext);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals(normalize("<ul class=\"errorMessage\"><li><span><p>hey</p></span></li></ul>", true),
|
||||
normalize(writer.toString(), true));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
FieldErrorTag freshTag = new FieldErrorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testFieldErrorsDontEscape() throws Exception {
|
||||
@@ -88,6 +178,39 @@ public class FieldErrorTagTest extends AbstractUITagTest {
|
||||
|
||||
assertEquals(normalize("<ul class=\"errorMessage\"><li><span><p>hey</p></span></li></ul>", true),
|
||||
normalize(writer.toString(), true));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
FieldErrorTag freshTag = new FieldErrorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testFieldErrorsDontEscape_clearTagStateSet() throws Exception {
|
||||
|
||||
FieldErrorTag tag = new FieldErrorTag();
|
||||
TestAction testAction = new TestAction();
|
||||
testAction.addFieldError("f", "<p>hey</p>");
|
||||
stack.pop();
|
||||
stack.push(testAction);
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setEscape(false);
|
||||
tag.setPageContext(pageContext);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals(normalize("<ul class=\"errorMessage\"><li><span><p>hey</p></span></li></ul>", true),
|
||||
normalize(writer.toString(), true));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
FieldErrorTag freshTag = new FieldErrorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testWithParamsWithFieldErrors1() throws Exception {
|
||||
@@ -111,6 +234,71 @@ public class FieldErrorTagTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(FieldErrorTagTest.class.getResource("fielderror-3.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ParamTag freshParamTag = new ParamTag();
|
||||
freshParamTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(pTag1, freshParamTag));
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(pTag2, freshParamTag));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
FieldErrorTag freshTag = new FieldErrorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testWithParamsWithFieldErrors1_clearTagStateSet() throws Exception {
|
||||
FieldErrorTag tag = new FieldErrorTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setId("someid");
|
||||
((InternalAction)action).setHaveFieldErrors(true);
|
||||
tag.setPageContext(pageContext);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
ParamTag pTag1 = new ParamTag();
|
||||
pTag1.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
pTag1.setPageContext(pageContext);
|
||||
pTag1.setValue("%{'field1'}");
|
||||
pTag1.doStartTag();
|
||||
setComponentTagClearTagState(pTag1, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
pTag1.doEndTag();
|
||||
|
||||
ParamTag pTag2 = new ParamTag();
|
||||
pTag2.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
pTag2.setPageContext(pageContext);
|
||||
pTag2.setValue("%{'field3'}");
|
||||
pTag2.doStartTag();
|
||||
setComponentTagClearTagState(pTag2, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
pTag2.doEndTag();
|
||||
|
||||
tag.doEndTag();
|
||||
|
||||
verify(FieldErrorTagTest.class.getResource("fielderror-3.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ParamTag freshParamTag = new ParamTag();
|
||||
freshParamTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshParamTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(pTag1, freshParamTag));
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(pTag2, freshParamTag));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
FieldErrorTag freshTag = new FieldErrorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testWithFieldName() throws Exception {
|
||||
@@ -122,6 +310,34 @@ public class FieldErrorTagTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(FieldErrorTagTest.class.getResource("fielderror-6.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
FieldErrorTag freshTag = new FieldErrorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testWithFieldName_clearTagStateSet() throws Exception {
|
||||
FieldErrorTag tag = new FieldErrorTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setFieldName("field1");
|
||||
((InternalAction)action).setHaveFieldErrors(true);
|
||||
tag.setPageContext(pageContext);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(FieldErrorTagTest.class.getResource("fielderror-6.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
FieldErrorTag freshTag = new FieldErrorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testWithParamsWithFieldErrors2() throws Exception {
|
||||
@@ -144,8 +360,72 @@ public class FieldErrorTagTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(FieldErrorTagTest.class.getResource("fielderror-4.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ParamTag freshParamTag = new ParamTag();
|
||||
freshParamTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(pTag1, freshParamTag));
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(pTag2, freshParamTag));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
FieldErrorTag freshTag = new FieldErrorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
// FieldErrorTag has no non=default state set here, so it compares as equal with the default tag clear state as well.
|
||||
assertTrue("Tag state after doEndTag() under default tag clear state is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testWithParamsWithFieldErrors2_clearTagStateSet() throws Exception {
|
||||
FieldErrorTag tag = new FieldErrorTag();
|
||||
((InternalAction)action).setHaveFieldErrors(true);
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
ParamTag pTag1 = new ParamTag();
|
||||
pTag1.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
pTag1.setPageContext(pageContext);
|
||||
pTag1.setValue("%{'field1'}");
|
||||
pTag1.doStartTag();
|
||||
setComponentTagClearTagState(pTag1, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
pTag1.doEndTag();
|
||||
|
||||
ParamTag pTag2 = new ParamTag();
|
||||
pTag2.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
pTag2.setPageContext(pageContext);
|
||||
pTag2.setValue("%{'field2'}");
|
||||
pTag2.doStartTag();
|
||||
setComponentTagClearTagState(pTag2, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
pTag2.doEndTag();
|
||||
|
||||
tag.doEndTag();
|
||||
|
||||
verify(FieldErrorTagTest.class.getResource("fielderror-4.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ParamTag freshParamTag = new ParamTag();
|
||||
freshParamTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshParamTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(pTag1, freshParamTag));
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(pTag2, freshParamTag));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
FieldErrorTag freshTag = new FieldErrorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testWithParamsWithFieldErrors3() throws Exception {
|
||||
FieldErrorTag tag = new FieldErrorTag();
|
||||
@@ -161,6 +441,57 @@ public class FieldErrorTagTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(FieldErrorTagTest.class.getResource("fielderror-5.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ParamTag freshParamTag = new ParamTag();
|
||||
freshParamTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(pTag1, freshParamTag));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
FieldErrorTag freshTag = new FieldErrorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
// FieldErrorTag has no non=default state set here, so it compares as equal with the default tag clear state as well.
|
||||
assertTrue("Tag state after doEndTag() under default tag clear state is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testWithParamsWithFieldErrors3_clearTagStateSet() throws Exception {
|
||||
FieldErrorTag tag = new FieldErrorTag();
|
||||
((InternalAction)action).setHaveFieldErrors(true);
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
ParamTag pTag1 = new ParamTag();
|
||||
pTag1.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
pTag1.setPageContext(pageContext);
|
||||
pTag1.setValue("%{'field2'}");
|
||||
pTag1.doStartTag();
|
||||
setComponentTagClearTagState(pTag1, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
pTag1.doEndTag();
|
||||
|
||||
tag.doEndTag();
|
||||
|
||||
verify(FieldErrorTagTest.class.getResource("fielderror-5.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ParamTag freshParamTag = new ParamTag();
|
||||
freshParamTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshParamTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(pTag1, freshParamTag));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
FieldErrorTag freshTag = new FieldErrorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testWithParamsWithoutFieldErrors1() throws Exception {
|
||||
@@ -182,6 +513,70 @@ public class FieldErrorTagTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(FieldErrorTagTest.class.getResource("fielderror-2.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ParamTag freshParamTag = new ParamTag();
|
||||
freshParamTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(pTag1, freshParamTag));
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(pTag2, freshParamTag));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
FieldErrorTag freshTag = new FieldErrorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
// FieldErrorTag has no non=default state set here, so it compares as equal with the default tag clear state as well.
|
||||
assertTrue("Tag state after doEndTag() under default tag clear state is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testWithParamsWithoutFieldErrors1_clearTagStateSet() throws Exception {
|
||||
FieldErrorTag tag = new FieldErrorTag();
|
||||
((InternalAction)action).setHaveFieldErrors(false);
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
ParamTag pTag1 = new ParamTag();
|
||||
pTag1.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
pTag1.setPageContext(pageContext);
|
||||
pTag1.setValue("%{'field1'}");
|
||||
pTag1.doStartTag();
|
||||
setComponentTagClearTagState(pTag1, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
pTag1.doEndTag();
|
||||
|
||||
ParamTag pTag2 = new ParamTag();
|
||||
pTag2.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
pTag2.setPageContext(pageContext);
|
||||
pTag2.setValue("%{'field3'}");
|
||||
pTag2.doStartTag();
|
||||
setComponentTagClearTagState(pTag2, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
pTag2.doEndTag();
|
||||
tag.doEndTag();
|
||||
|
||||
verify(FieldErrorTagTest.class.getResource("fielderror-2.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ParamTag freshParamTag = new ParamTag();
|
||||
freshParamTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshParamTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(pTag1, freshParamTag));
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(pTag2, freshParamTag));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
FieldErrorTag freshTag = new FieldErrorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testWithParamsWithoutFieldErrors2() throws Exception {
|
||||
@@ -203,8 +598,71 @@ public class FieldErrorTagTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(FieldErrorTagTest.class.getResource("fielderror-2.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ParamTag freshParamTag = new ParamTag();
|
||||
freshParamTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(pTag1, freshParamTag));
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(pTag2, freshParamTag));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
FieldErrorTag freshTag = new FieldErrorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
// FieldErrorTag has no non=default state set here, so it compares as equal with the default tag clear state as well.
|
||||
assertTrue("Tag state after doEndTag() under default tag clear state is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testWithParamsWithoutFieldErrors2_clearTagStateSet() throws Exception {
|
||||
FieldErrorTag tag = new FieldErrorTag();
|
||||
((InternalAction)action).setHaveFieldErrors(false);
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
ParamTag pTag1 = new ParamTag();
|
||||
pTag1.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
pTag1.setPageContext(pageContext);
|
||||
pTag1.setValue("%{'field1'}");
|
||||
pTag1.doStartTag();
|
||||
setComponentTagClearTagState(pTag1, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
pTag1.doEndTag();
|
||||
|
||||
ParamTag pTag2 = new ParamTag();
|
||||
pTag2.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
pTag2.setPageContext(pageContext);
|
||||
pTag2.setValue("%{'field3'}");
|
||||
pTag2.doStartTag();
|
||||
setComponentTagClearTagState(pTag2, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
pTag2.doEndTag();
|
||||
tag.doEndTag();
|
||||
|
||||
verify(FieldErrorTagTest.class.getResource("fielderror-2.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ParamTag freshParamTag = new ParamTag();
|
||||
freshParamTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshParamTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(pTag1, freshParamTag));
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(pTag2, freshParamTag));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
FieldErrorTag freshTag = new FieldErrorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testWithParamsWithoutFieldErrors3() throws Exception {
|
||||
FieldErrorTag tag = new FieldErrorTag();
|
||||
@@ -220,6 +678,57 @@ public class FieldErrorTagTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(FieldErrorTagTest.class.getResource("fielderror-2.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ParamTag freshParamTag = new ParamTag();
|
||||
freshParamTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(pTag1, freshParamTag));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
FieldErrorTag freshTag = new FieldErrorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
// FieldErrorTag has no non=default state set here, so it compares as equal with the default tag clear state as well.
|
||||
assertTrue("Tag state after doEndTag() under default tag clear state is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testWithParamsWithoutFieldErrors3_clearTagStateSet() throws Exception {
|
||||
FieldErrorTag tag = new FieldErrorTag();
|
||||
((InternalAction)action).setHaveFieldErrors(false);
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
ParamTag pTag1 = new ParamTag();
|
||||
pTag1.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
pTag1.setPageContext(pageContext);
|
||||
pTag1.setValue("%{'field2'}");
|
||||
pTag1.doStartTag();
|
||||
setComponentTagClearTagState(pTag1, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
pTag1.doEndTag();
|
||||
|
||||
tag.doEndTag();
|
||||
|
||||
verify(FieldErrorTagTest.class.getResource("fielderror-2.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ParamTag freshParamTag = new ParamTag();
|
||||
freshParamTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshParamTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(pTag1, freshParamTag));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
FieldErrorTag freshTag = new FieldErrorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testWithNullFieldErrors() throws Exception {
|
||||
@@ -237,9 +746,61 @@ public class FieldErrorTagTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(FieldErrorTagTest.class.getResource("fielderror-2.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ParamTag freshParamTag = new ParamTag();
|
||||
freshParamTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(pTag1, freshParamTag));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
FieldErrorTag freshTag = new FieldErrorTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
// FieldErrorTag has no non=default state set here, so it compares as equal with the default tag clear state as well.
|
||||
assertTrue("Tag state after doEndTag() under default tag clear state is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testWithNullFieldErrors_clearTagStateSet() throws Exception {
|
||||
FieldErrorTag tag = new FieldErrorTag();
|
||||
((InternalAction)action).setHaveFieldErrors(false);
|
||||
((InternalAction)action).setReturnNullForFieldErrors(true);
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
ParamTag pTag1 = new ParamTag();
|
||||
pTag1.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
pTag1.setPageContext(pageContext);
|
||||
pTag1.setValue("%{'field2'}");
|
||||
pTag1.doStartTag();
|
||||
setComponentTagClearTagState(pTag1, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
pTag1.doEndTag();
|
||||
|
||||
tag.doEndTag();
|
||||
|
||||
verify(FieldErrorTagTest.class.getResource("fielderror-2.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
ParamTag freshParamTag = new ParamTag();
|
||||
freshParamTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshParamTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(pTag1, freshParamTag));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
FieldErrorTag freshTag = new FieldErrorTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Action getAction() {
|
||||
return new InternalAction();
|
||||
}
|
||||
@@ -258,6 +819,7 @@ public class FieldErrorTagTest extends AbstractUITagTest {
|
||||
this.returnNullForFieldErrors = returnNullForFieldErrors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<String>> getFieldErrors() {
|
||||
if (haveFieldErrors) {
|
||||
List err1 = new ArrayList();
|
||||
@@ -280,6 +842,7 @@ public class FieldErrorTagTest extends AbstractUITagTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFieldErrors() {
|
||||
return haveFieldErrors;
|
||||
}
|
||||
|
||||
@@ -49,6 +49,42 @@ public class FileTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(TextFieldTag.class.getResource("File-1.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
FileTag freshTag = new FileTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testSimple_clearTagStateSet() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
testAction.setFoo("bar");
|
||||
|
||||
FileTag tag = new FileTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setLabel("mylabel");
|
||||
tag.setName("myname");
|
||||
tag.setAccept("*.txt");
|
||||
tag.setValue("%{foo}");
|
||||
tag.setSize("10");
|
||||
tag.setTitle("mytitle");
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(TextFieldTag.class.getResource("File-1.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
FileTag freshTag = new FileTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,6 +95,7 @@ public class FileTest extends AbstractUITagTest {
|
||||
* @return A Map of PropertyHolders values bound to {@link org.apache.struts2.views.jsp.AbstractUITagTest.PropertyHolder#getName()}
|
||||
* as key.
|
||||
*/
|
||||
@Override
|
||||
protected Map initializedGenericTagTestProperties() {
|
||||
Map result = super.initializedGenericTagTestProperties();
|
||||
new PropertyHolder("accept", "someAccepted").addToMap(result);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -39,5 +39,35 @@ public class HeadTagTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(HeadTagTest.class.getResource("HeadTagTest-1.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
HeadTag freshTag = new HeadTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
// HeadTag has no non=default state set here, so it compares as equal with the default tag clear state as well.
|
||||
assertTrue("Tag state after doEndTag() under default tag clear state is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testHead1_clearTagStateSet() throws Exception {
|
||||
HeadTag tag = new HeadTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
|
||||
stack.getActionContext().getSession().put("nonce", "r4nd0m");
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(HeadTagTest.class.getResource("HeadTagTest-1.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
HeadTag freshTag = new HeadTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ import org.apache.struts2.views.jsp.AbstractUITagTest;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class HiddenTest extends AbstractUITagTest {
|
||||
|
||||
public void testSimple() throws Exception {
|
||||
@@ -42,6 +44,39 @@ public class HiddenTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(TextFieldTag.class.getResource("Hidden-1.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
HiddenTag freshTag = new HiddenTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testSimple_clearTagStateSet() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
testAction.setFoo("bar");
|
||||
|
||||
HiddenTag tag = new HiddenTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setLabel("mylabel");
|
||||
tag.setName("myname");
|
||||
tag.setValue("%{foo}");
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(TextFieldTag.class.getResource("Hidden-1.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
HiddenTag freshTag = new HiddenTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testDisabled() throws Exception {
|
||||
@@ -59,6 +94,40 @@ public class HiddenTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(TextFieldTag.class.getResource("Hidden-2.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
HiddenTag freshTag = new HiddenTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testDisabled_clearTagStateSet() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
testAction.setFoo("bar");
|
||||
|
||||
HiddenTag tag = new HiddenTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setLabel("mylabel");
|
||||
tag.setName("myname");
|
||||
tag.setValue("%{foo}");
|
||||
tag.setDisabled("true");
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(TextFieldTag.class.getResource("Hidden-2.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
HiddenTag freshTag = new HiddenTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testDynamicAttributesWithActionInvocation() throws Exception {
|
||||
@@ -83,6 +152,47 @@ public class HiddenTest extends AbstractUITagTest {
|
||||
assertNotSame(stack.pop(), tag);
|
||||
|
||||
verify(TextFieldTag.class.getResource("Hidden-3.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
HiddenTag freshTag = new HiddenTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testDynamicAttributesWithActionInvocation_clearTagStateSet() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
testAction.setId(27357L);
|
||||
|
||||
MockActionInvocation ai = new MockActionInvocation();
|
||||
ai.setAction(action);
|
||||
ActionContext.getContext().setActionInvocation(ai);
|
||||
|
||||
HiddenTag tag = new HiddenTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setId("einszwei");
|
||||
tag.setName("first");
|
||||
tag.setValue("%{id}");
|
||||
tag.setDynamicAttribute("", "data-wuffmiauww", "%{id}");
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
assertSame(stack.pop(), testAction);
|
||||
assertNotSame(stack.pop(), tag);
|
||||
|
||||
verify(TextFieldTag.class.getResource("Hidden-3.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
HiddenTag freshTag = new HiddenTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testDynamicAttributesWithStack() throws Exception {
|
||||
@@ -103,6 +213,43 @@ public class HiddenTest extends AbstractUITagTest {
|
||||
assertNotSame(stack.pop(), tag);
|
||||
|
||||
verify(TextFieldTag.class.getResource("Hidden-3.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
HiddenTag freshTag = new HiddenTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testDynamicAttributesWithStack_clearTagStateSet() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
testAction.setId(27357L);
|
||||
|
||||
HiddenTag tag = new HiddenTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setId("einszwei");
|
||||
tag.setName("first");
|
||||
tag.setValue("%{id}");
|
||||
tag.setDynamicAttribute("", "data-wuffmiauww", "%{id}");
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
assertSame(stack.pop(), testAction);
|
||||
assertNotSame(stack.pop(), tag);
|
||||
|
||||
verify(TextFieldTag.class.getResource("Hidden-3.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
HiddenTag freshTag = new HiddenTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,8 +258,9 @@ public class HiddenTest extends AbstractUITagTest {
|
||||
* String, String[])} as properties to verify.<br> This implementation extends testdata from AbstractUITag.
|
||||
*
|
||||
* @return A Map of PropertyHolders values bound to {@link org.apache.struts2.views.jsp.AbstractUITagTest.PropertyHolder#getName()}
|
||||
* as key.
|
||||
* as key.
|
||||
*/
|
||||
@Override
|
||||
protected Map initializedGenericTagTestProperties() {
|
||||
Map result = new HashMap();
|
||||
new PropertyHolder("name", "someName").addToMap(result);
|
||||
|
||||
@@ -45,6 +45,45 @@ public class InputTransferSelectTagTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(InputTransferSelectTagTest.class.getResource("inputtransferselect-1.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
InputTransferSelectTag freshTag = new InputTransferSelectTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testWithRequired_clearTagStateSet() throws Exception {
|
||||
List list = new ArrayList();
|
||||
list.add("Item One");
|
||||
list.add("Item Two");
|
||||
|
||||
TestAction testaction = (TestAction) action;
|
||||
testaction.setCollection(list);
|
||||
|
||||
InputTransferSelectTag tag = new InputTransferSelectTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
|
||||
tag.setName("collection");
|
||||
tag.setList("collection");
|
||||
stack.getActionContext().getSession().put("nonce", "r4nd0m");
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
//System.out.println(writer.toString());
|
||||
verify(InputTransferSelectTagTest.class.getResource("inputtransferselect-1.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
InputTransferSelectTag freshTag = new InputTransferSelectTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testDynamicAttributes() throws Exception {
|
||||
|
||||
@@ -47,5 +47,38 @@ public class JspTemplateTest extends AbstractUITagTest {
|
||||
tag.doStartTag();
|
||||
tag.doEndTag();
|
||||
rdMock.verify();
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
CheckboxTag freshTag = new CheckboxTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testCheckBox_clearTagStateSet() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
testAction.setFoo("true");
|
||||
|
||||
CheckboxTag tag = new CheckboxTag();
|
||||
Mock rdMock = new Mock(RequestDispatcher.class);
|
||||
rdMock.expect("include",C.args(C.isA(HttpServletRequest.class), C.isA(HttpServletResponse.class)));
|
||||
RequestDispatcher dispatcher = (RequestDispatcher) rdMock.proxy();
|
||||
request.setupGetRequestDispatcher(dispatcher);
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setTemplate("/test/checkbox.jsp");
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
rdMock.verify();
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
CheckboxTag freshTag = new CheckboxTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,40 @@ public class LabelTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(LabelTest.class.getResource("Label-1.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
LabelTag freshTag = new LabelTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testSimple_clearTagStateSet() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
testAction.setFoo("bar");
|
||||
|
||||
LabelTag tag = new LabelTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setLabel("mylabel");
|
||||
tag.setName("myname");
|
||||
tag.setTitle("mytitle");
|
||||
tag.setValue("%{foo}");
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(LabelTest.class.getResource("Label-1.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
LabelTag freshTag = new LabelTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testSimpleWithLabelposition() throws Exception {
|
||||
@@ -61,6 +95,40 @@ public class LabelTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(LabelTest.class.getResource("Label-3.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
LabelTag freshTag = new LabelTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testSimpleWithLabelposition_clearTagStateSet() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
testAction.setFoo("bar");
|
||||
|
||||
LabelTag tag = new LabelTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setLabel("mylabel");
|
||||
tag.setName("myname");
|
||||
tag.setValue("%{foo}");
|
||||
tag.setLabelposition("top");
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(LabelTest.class.getResource("Label-3.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
LabelTag freshTag = new LabelTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,6 +139,7 @@ public class LabelTest extends AbstractUITagTest {
|
||||
* @return A Map of PropertyHolders values bound to {@link org.apache.struts2.views.jsp.AbstractUITagTest.PropertyHolder#getName()}
|
||||
* as key.
|
||||
*/
|
||||
@Override
|
||||
protected Map initializedGenericTagTestProperties() {
|
||||
Map result = new HashMap();
|
||||
new PropertyHolder("title", "someTitle").addToMap(result);
|
||||
@@ -95,6 +164,39 @@ public class LabelTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(LabelTest.class.getResource("Label-5.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
LabelTag freshTag = new LabelTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testWithNoValue_clearTagStateSet() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
testAction.setFoo("baz");
|
||||
|
||||
LabelTag tag = new LabelTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setLabel("mylabel");
|
||||
tag.setName("foo");
|
||||
tag.setFor("for");
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(LabelTest.class.getResource("Label-5.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
LabelTag freshTag = new LabelTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testGenericSimple() throws Exception {
|
||||
@@ -126,6 +228,44 @@ public class LabelTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(LabelTest.class.getResource("Label-2.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
LabelTag freshTag = new LabelTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testWithKeyNoValueFromStack_clearTagStateSet() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
final String key = "labelKey";
|
||||
final String value = "baz";
|
||||
testAction.setText(key, value);
|
||||
|
||||
testAction.setFoo("notToBeOutput");
|
||||
|
||||
LabelTag tag = new LabelTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setLabel("mylabel");
|
||||
tag.setFor("for");
|
||||
tag.setName("foo2");
|
||||
tag.setKey(key);
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(LabelTest.class.getResource("Label-2.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
LabelTag freshTag = new LabelTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testWithKeyValueFromStack() throws Exception {
|
||||
@@ -147,6 +287,44 @@ public class LabelTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(LabelTest.class.getResource("Label-4.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
LabelTag freshTag = new LabelTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testWithKeyValueFromStack_clearTagStateSet() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
final String key = "labelKey";
|
||||
final String value = "baz";
|
||||
testAction.setText(key, value);
|
||||
|
||||
testAction.setFoo("output");
|
||||
|
||||
LabelTag tag = new LabelTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setLabel("mylabel");
|
||||
tag.setFor("for");
|
||||
tag.setName("foo");
|
||||
tag.setKey(key);
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(LabelTest.class.getResource("Label-4.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
LabelTag freshTag = new LabelTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testWithJustKeyValueFromStack() throws Exception {
|
||||
@@ -166,6 +344,42 @@ public class LabelTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(LabelTest.class.getResource("Label-6.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
LabelTag freshTag = new LabelTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testWithJustKeyValueFromStack_clearTagStateSet() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
final String key = "labelKey";
|
||||
final String value = "baz";
|
||||
|
||||
// put key with message in a "resource"
|
||||
testAction.setText(key, value);
|
||||
|
||||
LabelTag tag = new LabelTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setKey(key);
|
||||
tag.setTheme("simple");
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(LabelTest.class.getResource("Label-6.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
LabelTag freshTag = new LabelTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testWithCssErrorClass() throws Exception {
|
||||
@@ -186,6 +400,43 @@ public class LabelTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(LabelTest.class.getResource("Label-7.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
LabelTag freshTag = new LabelTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testWithCssErrorClass_clearTagStateSet() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
testAction.setFoo("bar");
|
||||
|
||||
testAction.addFieldError("myname", "error");
|
||||
|
||||
LabelTag tag = new LabelTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setLabel("mylabel");
|
||||
tag.setName("myname");
|
||||
tag.setTitle("mytitle");
|
||||
tag.setValue("%{foo}");
|
||||
tag.setCssErrorClass("cssErrorClass1");
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(LabelTest.class.getResource("Label-7.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
LabelTag freshTag = new LabelTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testWithCssErrorStyle() throws Exception {
|
||||
@@ -206,6 +457,43 @@ public class LabelTest extends AbstractUITagTest {
|
||||
tag.doEndTag();
|
||||
|
||||
verify(LabelTest.class.getResource("Label-8.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
LabelTag freshTag = new LabelTag();
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
public void testWithCssErrorStyle_clearTagStateSet() throws Exception {
|
||||
TestAction testAction = (TestAction) action;
|
||||
testAction.setFoo("bar");
|
||||
|
||||
testAction.addFieldError("myname", "error");
|
||||
|
||||
LabelTag tag = new LabelTag();
|
||||
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
|
||||
tag.setPageContext(pageContext);
|
||||
tag.setLabel("mylabel");
|
||||
tag.setName("myname");
|
||||
tag.setTitle("mytitle");
|
||||
tag.setValue("%{foo}");
|
||||
tag.setCssErrorStyle("cssErrorStyle1");
|
||||
|
||||
tag.doStartTag();
|
||||
setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag).
|
||||
tag.doEndTag();
|
||||
|
||||
verify(LabelTest.class.getResource("Label-8.txt"));
|
||||
|
||||
// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
|
||||
LabelTag freshTag = new LabelTag();
|
||||
freshTag.setPerformClearTagStateForTagPoolingServers(true);
|
||||
freshTag.setPageContext(pageContext);
|
||||
assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " +
|
||||
"May indicate that clearTagStateForTagPoolingServers() calls are not working properly.",
|
||||
strutsBodyTagsAreReflectionEqual(tag, freshTag));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user