Java – how do I easymock actors?
How can I simulate an actor's performance
sqlMapClient sqlMapClient; sqlMapClientImpl sqlMapClientImpl = (sqlMapClientImpl) sqlMapClient
I'm laughing at the mantra of dependency, sqlmapclient and sqlmapclientimpl But I need to know how to use easymock for analog conversion
Any help will be greatly appreciated
Solution
You cannot simulate a cast because it does not result in a method call to an object
Instead, use the easymock class extension to simulate the sqlmapclientimpl class and pass a reference to the simulation to the class that accepts sqlmapclient to sqlmapclientimpl
Note, however, that performing a similar down conversion in code is a code smell If your production code is performing a downward conversion to the interface that implements the class, you will lose all the flexibility to use the interface It may actually be worse than not using interfaces at all, because it looks like your class depends on interfaces and can be used for any implementation, but in fact your class depends on a specific implementation