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 using 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 tag 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 after processing the tag lifecycle.
 void setDoReleaseRecursive(boolean doRelease)
          Specify if the release method should be called after processing the tag lifecycle.
 

Method Detail

setDoRelease

void setDoRelease(boolean doRelease)
Specify if the release method should be called after processing the tag lifecycle. 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 to call this method, because the tag instances are not pooled and reused during a test run. This method sets the doRelease flag for this tag but does not set the flag for child tags.

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

setDoReleaseRecursive

void setDoReleaseRecursive(boolean doRelease)
Specify if the release method should be called after processing the tag lifecycle. 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 to call this method, because the tag instances are not pooled and reused during a test run. This method sets the doRelease flag for this tag and all child tags recursively.

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

populateAttributes

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

int doLifecycle()
                throws javax.servlet.jsp.JspException
Performs the tag 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. Calls release on the tag after processing the tag lifecycle, if doRelease is true (use setDoRelease(boolean)).

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

getTag

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

Returns:
the wrapped tag

getWrappedTag

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

Returns:
the wrapped tag

removeChilds

void removeChilds()
Removes all childs.


getChilds

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

Returns:
the List of childs

getChild

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

Parameters:
index - the index
Returns:
the child

addTextChild

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

Parameters:
text - the static text

addDynamicChild

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

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

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

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

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

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

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