I’m using mockito to test a legacy JAAS/LDAP login module.
The javax.security.auth.callback.CallbackHandler interface defines the function:
void handle(javax.security.auth.callback.Callback[] callbacks)
I’m expecting callbacks to contain a NameCallback, which is the object that needs to be manipulated to pass the test.
Is there a way to mock this effectively, or would I be better off with a stubbed implementation of CallbackHandler?
For functions returning
void, use doAnswer()And an
Answerthat performs the interception must go in as the parameter todoAnswer, e.g. as an anonymous class:In this case
argswill be the arrayCallback[]!