I am not sure, but would rather not. I believe this is a standard way to
create pages in Wicket(passing required arguments in constructors) and there
should be a mechanism to test this.
On a side note, when I change my code to:
form.add(new AjaxSubmitLink("submitLink"){
private static final long serialVersionUID =
3239568065916265026L;
@Override
protected void onSubmit(AjaxRequestTarget target, Form
form){
//setResponsePage(new ScheduleEvent(event,
resources));
setResponsePage(ScheduleEvent.class);
}
});
the following fails
tester.clickLink("eventDetailsGroupBox:eventDetailsForm:submitLink",
false);
tester.assertRenderedPage(ScheduleEvent.class);
junit.framework.AssertionFailedError: expected:<ScheduleEvent> but
was:<EventDetails>
at
org.apache.wicket.util.tester.WicketTester.assertResult(WicketTester.java:575)
at
org.apache.wicket.util.tester.WicketTester.assertRenderedPage(WicketTester.java:522)
at
I have verified that
onSubmit(AjaxRequestTarget target, Form form)
is infact getting called. Any ideas?
jwcarman wrote:
>
> Can those arguments be put into PageParameters?
>
> On Thu, May 22, 2008 at 11:24 AM, nitinkc <[EMAIL PROTECTED]> wrote:
>>
>> That won't work for me b'cos I am also passing constructor arguments to
>> the
>> response Page.
>> So "new Page()" is actually "new Page(x,y)".
>>
>>
>> jwcarman wrote:
>>>
>>> You could use the bookmarkable version of setResponsePage(). That
>>> just says what type of page to instantiate.
>>>
>>>
>>> On Thu, May 22, 2008 at 10:51 AM, nitinkc <[EMAIL PROTECTED]>
>>> wrote:
>>>>
>>>> I am looking to unit test the following:
>>>>
>>>> form.add(new AjaxSubmitLink("submitLink"){
>>>> private static final long serialVersionUID =
>>>> 3239568065916265026L;
>>>>
>>>> @Override
>>>> protected void onSubmit(AjaxRequestTarget
>>>> target,
>>>> Form form){
>>>> setResponsePage(new ScheduleEvent(event,
>>>> resources));
>>>> }
>>>>
>>>> Calling
>>>> tester.clickLink("submitLink", true);
>>>>
>>>> instantiates the ScheduleEvent class. I want to avoid this as it forces
>>>> me
>>>> to mock appropriate parameters for ScheduleEvent. All I want to do is
>>>> check
>>>> that the rendered page is of type ScheduleEvent. ScheduleEvent class
>>>> will
>>>> have it's own unit tests where I want to address issues concerning it.
>>>> Has
>>>> anyone done this??
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/unit-testing-setRenderResponse%28new-Page%28%29%29-without-instantiation-of-Page-tp17405981p17405981.html
>>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/unit-testing-setRenderResponse%28new-Page%28%29%29-without-instantiation-of-Page-tp17405981p17406699.html
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
--
View this message in context:
http://www.nabble.com/unit-testing-setRenderResponse%28new-Page%28%29%29-without-instantiation-of-Page-tp17405981p17407117.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]