Jul 312012
Trying to unit test some code that was to run inside Solr, I bumped into this:
Cannot mock/spy class org.apache.solr.core.SolrCore Mockito cannot mock/spy following: - final classes - anonymous classes - primitive types
Fortunately, there’s a simple solution: PowerMock. After adding the following two annotations to my test class definition (and the requisite Maven dependency declarations), everything just worked. No changes needed to the actual Mockito calls themselves. Sweet.
@RunWith(PowerMockRunner.class) @PrepareForTest( { SolrCore.class })