public abstract class AbstractComponentTest extends org.easymock.EasyMockSupport implements Function<org.apache.wicket.Page,org.apache.wicket.ajax.AjaxRequestTarget>
BaseWicketTester.startComponentInPage(Component)
, and it uses EasyMockSupport.createMockBuilder(Class)
to create a mock of AjaxRequestTarget
with which to verify Ajax calls from the component.
Note that AjaxRequestTarget.addListener(IListener)
, IRequestHandler.respond(IRequestCycle)
and IRequestHandler.detach(IRequestCycle)
are ignored by the mock, as they are used by the wicket
framework itself.Modifier and Type | Field and Description |
---|---|
org.junit.rules.ExpectedException |
exception
Rule for expecting thrown exceptions during test execution.
|
Constructor and Description |
---|
AbstractComponentTest() |
Modifier and Type | Method and Description |
---|---|
org.apache.wicket.ajax.AjaxRequestTarget |
apply(org.apache.wicket.Page context)
This method is a part of IContextProvider<AjaxRequestTarget, Page> implementation and is not
meant to be called by user code.
|
protected org.apache.wicket.protocol.http.WebApplication |
createApp()
Creates an instance of a Wicket
WebApplication in which to run the tests. |
protected ExtendedWicketTester |
createTester(org.apache.wicket.protocol.http.WebApplication app)
Creates the Wicket tester object that will support the tests.
|
protected org.apache.wicket.ajax.AjaxRequestTarget |
getTarget() |
protected ExtendedWicketTester |
getTester() |
protected void |
mockRequest(boolean mockRequest)
Optionally creates and injects a mock AJAX request target for the component to interact with.
|
protected void |
resetTest()
Resets the test.
|
void |
setUp()
Code that runs before every test.
|
protected void |
startFormComponentTest(org.apache.wicket.Component subject,
String inputType)
Starts a component for testing in a bare-bones form in a simple page.
|
protected void |
startFormComponentTest(org.apache.wicket.Component subject,
String inputType,
boolean mockRequest)
Starts a component for testing in a bare-bones form in a simple page.
|
protected void |
startFormComponentTestWithMarkup(org.apache.wicket.Component subject,
String inputType,
org.apache.wicket.markup.IMarkupFragment markup)
Starts a component for testing in a bare-bones form in a simple page.
|
protected void |
startFormComponentTestWithMarkup(org.apache.wicket.Component subject,
String inputType,
org.apache.wicket.markup.IMarkupFragment markup,
boolean mockRequest)
Starts a component for testing in a bare-bones form in a simple page with provided markup.
|
protected void |
startTest(org.apache.wicket.Component subject)
Starts a component for testing in a bare-bones page generated by the wicket framework.
|
protected void |
startTest(org.apache.wicket.Component subject,
boolean mockRequest)
Starts a component for testing in a bare-bones page generated by the wicket framework.
|
void |
tearDown()
Code that runs after every test.
|
createControl, createControl, createMock, createMock, createMock, createMock, createMockBuilder, createNiceControl, createNiceMock, createNiceMock, createStrictControl, createStrictMock, createStrictMock, getMockedClass, injectMocks, mock, mock, mock, mock, niceMock, niceMock, partialMockBuilder, replayAll, resetAll, resetAllToDefault, resetAllToNice, resetAllToStrict, strictMock, strictMock, verifyAll, verifyAllRecordings, verifyAllUnexpectedCalls
public org.junit.rules.ExpectedException exception
ExpectedException.expect(Class)
or a similar method to specify that it expects an
exception to be thrown subsequently.public void setUp()
public void tearDown()
protected org.apache.wicket.protocol.http.WebApplication createApp()
WebApplication
in which to run the tests. Can be overriden if specific functionality is
needed in the app, such as a specific home page. Note that this method is only called once, in the test constructor.WebApplication
.protected ExtendedWicketTester createTester(org.apache.wicket.protocol.http.WebApplication app)
app
- The Wicket application that the tester will associate with the pages and components createdprotected void startTest(org.apache.wicket.Component subject)
BaseWicketTester.startComponentInPage(Component)
.
Note that AjaxRequestTarget.addListener(IListener)
, IRequestHandler.respond(IRequestCycle)
and IRequestHandler.detach(IRequestCycle)
are ignored by the mock, as they are used by the wicket
framework itself.subject
- The component to be testedprotected void startFormComponentTest(org.apache.wicket.Component subject, String inputType)
BaseWicketTester.startComponentInPage(Component)
.
Note that AjaxRequestTarget.addListener(IListener)
, IRequestHandler.respond(IRequestCycle)
and IRequestHandler.detach(IRequestCycle)
are ignored by the mock, as they are used by the wicket
framework itself.subject
- The component to be testedinputType
- The HTML type of the input to associate with the component to be testedprotected void startFormComponentTestWithMarkup(org.apache.wicket.Component subject, String inputType, org.apache.wicket.markup.IMarkupFragment markup)
BaseWicketTester.startComponentInPage(Component)
.
Note that AjaxRequestTarget.addListener(IListener)
, IRequestHandler.respond(IRequestCycle)
and IRequestHandler.detach(IRequestCycle)
are ignored by the mock, as they are used by the wicket
framework itself.subject
- The component to be testedinputType
- The HTML type of the input to associate with the component to be testedmarkup
- The markup to use to initialize the Wicket test page.protected void startTest(org.apache.wicket.Component subject, boolean mockRequest)
BaseWicketTester.startComponentInPage(Component)
.
Note that AjaxRequestTarget.addListener(IListener)
, IRequestHandler.respond(IRequestCycle)
and IRequestHandler.detach(IRequestCycle)
are ignored by the mock, as they are used by the wicket
framework itself.subject
- The component to be testedmockRequest
- If the parameter is true, a mock request is created. Use this to verify the component's calls into Ajax.
If the parameter is false, a mock request is not created and the default request created by the wicket
framework is used instead. Use this to call into the component from Ajax.protected void startFormComponentTest(org.apache.wicket.Component subject, String inputType, boolean mockRequest)
BaseWicketTester.startComponentInPage(Component)
.
Note that AjaxRequestTarget.addListener(IListener)
, IRequestHandler.respond(IRequestCycle)
and IRequestHandler.detach(IRequestCycle)
are ignored by the mock, as they are used by the wicket
framework itself.subject
- The component to be testedinputType
- The HTML type of the input to associate with the component to be testedmockRequest
- If the parameter is true, a mock request is created. Use this to verify the component's calls into Ajax.
If the parameter is false, a mock request is not created and the default request created by the wicket
framework is used instead. Use this to call into the component from Ajax.protected void startFormComponentTestWithMarkup(org.apache.wicket.Component subject, String inputType, org.apache.wicket.markup.IMarkupFragment markup, boolean mockRequest)
BaseWicketTester.startComponentInPage(Component)
.
Note that AjaxRequestTarget.addListener(IListener)
, IRequestHandler.respond(IRequestCycle)
and IRequestHandler.detach(IRequestCycle)
are ignored by the mock, as they are used by the wicket
framework itself.subject
- The component to be testedinputType
- The HTML type of the input to associate with the component to be testedmarkup
- The markup to use to initialize the Wicket test page.mockRequest
- If the parameter is true, a mock request is created. Use this to verify the component's calls into Ajax.
If the parameter is false, a mock request is not created and the default request created by the wicket
framework is used instead. Use this to call into the component from Ajax.protected ExtendedWicketTester getTester()
WicketTester
object created during test set-up.protected org.apache.wicket.ajax.AjaxRequestTarget getTarget() throws TestNotStartedException
startTest(Component)
,
startTest(Component, boolean)
, startFormComponentTest(Component, String)
or startFormComponentTest(Component, String, boolean)
.
The object returned is always the mock target, regardless of whether requests are currently being mocked or not.TestNotStartedException
- if this method is called before any of those methods,
or if resetTest()
is called.protected void mockRequest(boolean mockRequest)
AjaxRequestTarget.addListener(IListener)
, IRequestHandler.respond(IRequestCycle)
and IRequestHandler.detach(IRequestCycle)
are ignored by the mock, as they are used by the wicket
framework itself.mockRequest
- If the parameter is true, a mock request is created. Use this to verify the component's calls into Ajax.
If the parameter is false, a mock request is not created and the default request created by the wicket
framework is used instead. Use this to call into the component from Ajax.protected void resetTest()
public org.apache.wicket.ajax.AjaxRequestTarget apply(org.apache.wicket.Page context)
Copyright © 2014–2019 Premium Minds. All rights reserved.