|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.wicket.util.tester.BaseWicketTester
public class BaseWicketTester
A helper class to ease unit testing of Wicket applications without the need for a servlet
container. See javadoc of WicketTester
for example usage. This class can be used as
is, but JUnit users should use derived class WicketTester
.
WicketTester
Nested Class Summary | |
---|---|
static class |
BaseWicketTester.StartComponentInPage
A page that is used as the automatically created page for startComponentInPage(Class) and the other variations. |
Constructor Summary | |
---|---|
BaseWicketTester()
Creates WicketTester and automatically create a WebApplication , but
the tester will have no home page. |
|
BaseWicketTester(Class<C> homePage)
Creates WicketTester and automatically creates a WebApplication . |
|
BaseWicketTester(WebApplication application)
Creates a WicketTester . |
|
BaseWicketTester(WebApplication application,
boolean init)
Creates a WicketTester . |
|
BaseWicketTester(WebApplication application,
javax.servlet.ServletContext servletCtx)
Creates a WicketTester . |
|
BaseWicketTester(WebApplication application,
javax.servlet.ServletContext servletCtx,
boolean init)
Creates a WicketTester . |
|
BaseWicketTester(WebApplication application,
String servletContextBasePath)
Creates a WicketTester . |
Method Summary | ||
---|---|---|
void |
addRequestHeader(String key,
String value)
Allows to set Request header value any time. |
|
void |
applyRequest()
Rebuilds ServletWebRequest used by wicket from the mock request used to build
requests. |
|
void |
assertListView(String path,
List<?> expectedList)
assert the model of ListView use expectedList |
|
void |
assertResultPage(Class<?> pageClass,
String filename)
Asserts last rendered Page against an expected HTML document. |
|
protected Result |
checkUsability(Component component,
boolean throwException)
Checks whether a component is visible and/or enabled before usage |
|
void |
cleanupFeedbackMessages()
Cleans up feedback messages. |
|
protected void |
cleanupFeedbackMessages(IFeedbackMessageFilter filter)
Cleans up feedback messages given the specified filter. |
|
void |
clearFeedbackMessages()
Removes all feedback messages |
|
void |
clickLink(String path)
Click the Link in the last rendered Page. |
|
void |
clickLink(String path,
boolean isAjax)
Click the Link in the last rendered Page. |
|
protected Page |
createPage()
Creates a BaseWicketTester.StartComponentInPage to test a component with
startComponentInPage(Component, IMarkupFragment) |
|
protected String |
createPageMarkup(String componentId)
Creates the markup that will be used for the automatically created BaseWicketTester.StartComponentInPage that will be
used to test a component with startComponentInPage(Class, IMarkupFragment) |
|
void |
debugComponentTrees()
Dumps the Component trees. |
|
void |
debugComponentTrees(String filter)
Dumps the Component trees to log. |
|
void |
destroy()
Destroys the tester. |
|
void |
dumpPage()
Dumps the source of last rendered Page . |
|
void |
executeAjaxEvent(Component component,
String event)
Simulates the firing of an Ajax event. |
|
void |
executeAjaxEvent(String componentPath,
String event)
Simulates the firing of an Ajax event. |
|
void |
executeAjaxUrl(Url url)
|
|
void |
executeAllTimerBehaviors(MarkupContainer page)
Simulates the firing of all ajax timer behaviors on the page |
|
void |
executeBehavior(AbstractAjaxBehavior behavior)
Builds and processes a request suitable for executing an AbstractAjaxBehavior . |
|
void |
executeListener(Component component)
Builds and processes a request suitable for invoking a listener. |
|
void |
executeListener(Component component,
RequestListenerInterface listener)
Simulates processing URL that invokes specified RequestListenerInterface on
component. |
|
void |
executeUrl(String _url)
Starts a page, a shared resource or a IRequestListener depending on what the
IRequestMapper s resolve for the passed url. |
|
WebApplication |
getApplication()
Returns the Application for this environment. |
|
Component |
getComponentFromLastRenderedPage(String path)
Gets the component with the given path from last rendered page. |
|
Component |
getComponentFromLastRenderedPage(String path,
boolean wantVisibleInHierarchy)
Gets the component with the given path from last rendered page. |
|
String |
getContentDispositionFromResponseHeader()
Retrieves the content disposition from the response header. |
|
int |
getContentLengthFromResponseHeader()
Retrieves the content length from the response header. |
|
String |
getContentTypeFromResponseHeader()
Retrieves the content type from the response header. |
|
MockHttpSession |
getHttpSession()
Returns HttpSession for this environment |
|
String |
getLastModifiedFromResponseHeader()
Retrieves the last-modified value from the response header. |
|
Page |
getLastRenderedPage()
|
|
MockHttpServletRequest |
getLastRequest()
|
|
MockHttpServletResponse |
getLastResponse()
|
|
String |
getLastResponseAsString()
The last response as a string when a page is tested via startPage() methods. |
|
List<Serializable> |
getMessages(int level)
Retrieves FeedbackMessages . |
|
List<MockHttpServletRequest> |
getPreviousRequests()
|
|
List<MockHttpServletResponse> |
getPreviousResponses()
|
|
MockHttpServletRequest |
getRequest()
|
|
RequestCycle |
getRequestCycle()
|
|
protected Duration |
getResourcePollFrequency()
By default Modification Watcher is disabled by default for the tests. |
|
MockHttpServletResponse |
getResponse()
|
|
javax.servlet.ServletContext |
getServletContext()
Returns the ServletContext for this environment |
|
Session |
getSession()
|
|
TagTester |
getTagById(String id)
Retrieves a TagTester based on an DOM id. |
|
TagTester |
getTagByWicketId(String wicketId)
Retrieves a TagTester based on a wicket:id . |
|
List<TagTester> |
getTagsByWicketId(String wicketId)
Modified version of BaseWicketTester#getTagByWicketId(String) that returns all matching tags instead of just the first. |
|
String |
getWicketAjaxBaseUrlEncodedInLastResponse()
This method tries to parse the last response to return the encoded base URL and will throw an exception if there none was encoded. |
|
Result |
hasLabel(String path,
String expectedLabelText)
assert the text of Label component. |
|
Result |
hasNoErrorMessage()
Asserts no error-level feedback messages. |
|
Result |
hasNoInfoMessage()
Asserts no info-level feedback messages. |
|
Result |
ifContains(String pattern)
assert the content of last rendered page contains(matches) regex pattern. |
|
Result |
ifContainsNot(String pattern)
assert the content of last rendered page contains(matches) regex pattern. |
|
void |
invokeListener(Component component,
RequestListenerInterface listener)
Simulates invoking a listener on a component. |
|
|
isComponent(String path,
Class<C> expectedComponentClass)
assert component class |
|
Result |
isComponentOnAjaxResponse(Component component)
Tests that a Component has been added to a AjaxRequestTarget , using
AjaxRequestTarget.add(org.apache.wicket.Component...) . |
|
Result |
isDisabled(String path)
assert component disabled. |
|
Result |
isEnabled(String path)
assert component enabled. |
|
protected Result |
isEqual(Object expected,
Object actual)
|
|
boolean |
isExposeExceptions()
|
|
boolean |
isFollowRedirects()
|
|
Result |
isInvisible(String path)
assert component invisible. |
|
Result |
isNotRequired(FormComponent<?> component)
Asserts that a component is not required. |
|
Result |
isNotRequired(String path)
Asserts that a component is not required. |
|
|
isRenderedPage(Class<C> expectedRenderedPageClass)
Asserts the last rendered Page class. |
|
Result |
isRequired(FormComponent<?> component)
assert component required. |
|
Result |
isRequired(String path)
assert component required. |
|
Result |
isResultPage(String expectedDocument)
Asserts last rendered Page against an expected HTML document as a
String . |
|
boolean |
isUseRequestUrlAsBase()
|
|
Result |
isVisible(String path)
assert component visible. |
|
FormTester |
newFormTester(String path)
Creates a FormTester for the Form at a given path, and fills all child
FormComponent s with blank String s. |
|
FormTester |
newFormTester(String path,
boolean fillBlankString)
Creates a FormTester for the Form at a given path. |
|
protected Response |
newServletWebResponse(ServletWebRequest servletWebRequest)
|
|
protected IPageManagerProvider |
newTestPageManagerProvider()
|
|
boolean |
processRequest()
|
|
boolean |
processRequest(IRequestHandler forcedRequestHandler)
|
|
boolean |
processRequest(MockHttpServletRequest request)
Processes the request in mocked Wicket environment. |
|
boolean |
processRequest(MockHttpServletRequest request,
IRequestHandler forcedRequestHandler)
Processes the request in mocked Wicket environment. |
|
protected boolean |
processRequest(MockHttpServletRequest forcedRequest,
IRequestHandler forcedRequestHandler,
boolean redirect)
Process the request. |
|
void |
setExposeExceptions(boolean exposeExceptions)
|
|
void |
setFollowRedirects(boolean followRedirects)
Sets whether responses with redirects will be followed automatically. |
|
void |
setLastResponse(MockHttpServletResponse response)
|
|
void |
setRequest(MockHttpServletRequest request)
|
|
void |
setUseRequestUrlAsBase(boolean setBaseUrl)
|
|
Component |
startComponent(Component component)
Deprecated. Use startComponentInPage(Component) instead. WICKET-5097 |
|
|
startComponentInPage(C component)
Process a component. |
|
|
startComponentInPage(C component,
IMarkupFragment pageMarkup)
Process a component. |
|
|
startComponentInPage(Class<C> componentClass)
Process a component. |
|
|
startComponentInPage(Class<C> componentClass,
IMarkupFragment pageMarkup)
Process a component. |
|
|
startPage(Class<C> pageClass)
Renders a Page from its default constructor. |
|
|
startPage(Class<C> pageClass,
PageParameters parameters)
Renders a Page from its default constructor. |
|
Page |
startPage(IPageProvider pageProvider)
Renders the page specified by given IPageProvider . |
|
|
startPage(T page)
Renders the page. |
|
ResourceReference |
startResource(IResource resource)
Simulates a request to a mounted IResource |
|
ResourceReference |
startResourceReference(ResourceReference reference)
Simulates a request to a mounted ResourceReference |
|
ResourceReference |
startResourceReference(ResourceReference reference,
PageParameters pageParameters)
Simulates a request to a mounted ResourceReference |
|
void |
submitForm(Form<?> form)
Submit the given form in the last rendered BaseWicketTester.StartComponentInPage |
|
void |
submitForm(String path)
Submits the Form in the last rendered BaseWicketTester.StartComponentInPage . |
|
Url |
urlFor(AjaxLink<?> link)
|
|
Url |
urlFor(IRequestHandler handler)
Encodes the IRequestHandler to Url . |
|
String |
urlFor(Link<?> link)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BaseWicketTester()
WicketTester
and automatically create a WebApplication
, but
the tester will have no home page.
public BaseWicketTester(Class<C> homePage)
WicketTester
and automatically creates a WebApplication
.
C
- homePage
- a home page Class
public BaseWicketTester(WebApplication application)
WicketTester
.
application
- a WicketTester
WebApplication
objectpublic BaseWicketTester(WebApplication application, String servletContextBasePath)
WicketTester
.
application
- a WicketTester
WebApplication
objectservletContextBasePath
- the absolute path on disk to the web application's contents (e.g. war root) - may
be null
public BaseWicketTester(WebApplication application, javax.servlet.ServletContext servletCtx)
WicketTester
.
application
- a WicketTester
WebApplication
objectservletCtx
- the servlet context used as backendpublic BaseWicketTester(WebApplication application, boolean init)
WicketTester
.
application
- a WicketTester
WebApplication
objectinit
- force the application to be initialized (default = true)public BaseWicketTester(WebApplication application, javax.servlet.ServletContext servletCtx, boolean init)
WicketTester
.
application
- a WicketTester
WebApplication
objectservletCtx
- the servlet context used as backendinit
- force the application to be initialized (default = true)Method Detail |
---|
protected Duration getResourcePollFrequency()
protected IPageManagerProvider newTestPageManagerProvider()
public Page getLastRenderedPage()
public void cleanupFeedbackMessages()
public void clearFeedbackMessages()
protected void cleanupFeedbackMessages(IFeedbackMessageFilter filter)
filter
- filter used to cleanup messages, accepted messages will be removedprotected Response newServletWebResponse(ServletWebRequest servletWebRequest)
servletWebRequest
-
public MockHttpServletRequest getRequest()
public void setRequest(MockHttpServletRequest request)
request
- public void setLastResponse(MockHttpServletResponse response)
response
- public Session getSession()
public MockHttpSession getHttpSession()
HttpSession
for this environment
public WebApplication getApplication()
Application
for this environment.
public javax.servlet.ServletContext getServletContext()
ServletContext
for this environment
public void destroy()
ThreadContext
to state before instance of
WicketTester
was created.
public boolean processRequest()
public boolean processRequest(MockHttpServletRequest request)
request
- request to process
public boolean processRequest(MockHttpServletRequest request, IRequestHandler forcedRequestHandler)
request
- request to processforcedRequestHandler
- optional parameter to override parsing the request URL and force
IRequestHandler
public boolean processRequest(IRequestHandler forcedRequestHandler)
forcedRequestHandler
-
protected boolean processRequest(MockHttpServletRequest forcedRequest, IRequestHandler forcedRequestHandler, boolean redirect)
You may subclass processRequest it, to monitor or change any pre-configured value. Request
headers can be configured more easily by calling addRequestHeader(String, String)
.
forcedRequest
- Can be null.forcedRequestHandler
- Can be null.redirect
-
public final void addRequestHeader(String key, String value)
processRequest(MockHttpServletRequest, IRequestHandler, boolean)
. They are
reset immediately after and thus are not re-used for a sequence of requests.
Deletion (not replace) of pre-configured header value can be achieved by subclassing
processRequest(MockHttpServletRequest, IRequestHandler, boolean)
and modifying the
request header directly.
key
- value
- public Page startPage(IPageProvider pageProvider)
IPageProvider
. After render the page instance can
be retrieved using getLastRenderedPage()
and the rendered document will be available
in getLastResponse()
.
Depending on IRequestCycleSettings.RenderStrategy
invoking this method can mean that a redirect will happen
before the actual render.
pageProvider
-
public <T extends Page> T startPage(T page)
page
-
startPage(IPageProvider)
public ResourceReference startResource(IResource resource)
IResource
resource
- the resource to test
ResourceReference
for the simulationpublic ResourceReference startResourceReference(ResourceReference reference)
ResourceReference
reference
- the resource reference to test
public ResourceReference startResourceReference(ResourceReference reference, PageParameters pageParameters)
ResourceReference
reference
- the resource reference to testpageParameters
- the parameters passed to the resource reference
public MockHttpServletResponse getLastResponse()
null
> if no response has been produced yet.public String getLastResponseAsString()
startPage()
methods.
In case the processed component was not a BaseWicketTester.StartComponentInPage
then the automatically created page
markup gets removed. If you need the whole returned markup in this case use
getLastResponse()
.getDocument()
public String getWicketAjaxBaseUrlEncodedInLastResponse() throws IOException, ResourceStreamNotFoundException, ParseException
AbstractDefaultAjaxBehavior
IOException
ResourceStreamNotFoundException
ParseException
public List<MockHttpServletRequest> getPreviousRequests()
public List<MockHttpServletResponse> getPreviousResponses()
public void setFollowRedirects(boolean followRedirects)
followRedirects
- public boolean isFollowRedirects()
true
if redirect responses will be followed automatically,
false
otherwise.public Url urlFor(IRequestHandler handler)
IRequestHandler
to Url
. It should be safe to call this method
outside request thread as log as no registered IRequestMapper
requires a
RequestCycle
.
handler
-
Url
for handler.public String urlFor(Link<?> link)
link
-
public void executeListener(Component component, RequestListenerInterface listener)
RequestListenerInterface
on
component.
After the listener interface is invoked the page containing the component will be rendered
(with an optional redirect - depending on IRequestCycleSettings.RenderStrategy
).
component
- listener
- public void invokeListener(Component component, RequestListenerInterface listener)
executeListener(Component)
method, current request/response objects will be used
After the listener interface is invoked the page containing the component will be rendered
(with an optional redirect - depending on IRequestCycleSettings.RenderStrategy
).
component
- listener
- public void executeListener(Component component)
Component
must implement any of the known IListener
interfaces.
component
- the listener to invokepublic void executeBehavior(AbstractAjaxBehavior behavior)
AbstractAjaxBehavior
.
behavior
- an AbstractAjaxBehavior
to executepublic Url urlFor(AjaxLink<?> link)
link
-
public void executeAjaxUrl(Url url)
url
- public final <C extends Page> C startPage(Class<C> pageClass)
Page
from its default constructor.
C
- pageClass
- a test Page
class with default constructor
Page
public final <C extends Page> C startPage(Class<C> pageClass, PageParameters parameters)
Page
from its default constructor.
C
- pageClass
- a test Page
class with default constructorparameters
- the parameters to use for the class.
Page
public FormTester newFormTester(String path)
FormTester
for the Form
at a given path, and fills all child
FormComponent
s with blank String
s.
path
- path to FormComponent
FormTester
instance for testing the Form
newFormTester(String, boolean)
public FormTester newFormTester(String path, boolean fillBlankString)
FormTester
for the Form
at a given path.
path
- path to FormComponent
fillBlankString
- specifies whether to fill all child FormComponent
s with blank
String
s
FormTester
instance for testing the Form
FormTester
public final <C extends Component> C startComponentInPage(Class<C> componentClass)
createPageMarkup(String)
.
Note: the instantiated component will have an auto-generated id. To
reach any of its children use their relative path to the component itself. For example
if the started component has a child a Link component with id "link" then after starting
the component you can click it with: tester.clickLink("link")
C
- the type of the componentcomponentClass
- the class of the component to be tested
startComponentInPage(org.apache.wicket.Component)
public final <C extends Component> C startComponentInPage(Class<C> componentClass, IMarkupFragment pageMarkup)
pageMarkup
provided. In case pageMarkup is null, the markup will be automatically created with
createPageMarkup(String)
.
Note: the instantiated component will have an auto-generated id. To
reach any of its children use their relative path to the component itself. For example
if the started component has a child a Link component with id "link" then after starting
the component you can click it with: tester.clickLink("link")
C
- the type of the componentcomponentClass
- the class of the component to be testedpageMarkup
- the markup for the Page that will be automatically created. May be null
.
public final <C extends Component> C startComponentInPage(C component)
createPageMarkup(String)
.
Note: the component id is set by the user. To
reach any of its children use this id + their relative path to the component itself. For example
if the started component has id compId and a Link child component component with id "link"
then after starting the component you can click it with: tester.clickLink("compId:link")
C
- the type of the componentcomponent
- the component to be tested
startComponentInPage(Class)
public final <C extends Component> C startComponentInPage(C component, IMarkupFragment pageMarkup)
pageMarkup
provided. In case pageMarkup
is null, the markup will be automatically created with
createPageMarkup(String)
.
Note: the component id is set by the user. To
reach any of its children use this id + their relative path to the component itself. For example
if the started component has id compId and a Link child component component with id "link"
then after starting the component you can click it with: tester.clickLink("compId:link")
C
- the type of the componentcomponent
- the component to be testedpageMarkup
- the markup for the Page that will be automatically created. May be null
.
protected String createPageMarkup(String componentId)
BaseWicketTester.StartComponentInPage
that will be
used to test a component with startComponentInPage(Class, IMarkupFragment)
componentId
- the id of the component to be tested
BaseWicketTester.StartComponentInPage
as String
. Cannot be null
.protected Page createPage()
BaseWicketTester.StartComponentInPage
to test a component with
startComponentInPage(Component, IMarkupFragment)
BaseWicketTester.StartComponentInPage
which will contain the component under test as a single child@Deprecated public Component startComponent(Component component)
component
-
startComponentInPage(Class)
public Component getComponentFromLastRenderedPage(String path, boolean wantVisibleInHierarchy)
path
- Path to componentwantVisibleInHierarchy
- if true component needs to be VisibleInHierarchy else null is returned
MarkupContainer.get(String)
public Component getComponentFromLastRenderedPage(String path)
path
- Path to component
MarkupContainer.get(String)
public Result hasLabel(String path, String expectedLabelText)
Label
component.
path
- path to Label
componentexpectedLabelText
- expected label text
Result
public <C extends Component> Result isComponent(String path, Class<C> expectedComponentClass)
C
- path
- path to componentexpectedComponentClass
- expected component class
Result
public Result isVisible(String path)
path
- path to component
Result
public Result isInvisible(String path)
path
- path to component
Result
public Result isEnabled(String path)
path
- path to component
Result
public Result isDisabled(String path)
path
- path to component
Result
public Result isRequired(String path)
path
- path to component
Result
public Result isRequired(FormComponent<?> component)
component
- a form component
Result
public Result isNotRequired(String path)
path
- path to component
Result
public Result isNotRequired(FormComponent<?> component)
component
- a form component
Result
public Result ifContains(String pattern)
pattern
- reqex pattern to match
Result
public Result ifContainsNot(String pattern)
pattern
- reqex pattern to match
Result
public void assertListView(String path, List<?> expectedList)
ListView
use expectedList
path
- path to ListView
componentexpectedList
- expected list in the model of ListView
public void clickLink(String path)
Link
in the last rendered Page.
Simulate that AJAX is enabled.
path
- Click the Link
in the last rendered Page.clickLink(String, boolean)
public void clickLink(String path, boolean isAjax)
Link
in the last rendered Page.
This method also works for AjaxLink
, AjaxFallbackLink
and
AjaxSubmitLink
.
On AjaxLinks and AjaxFallbackLinks the onClick method is invoked with a valid AjaxRequestTarget. In that way you can test the flow of your application when using AJAX.
When clicking an AjaxSubmitLink the form, which the AjaxSubmitLink is attached to is first
submitted, and then the onSubmit method on AjaxSubmitLink is invoked. If you have changed
some values in the form during your test, these will also be submitted. This should not be
used as a replacement for the FormTester
to test your forms. It should be used to
test that the code in your onSubmit method in AjaxSubmitLink actually works.
This method is also able to simulate that AJAX (javascript) is disabled on the client. This is done by setting the isAjax parameter to false. If you have an AjaxFallbackLink you can then check that it doesn't fail when invoked as a normal link.
path
- path to Link
componentisAjax
- Whether to simulate that AJAX (javascript) is enabled or not. If it's false then
AjaxLink and AjaxSubmitLink will fail, since it wouldn't work in real life.
AjaxFallbackLink will be invoked with null as the AjaxRequestTarget parameter.public void submitForm(Form<?> form)
BaseWicketTester.StartComponentInPage
Note: Form request parameters have to be set explicitely.
form
- path to componentpublic void submitForm(String path)
Form
in the last rendered BaseWicketTester.StartComponentInPage
.
Note: Form request parameters have to be set explicitely.
path
- path to componentpublic <C extends Page> Result isRenderedPage(Class<C> expectedRenderedPageClass)
Page
class.
C
- expectedRenderedPageClass
- expected class of last rendered page
Result
public void assertResultPage(Class<?> pageClass, String filename) throws Exception
Page
against an expected HTML document.
Use -Dwicket.replace.expected.results=true
to automatically replace the expected
output file.
pageClass
- used to load the File
(relative to clazz
package)filename
- expected output File
name
Exception
public Result isResultPage(String expectedDocument) throws Exception
Page
against an expected HTML document as a
String
.
expectedDocument
- expected output
Result
Exception
public Result hasNoErrorMessage()
Result
public Result hasNoInfoMessage()
Result
public List<Serializable> getMessages(int level)
FeedbackMessages
.
level
- level of feedback message, for example:
FeedbackMessage.DEBUG or FeedbackMessage.INFO.. etc
List
of messages (as String
s)FeedbackMessage
public void dumpPage()
Page
.
public void debugComponentTrees()
Component
trees.
public void debugComponentTrees(String filter)
Component
trees to log. Show only the Component
s whose
paths contain the filter String
.
filter
- a filter String
public Result isComponentOnAjaxResponse(Component component)
Component
has been added to a AjaxRequestTarget
, using
AjaxRequestTarget.add(org.apache.wicket.Component...)
. This
method actually tests that a Component
is on the Ajax response sent back to the
client.
PLEASE NOTE! This method doesn't actually insert the Component
in the client DOM
tree, using JavaScript. But it shouldn't be needed because you have to trust that the Wicket
Ajax JavaScript just works.
component
- the Component
to test
Result
public void executeAjaxEvent(String componentPath, String event)
componentPath
- the Component
pathevent
- the event which we simulate being fired. If event
is
null
, the test will fail.executeAjaxEvent(Component, String)
public void executeAllTimerBehaviors(MarkupContainer page)
page
- the page which timers will be executedpublic void executeAjaxEvent(Component component, String event)
Component
by
using:
... component.add(new AjaxEventBehavior("ondblclick") { public void onEvent(AjaxRequestTarget) {} }); ...You can then test that the code inside
onEvent
actually does what it's supposed
to, using the WicketTester
:
... tester.executeAjaxEvent(component, "ondblclick"); // Test that the code inside onEvent is correct. ...This also works with
AjaxFormSubmitBehavior
, where it will "submit" the
Form
before executing the command.
PLEASE NOTE! This method doesn't actually insert the Component
in the client DOM
tree, using JavaScript.
component
- the Component
that has the AjaxEventBehavior
we want to
test. If the Component
is null
, the test will fail.event
- the event to simulate being fired. If event
is null
, the
test will fail.public TagTester getTagByWicketId(String wicketId)
TagTester
based on a wicket:id
. If more
Component
s exist with the same wicket:id
in the markup, only the
first one is returned.
wicketId
- the wicket:id
to search for
TagTester
for the tag which has the given wicket:id
public List<TagTester> getTagsByWicketId(String wicketId)
wicketId
-
public TagTester getTagById(String id)
TagTester
based on an DOM id. If more Component
s exist
with the same id in the markup, only the first one is returned.
id
- the DOM id to search for.
TagTester
for the tag which has the given DOM idpublic String getContentTypeFromResponseHeader()
public int getContentLengthFromResponseHeader()
public String getLastModifiedFromResponseHeader()
public String getContentDispositionFromResponseHeader()
public void applyRequest()
ServletWebRequest
used by wicket from the mock request used to build
requests. Sometimes this method is useful when changes need to be checked without processing
a request.
protected final Result isEqual(Object expected, Object actual)
expected
- actual
-
protected Result checkUsability(Component component, boolean throwException)
component
- throwException
-
public RequestCycle getRequestCycle()
public MockHttpServletResponse getResponse()
public MockHttpServletRequest getLastRequest()
public boolean isExposeExceptions()
public void setExposeExceptions(boolean exposeExceptions)
exposeExceptions
- public boolean isUseRequestUrlAsBase()
public void setUseRequestUrlAsBase(boolean setBaseUrl)
setBaseUrl
- public void executeUrl(String _url)
IRequestListener
depending on what the
IRequestMapper
s resolve for the passed url.
_url
- the url to resolve and execute
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |