com.mockrunner.tag
Interface NestedTag

All Known Implementing Classes:
NestedBodyTag, NestedSimpleTag, NestedStandardTag

public interface NestedTag

NestedTag is used to simulate tags with static body content and child tags. It can be used to test the interaction of different tags. A NestedTag always wraps a real tag class (the actual testee). TagTestModule works with NestedTag instances internally. If you only want to test the ouptput of one single tag without interaction with other tags, you do not have to care about NestedTag. Use it, if you want to write sophisticated tests of body tags. NestedTag instances are created with the help of TagTestModule.createNestedTag(java.lang.Class). You do not need to create them on your own in the tests.


Method Summary
 void addDynamicChild(DynamicChild child)
          Adds a dynamic child simulating scriptlets and EL expressions.
 NestedTag addTagChild(java.lang.Class tag)
          Adds a tag child simulating nested tags.
 NestedTag addTagChild(java.lang.Class tag, java.util.Map attributeMap)
          Adds a tag child simulating nested tags.
 NestedTag addTagChild(javax.servlet.jsp.tagext.JspTag tag)
          Adds a tag child simulating nested tags.
 NestedTag addTagChild(javax.servlet.jsp.tagext.JspTag tag, java.util.Map attributeMap)
          Adds a tag child simulating nested tags.
 NestedTag addTagChild(javax.servlet.jsp.tagext.TagSupport tag)
          Adds a tag child simulating nested tags.
 NestedTag addTagChild(javax.servlet.jsp.tagext.TagSupport tag, java.util.Map attributeMap)
          Adds a tag child simulating nested tags.
 void addTextChild(java.lang.String text)
          Adds a text child simulating static body content.
 int doLifecycle()
          Performs the tags lifecycle.
 java.lang.Object getChild(int index)
          Returns a child specified by its index.
 java.util.List getChilds()
          Returns the List of childs.
 javax.servlet.jsp.tagext.TagSupport getTag()
          Returns the wrapped tag (the testee).
 javax.servlet.jsp.tagext.JspTag getWrappedTag()
          Returns the wrapped tag (the testee).
 void populateAttributes()
          Populates the attributes of the underlying tag.
 void removeChilds()
          Removes all childs.
 void setDoRelease(boolean doRelease)
          Specify if the release method should be called before populating a tag.
 void setDoReleaseRecursive(boolean doRelease)
          Specify if the release method should be called before populating a tag.
 

Method Detail

setDoRelease

public void setDoRelease(boolean doRelease)
Specify if the release method should be called before populating a tag. Defaults to false. It's the container behaviour to call release when the tag goes back to the pool. It's usually not necessary in the tests, because the tag instances are not pooled and reused during a test run. Only sets the doRelease flag for this tag and leaves the flag for child tags.

Parameters:
doRelease - should release be called, default is false

setDoReleaseRecursive

public void setDoReleaseRecursive(boolean doRelease)
Specify if the release method should be called before populating a tag. Defaults to false. It's the container behaviour to call release when the tag goes back to the pool. It's usually not necessary in the tests, because the tag instances are not pooled and reused during a test run. Recursively sets the doRelease flag for this tag and all childs.

Parameters:
doRelease - should release be called, default is false

populateAttributes

public void populateAttributes()
Populates the attributes of the underlying tag. The setters of the tag are called. Please note that child tags are not populated.


doLifecycle

public int doLifecycle()
                throws javax.servlet.jsp.JspException
Performs the tags lifecycle. All doBody and doTag methods are called as in the real web container. The evaluation of the body is simulated by performing the lifecycle recursively for all childs of the NestedTag.

Returns:
the result of the final doEndTag call
Throws:
javax.servlet.jsp.JspException

getTag

public javax.servlet.jsp.tagext.TagSupport getTag()
Returns the wrapped tag (the testee).

Returns:
the wrapped tag

getWrappedTag

public javax.servlet.jsp.tagext.JspTag getWrappedTag()
Returns the wrapped tag (the testee).

Returns:
the wrapped tag

removeChilds

public void removeChilds()
Removes all childs.


getChilds

public java.util.List getChilds()
Returns the List of childs.

Returns:
the List of childs

getChild

public java.lang.Object getChild(int index)
Returns a child specified by its index.

Parameters:
index - the index
Returns:
the child

addTextChild

public void addTextChild(java.lang.String text)
Adds a text child simulating static body content.

Parameters:
text - the static text

addDynamicChild

public void addDynamicChild(DynamicChild child)
Adds a dynamic child simulating scriptlets and EL expressions. Check out TagUtil.evalBody(List, Object) for details about child handling.

Parameters:
child - the dynamic child instance

addTagChild

public NestedTag addTagChild(java.lang.Class tag)
Adds a tag child simulating nested tags. The corresponding NestedTag will be created automatically wrapping the specified tag. An empty attribute Map will be used for the tag.

Parameters:
tag - the tag class

addTagChild

public NestedTag addTagChild(java.lang.Class tag,
                             java.util.Map attributeMap)
Adds a tag child simulating nested tags. The corresponding NestedTag will be created automatically wrapping the specified tag. The attributes Map contains the attributes of this tag (propertyname maps to propertyvalue).

Parameters:
tag - the tag class
attributeMap - the attribute map

addTagChild

public NestedTag addTagChild(javax.servlet.jsp.tagext.TagSupport tag)
Adds a tag child simulating nested tags. NestedTag will be created automatically wrapping the specified tag. An empty attribute Map will be used for the tag.

Parameters:
tag - the tag

addTagChild

public NestedTag addTagChild(javax.servlet.jsp.tagext.TagSupport tag,
                             java.util.Map attributeMap)
Adds a tag child simulating nested tags. The corresponding NestedTag will be created automatically wrapping the specified tag. The attributes Map contains the attributes of this tag (propertyname maps to propertyvalue).

Parameters:
tag - the tag
attributeMap - the attribute map

addTagChild

public NestedTag addTagChild(javax.servlet.jsp.tagext.JspTag tag)
Adds a tag child simulating nested tags. NestedTag will be created automatically wrapping the specified tag. An empty attribute Map will be used for the tag.

Parameters:
tag - the tag

addTagChild

public NestedTag addTagChild(javax.servlet.jsp.tagext.JspTag tag,
                             java.util.Map attributeMap)
Adds a tag child simulating nested tags. The corresponding NestedTag will be created automatically wrapping the specified tag. The attributes Map contains the attributes of this tag (propertyname maps to propertyvalue).

Parameters:
tag - the tag
attributeMap - the attribute map