I unsuccessfully tried several different ways to invoke the AjaxSubmitLink
from my test method.
1. formTester.submit("submitButton") does not call
AjaxSubmitLink#onSubmit(AjaxRequestTarget target, Form form)
2. formTester.submitLink("submitButton", false) fails with
*org.apache.wicket.WicketRuntimeException: Link
panel:referralForm:submitButtonis an AjaxSubmitLink and will not be invoked
when AJAX (javascript) is disabled.*
3. tester.clickLink("referralForm:submitButton, true) does not call
AjaxSubmitLink#onSubmit(AjaxRequestTarget target, Form form)
4. EnhancedWicketTester.clickAjaxLink("referralForm:submitButton") fails
with
*junit.framework.AssertionFailedError: component
'ReferralPanel$ReferralForm$2' is not type:Link*
This makes sense because AjaxSubmitLink class is not a subclass of Link.
So, how do I test AjaxSubmitLink#onSubmit(AjaxRequestTarget target, Form
form) method?
Thanks,
Alec
@L
On Sun, Dec 27, 2009 at 9:44 AM, Alec Swan <[email protected]> wrote:
> I have a page with a form and AjaxSubmitLink in the form.
>
> I call WicketTester#clickLink(pathToLink, true) to test the code in
> AjaxSubmitLink#onSubmit(). The call returns with no errors, but
> AjaxSubmitLink#onSubmit() is never called.
>
> Here is a code sample:
>
> tester.startPanel(MyPanel.class);
> final FormTester formTester = tester.newFormTester(FORM_PATH);
>
> // Test: Submit form with valid inputs
> formTester.setValue("company", "company");
> formTester.setValue("phone", "phone");
> *tester.clickLink(SUBMIT_LINK_PATH, true);*
>
> Thanks,
>
> Alec
>
>
>
>
>