On Sun, Nov 23, 2008 at 4:06 AM, Toby <[email protected]> wrote:
>
> Hi Folks,
>
> I've been using the CalendarService but have a few issues with mocking
> and type erasure. To try and mock a service in order to test my app,
> I'm forced to imposterise the CalendarService, GoogleService or
> Service classes (as they aren't interfaces). However, because of
> Java's lovely type erasure, I can't!
>
> That is to say when imposterising (using jmock2) the GoogleService
> class, it actually uses the method definition higher up the hierarchy,
> so although the CalendarService wants to say something like;
>
>  public CalendarEntry insert(URL feedUrl, CalendarEntry entry);
>
> the definition higher up the hierarchy is;
>
>  public <E extends BaseEntry<?>> E insert(URL feedUrl, E entry)
>
> So the imposteriser has no way on knowing that it should be returning
> a CalendarEntry and not a BaseEntry. So, I'll get class cast
> exceptions during my testing... phew.
>
> java.lang.ClassCastException: com.google.gdata.data.BaseEntry$
> $EnhancerByCGLIB$$241815eb cannot be cast to
> com.google.gdata.data.calendar.CalendarEntry
>
>
> To get round this I was thinking of having some interface which
> defines the services that my application will use and wrapping the
> google services. However, I was thinking its a bit naff to have to
> create my own layer on top of an API like this.
>
> Has anyone else had any experience with this kind of problem, trying
> to expose the gdata to mocking? Any comments appreciated :)
>
> Cheers,
> Toby

Looks like nobody replied, but if you do come up with any good
solutions, be sure to post them to the group.

-- 
Trevor Johns

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Calendar Data API" group.
To post to this group, send email to 
[email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-calendar-help-dataapi?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to