If what you want to test is some specific class implementing the QueueManager
interface, then a solution is simply to instantiate the class directly in the test, rather than using Spring for that.
The reason for the exception is that Spring actually creates a proxy class instance for the queueManager
field, intended to decorate the real implementation (the proxy object delegates every method call to another object, which would be an instance of an application class actually implementing the QueueManager
interface). The proxy class does not contain a field named "dataLogManager", so that's why Deencapsulation.setField(...)
can't find it.
If the first solution I mentioned is not applicable, you can still let Spring do the instantiation, provided it also inject the fields inside the queueManager
object. To mock the class implementing DataLogManager
(and other interfaces), use @Capturing
instead of (or in addition to) @Mocked
; this will instruct JMockit to extend mocking to all implementation classes.