A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
EasyMock - How to mock the cast operation
Joined: Sep 07, 2010
Sep 07, 2010 12:55:51
How can I mock the cast operation.
I have an cast operation on a dependent object , which will cast to another dependent object like
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.
author & internet detective
Joined: May 26, 2003
Sep 07, 2010 18:24:46
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.
How To Ask Questions The Smart Way
Blogging on Certs:
SCEA Part 1
Part 2 & 3
Core Spring 3
TOGAF part 1
Joined: Apr 07, 2007
Sep 08, 2010 22:20:00
You could also use the EasyMock class extensions to make your mock an instanceof SqlMapClientImpl (since I assume SqlMapClientImpl implements the SqlMapClient interface).
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
subject: EasyMock - How to mock the cast operation
how to skip execution of a line in a method..need help ranchers
newbie question on easyMocking the DataSource
Deprecated method SetReturnValue() in 2.4
How to write a class so that it can be mocked?
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014