You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by pokkie <po...@gmail.com> on 2007/09/12 10:51:44 UTC

Unit testing ListView

I am trying to write a test case for my listView that contains some links.
When the user clicks on 
a link, a certain action should be performed, and it is for this action that
I wish to write a test case for. 

I can get a handle on the ListView by using the
wicketTester.getLastRenderedPage().get("pathToListView");, 
but the problem then is that the listView isn't populated. I thought about
extracting the above method call, 
into a variable, so that the listView is returned, i.e. 

----
MyListView listView =
(MyListView)wicketTester.getLastRenderedPage().get("pathToListView");

// Populate the listView with a model object so that it will populate the
ListView
listView.setModelObject(new ModelObject());

// Create a new ListItem so that the listView can be populated
ListItem listItem = new ListItem(0, listView.getModel());

// Populate the listView with the listItem
listView.populateItem(listItem);

// Execute ajax event
wicketTester.executeAjaxEvent("pathToLinkOnListView","onclick");
----

Would be greatful if somebody could advise me on how to proceed. 

Thanks, 

-- pokkie






-- 
View this message in context: http://www.nabble.com/Unit-testing-ListView-tf4427848.html#a12631265
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Unit testing ListView

Posted by younggun <yo...@gmail.com>.


pokkie wrote:
> 
> I am trying to write a test case for my listView that contains some links.
> When the user clicks on 
> a link, a certain action should be performed, and it is for this action
> that I wish to write a test case for. 
> 
> I can get a handle on the ListView by using the
> wicketTester.getLastRenderedPage().get("pathToListView");, 
> but the problem then is that the listView isn't populated. I thought about
> extracting the above method call, 
> into a variable, so that the listView is returned, i.e. 
> 
> ----
> MyListView listView =
> (MyListView)wicketTester.getLastRenderedPage().get("pathToListView");
> 
> // Populate the listView with a model object so that it will populate the
> ListView
> listView.setModelObject(new ModelObject());
> 
> // Create a new ListItem so that the listView can be populated
> ListItem listItem = new ListItem(0, listView.getModel());
> 
> // Populate the listView with the listItem
> listView.populateItem(listItem);
> 
> // Execute ajax event
> wicketTester.executeAjaxEvent("pathToLinkOnListView","onclick");
> ----
> 
> Would be greatful if somebody could advise me on how to proceed. 
> 
> Thanks, 
> 
> -- pokkie
> 
> 
> 
> 
> 
> 
> 

Please use: ListItem listItem = (ListItem) listView.get(0); to get the
ListItem, then you can go ahead.
-- 
View this message in context: http://www.nabble.com/Unit-testing-ListView-tp12631265p21157383.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Unit testing ListView

Posted by Eelco Hillenius <ee...@gmail.com>.
On 9/12/07, pokkie <po...@gmail.com> wrote:
>
> I am trying to write a test case for my listView that contains some links.
> When the user clicks on
> a link, a certain action should be performed, and it is for this action that
> I wish to write a test case for.
>
> I can get a handle on the ListView by using the
> wicketTester.getLastRenderedPage().get("pathToListView");,
> but the problem then is that the listView isn't populated. I thought about
> extracting the above method call,
> into a variable, so that the listView is returned, i.e.
>
> ----
> MyListView listView =
> (MyListView)wicketTester.getLastRenderedPage().get("pathToListView");
>
> // Populate the listView with a model object so that it will populate the
> ListView
> listView.setModelObject(new ModelObject());
>
> // Create a new ListItem so that the listView can be populated
> ListItem listItem = new ListItem(0, listView.getModel());
>
> // Populate the listView with the listItem
> listView.populateItem(listItem);
>
> // Execute ajax event
> wicketTester.executeAjaxEvent("pathToLinkOnListView","onclick");

Why isn't it populated though? I don't use WicketTester much, but I
would expect the lastRendered page to have the listview intact as it
rendered. Only when it starts a new render are items removed. For
which btw you can also use setReuseItems(true).

Eelco

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org