Eugeny Shchelkanov
unread,Oct 12, 2011, 10:33:15 AM10/12/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mockito
My situation is: I am loading an OSGi bundle to Equinox, loading a
class from bundle and I want to test it. I need to mock a class so
that bundle's class will accept it. I can't use a class from my
sources because it will not be the same as bundle's class. Must be
confusing, so I will make an example.
Class MAIN uses class LOGIC which uses external resources, so I want
to mock it. I load dynamically (from OSGi bundle, using
Bundle.loadClass()) Class objects for MAIN and LOGIC. I am creating
mock for LOGIC.I can't cast dynamically created object to LOGIC: they
are loaded with different classloaders. I am getting a
ClassCastException. I can't write:
verify(mockLOGIC).method();
because mockLOGIC is of type Object and simply does not have this
method.
Can I somehow specify method name as a String? I did not find anything
similar in javadoc. If Mockito can't do this, can you suggest mocking
framework that can?
No refactoring possible, I am testing interaction with JCICS.