Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

EasyMock - How to mock the cast operation  RSS feed

 
Girish kamath
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I mock the cast operation.
I have an cast operation on a dependent object , which will cast to another dependent object like

SqlMapClient sqlMapClient;
SqlMapClientImpl sqlMapClientImpl = (SqlMapClientImpl) sqlMapClient

I' mocking both the dependent clesses i.e SqlMapClient and SqlMapClientImpl .But I need to know how to mock cast using EasyMock.

Any help would be appreciated.
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36406
454
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Girish,
Welcome to JavaRanch!

You can't mock the cast. What you can do is cast to something more generic 9an interface) so both the concrete class and mock can be cast to it.
 
Jeff Storey
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could also use the EasyMock class extensions to make your mock an instanceof SqlMapClientImpl (since I assume SqlMapClientImpl implements the SqlMapClient interface).
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!