You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Nicolas Castin <ni...@skynet.be> on 2008/11/26 16:48:48 UTC

JUnit testing Image problem

Hello,

I am writing a JUnit test for a Wicket page containing some images added
dynamically.  My test needs to detect which images as been rendered, but the
org.apache.wicket.markup.html.image.Image class doesn't expose any method to
get it's resource.

I can extend the class to have a public method giving me the resource, but I
can't imagine that there aren't another way to do this.

Thanks for your help.

Nicolas Castin
Senior Software Developer
EURid.eu

Re: JUnit testing Image problem

Posted by mustaghattack <bi...@gmail.com>.
But image.getDefaultModel().getObject() will throw NPE because the default
model is, by default, set to null. The ResourceReference is not the default
model object.

Why does Image declare getImageResourceReference as protected and not public
?

Bruno



Nicolas Castin-3 wrote:
> 
> A solution has been found by mbosteels.dns.
> 
> When I did my tests, I discovered that lot of Wicket classes weren't
> implementing the equals() method, but ResourceReference do implement it. 
> If
> I set my Image using a ResourceReference, I can create an assertEquals
> statement in my JUnit test and compare the
> image.getDefaultModel().getObject() with an instance of ResourceReference
> I
> create in my test with the expected value.
> Have a good day
> On Thu, Nov 27, 2008 at 9:32 AM, Nicolas Castin
> <ni...@skynet.be>wrote:
> 
>> Hello,
>>
>> I am writing a JUnit test for a Wicket page containing some images added
>> dynamically.  My test needs to detect which images as been rendered, but
>> the
>> org.apache.wicket.markup.html.image.Image class doesn't expose any method
>> to
>> get it's resource.
>>
>> I can extend the class to have a public method giving me the resource,
>> but
>> I can't imagine that there aren't another way to do this.
>>
>> Thanks for your help.
>>
>> Nicolas Castin
>> Senior Software Developer
>> EURid.eu
>>
>>
> 
> 
> -- 
> Nicolas Castin
> Senior Software Developer
> EURid.eu
> 
> 

-- 
View this message in context: http://www.nabble.com/JUnit-testing-Image-problem-tp20703576p25423238.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: JUnit testing Image problem

Posted by Nicolas Castin <nc...@gmail.com>.
A solution has been found by mbosteels.dns.

When I did my tests, I discovered that lot of Wicket classes weren't
implementing the equals() method, but ResourceReference do implement it.  If
I set my Image using a ResourceReference, I can create an assertEquals
statement in my JUnit test and compare the
image.getDefaultModel().getObject() with an instance of ResourceReference I
create in my test with the expected value.
Have a good day
On Thu, Nov 27, 2008 at 9:32 AM, Nicolas Castin <ni...@skynet.be>wrote:

> Hello,
>
> I am writing a JUnit test for a Wicket page containing some images added
> dynamically.  My test needs to detect which images as been rendered, but the
> org.apache.wicket.markup.html.image.Image class doesn't expose any method to
> get it's resource.
>
> I can extend the class to have a public method giving me the resource, but
> I can't imagine that there aren't another way to do this.
>
> Thanks for your help.
>
> Nicolas Castin
> Senior Software Developer
> EURid.eu
>
>


-- 
Nicolas Castin
Senior Software Developer
EURid.eu