File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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.
OCA 8 book
How To Ask Questions The Smart Way
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).
I agree. Here's the link:
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-2015