« Return to Thread: ClassCastException with generic method

Re: ClassCastException with generic method

by Steve Freeman-2 :: Rate this Message:

Reply to Author | View in Thread

Ah, just seen it.

your first argument is a /class/, not an instance.

Can you try:

one(jaxbUnmarshaller).unmarshal(with(equalTo(Issue.class)),  
with(any(String.class)));

Or something like that?

S.

On 11 May 2009, at 14:41, Jeudy, Guillaume wrote:

> I'm trying to test a generic method. Is that possible with jmock2?
>
> expectations code:
>
> this.mockContext.checking(new Expectations() {{
>   one(jaxbUnmarshaller).unmarshal(with(Issue.class),  
> with(any(String.class)));
>  }});
>
> I tried:  one(jaxbUnmarshaller).unmarshal(with(any(Class.class),  
> with(any(String.class))) but that also fails.
>
> interface:
>
> public interface JAXBUnmarshaller {
> <T> T unmarshal(Class<T> expectedType, String text) throws  
> JAXBException;
> }


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


 « Return to Thread: ClassCastException with generic method