I think because Java erases the type by the time it comes to us. In
this case you could write a custom action that took the class passed
into the call and uses it to create an instance. Not sure it's worth
the trouble, though.
S.
On 11 May 2009, at 14:59, Jeudy, Guillaume wrote:
> I'm not sure why in this case the return type can't be autodetected
> by JMock. In many other cases where the return value didn't matter I
> just omitted the will(returnValue()) expectation and it all worked
> fine.
>
> Regards,
> -Guillaume
>
> ________________________________
>
> From: Ignat Zapolsky [mailto:
izapolsky@...]
> Sent: Mon 5/11/2009 9:47 AM
> To:
user@...
> Subject: Re: [jmock-user] ClassCastException with generic method
>
>
> Hi Jeudy,,
>
> Have you tried to return object of expected type, e.g. instanceof
> Issue as result of
> one(jaxbUnmarshaller).unmarshal(with(Issue.class),
> with(any(String.class))); expectation ?
> Example:
>
> one(jaxbUnmarshaller).unmarshal(with(Issue.class),
> with(any(String.class)));
> will(returnValue(new Issue()));
>
>
> I recon that correct return type may not be detected by JMock
> automatically and it will just return new Object instead of new Issue.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email