|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.mockrunner.base.WebTestModule com.mockrunner.base.HTMLOutputModule com.mockrunner.tag.TagTestModule
public class TagTestModule
Module for custom tag tests. Simulates the container by performing the tag lifecycle.
Constructor Summary | |
---|---|
TagTestModule(WebMockObjectFactory mockFactory)
|
Method Summary | |
---|---|
void |
clearOutput()
Resets the output buffer. |
NestedTag |
createNestedTag(java.lang.Class tagClass)
Creates a NestedTag and returns it. |
NestedTag |
createNestedTag(java.lang.Class tagClass,
java.util.Map attributes)
Creates a NestedTag and returns it. |
javax.servlet.jsp.tagext.TagSupport |
createTag(java.lang.Class tagClass)
Creates a tag. |
javax.servlet.jsp.tagext.TagSupport |
createTag(java.lang.Class tagClass,
java.util.Map attributes)
Creates a tag. |
javax.servlet.jsp.tagext.JspTag |
createWrappedTag(java.lang.Class tagClass)
Creates a tag. |
javax.servlet.jsp.tagext.JspTag |
createWrappedTag(java.lang.Class tagClass,
java.util.Map attributes)
Creates a tag. |
int |
doAfterBody()
Calls the doAfterBody method of the current tag. |
int |
doEndTag()
Calls the doEndTag method of the current tag. |
void |
doInitBody()
Calls the doInitBody method of the current tag. |
int |
doStartTag()
Calls the doStartTag method of the current tag. |
void |
doTag()
Calls the doStartTag method of the current tag. |
MockPageContext |
getMockPageContext()
Returns the MockPageContext object. |
NestedTag |
getNestedTag()
Returns the current nested tag. |
java.lang.String |
getOutput()
Gets the output data the current tag has rendered. |
javax.servlet.jsp.tagext.TagSupport |
getTag()
Returns the current wrapped tag. |
javax.servlet.jsp.tagext.JspTag |
getWrappedTag()
Returns the current wrapped tag. |
void |
populateAttributes()
Populates the attributes of the underlying tag by calling NestedTag.populateAttributes() . |
int |
processTagLifecycle()
Performs the tags lifecycle by calling NestedTag.doLifecycle() . |
void |
release()
Calls the release method of the current tag. |
void |
setBody(java.lang.String body)
Sets the body of the tag as a static string. |
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. |
NestedTag |
setTag(javax.servlet.jsp.tagext.JspTag tag)
Creates a NestedTag and returns it. |
NestedTag |
setTag(javax.servlet.jsp.tagext.JspTag tag,
java.util.Map attributes)
Creates a NestedTag and returns it. |
NestedTag |
setTag(javax.servlet.jsp.tagext.TagSupport tag)
Creates a NestedTag and returns it. |
NestedTag |
setTag(javax.servlet.jsp.tagext.TagSupport tag,
java.util.Map attributes)
Creates a NestedTag and returns it. |
Methods inherited from class com.mockrunner.base.HTMLOutputModule |
---|
getOutputAsBufferedReader, getOutputAsJDOMDocument, getOutputAsW3CDocument, getOutputAsWellformedXML, setCaseSensitive, verifyOutput, verifyOutputContains, verifyOutputRegularExpression |
Methods inherited from class com.mockrunner.base.WebTestModule |
---|
addRequestParameter, addRequestParameter, addRequestParameter, getRequestAttribute, getRequestParameter, getSessionAttribute, setRequestAttribute, setSessionAttribute |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TagTestModule(WebMockObjectFactory mockFactory)
Method Detail |
---|
public javax.servlet.jsp.tagext.TagSupport createTag(java.lang.Class tagClass)
NestedTag
is created but the wrapped tag is returned. If you
simply want to test the output of the tag without
nesting other tags, you do not have to care about the
NestedTag
, just use the returned instance.
An empty attribute Map
will be used for
the tag.
tagClass
- the class of the tag
TagSupport
or BodyTagSupport
RuntimeException
,
- if the created tag
is not an instance of TagSupport
public javax.servlet.jsp.tagext.TagSupport createTag(java.lang.Class tagClass, java.util.Map attributes)
NestedTag
is created but the wrapped tag is returned. If you
simply want to test the output of the tag without
nesting other tags, you do not have to care about the
NestedTag
, just use the returned instance.
The attributes Map
contains the attributes
of this tag (propertyname maps to propertyvalue).
The attributes are populated (i.e. the tags setters are called)
during the lifecycle or with an explicit call of
populateAttributes()
.
tagClass
- the class of the tagattributes
- the attribute map
TagSupport
or BodyTagSupport
RuntimeException
,
- if the created tag
is not an instance of TagSupport
public javax.servlet.jsp.tagext.JspTag createWrappedTag(java.lang.Class tagClass)
NestedTag
is created but the wrapped tag is returned. If you
simply want to test the output of the tag without
nesting other tags, you do not have to care about the
NestedTag
, just use the returned instance.
An empty attribute Map
will be used for
the tag.
This method can be used for all kind of tags. The tag
class does not need to be a subclass of TagSupport
.
tagClass
- the class of the tag
JspTag
public javax.servlet.jsp.tagext.JspTag createWrappedTag(java.lang.Class tagClass, java.util.Map attributes)
NestedTag
is created but the wrapped tag is returned. If you
simply want to test the output of the tag without
nesting other tags, you do not have to care about the
NestedTag
, just use the returned instance.
The attributes Map
contains the attributes
of this tag (propertyname maps to propertyvalue).
The attributes are populated (i.e. the tags setters are called)
during the lifecycle or with an explicit call of
populateAttributes()
.
This method can be used for all kind of tags. The tag
class does not need to be a subclass of TagSupport
.
tagClass
- the class of the tagattributes
- the attribute map
JspTag
public NestedTag createNestedTag(java.lang.Class tagClass)
NestedTag
and returns it. You can
add child tags or body blocks to the NestedTag
.
Use getTag()
to get the wrapped tag.
An empty attribute Map
will be used for
the tag.
tagClass
- the class of the tag
NestedStandardTag
, NestedBodyTag
or
NestedSimpleTag
public NestedTag createNestedTag(java.lang.Class tagClass, java.util.Map attributes)
NestedTag
and returns it. You can
add child tags or body blocks to the NestedTag
.
Use getTag()
to get the wrapped tag.
The attributes Map
contains the attributes
of this tag (propertyname maps to propertyvalue).
The attributes are populated (i.e. the tags setters are called)
during the lifecycle or with an explicit call of
populateAttributes()
.
tagClass
- the class of the tagattributes
- the attribute map
NestedStandardTag
, NestedBodyTag
or
NestedSimpleTag
public NestedTag setTag(javax.servlet.jsp.tagext.TagSupport tag)
NestedTag
and returns it. You can
add child tags or body blocks to the NestedTag
.
Use getTag()
to get the wrapped tag.
An empty attribute Map
will be used for
the tag.
tag
- the tag
NestedStandardTag
or NestedBodyTag
public NestedTag setTag(javax.servlet.jsp.tagext.TagSupport tag, java.util.Map attributes)
NestedTag
and returns it. You can
add child tags or body blocks to the NestedTag
.
Use getTag()
to get the wrapped tag.
The attributes Map
contains the attributes
of this tag (propertyname maps to propertyvalue).
The attributes are populated (i.e. the tags setters are called)
during the lifecycle or with an explicit call of
populateAttributes()
.
tag
- the tagattributes
- the attribute map
NestedStandardTag
or NestedBodyTag
public NestedTag setTag(javax.servlet.jsp.tagext.JspTag tag)
NestedTag
and returns it. You can
add child tags or body blocks to the NestedTag
.
Use getTag()
to get the wrapped tag.
An empty attribute Map
will be used for
the tag.
This method can be used for all kind of tags. The tag
class does not need to be a subclass of TagSupport
.
tag
- the tag
NestedStandardTag
, NestedBodyTag
or
NestedSimpleTag
public NestedTag setTag(javax.servlet.jsp.tagext.JspTag tag, java.util.Map attributes)
NestedTag
and returns it. You can
add child tags or body blocks to the NestedTag
.
Use getTag()
to get the wrapped tag.
The attributes Map
contains the attributes
of this tag (propertyname maps to propertyvalue).
The attributes are populated (i.e. the tags setters are called)
during the lifecycle or with an explicit call of
populateAttributes()
.
This method can be used for all kind of tags. The tag
class does not need to be a subclass of TagSupport
.
tag
- the tagattributes
- the attribute map
NestedStandardTag
, NestedBodyTag
or
NestedSimpleTag
public void setDoRelease(boolean doRelease)
release
method should be called
after processing the tag lifecycle. Delegates to NestedTag.setDoRelease(boolean)
Defaults to false
. It's the container behaviour to call
release
, but it's usually not necessary in the tests,
because the tag instances are not reused during a test run.
doRelease
- should release be calledpublic void setDoReleaseRecursive(boolean doRelease)
release
method should be called
after processing the tag lifecycle. Delegates to NestedTag.setDoReleaseRecursive(boolean)
Defaults to false
. It's the container behaviour to call
release
, but it's usually not necessary in the tests,
because the tag instances are not reused during a test run.
doRelease
- should release be calledpublic void populateAttributes()
NestedTag.populateAttributes()
. The setters
of the tag are called. Please note that child tags are not
populated. This is done during the lifecycle.
public void setBody(java.lang.String body)
NestedTag
are deleted and the static content is set. If you want
to use nested tags, please use the method NestedTag.addTextChild(java.lang.String)
to set static content.
body
- the static body contentpublic javax.servlet.jsp.tagext.TagSupport getTag()
TagSupport
or BodyTagSupport
RuntimeException
,
- if the wrapped tag
is not an instance of TagSupport
public javax.servlet.jsp.tagext.JspTag getWrappedTag()
TagSupport
.
JspTag
public NestedTag getNestedTag()
NestedTag
.
Use getTag()
to get the wrapped tag.
NestedStandardTag
or NestedBodyTag
public MockPageContext getMockPageContext()
MockPageContext
object.
Delegates to WebMockObjectFactory.getMockPageContext()
.
public void doTag()
doStartTag
method of the current tag.
RuntimeException
,
- if the tag
is not a simple tagpublic int doStartTag()
doStartTag
method of the current tag.
doStartTag
RuntimeException
,
- if the tag
is a simple tagpublic int doEndTag()
doEndTag
method of the current tag.
doEndTag
RuntimeException
,
- if the tag
is a simple tagpublic void doInitBody()
doInitBody
method of the current tag.
java.lang.RuntimeException
- if the current tag is no body tag
RuntimeException
,
- if the tag
is a simple tagpublic int doAfterBody()
doAfterBody
method of the current tag.
doAfterBody
RuntimeException
,
- if the tag
is a simple tagpublic void release()
release
method of the current tag.
RuntimeException
,
- if the tag
is a simple tagpublic int processTagLifecycle()
NestedTag.doLifecycle()
.
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
.
doEndTag
call or -1 in
the case of a simple tagpublic void clearOutput()
public java.lang.String getOutput()
doStartTag()
or processTagLifecycle()
getOutput
in class HTMLOutputModule
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |