AbstractLoginModule implements LoginModule { protected void onError() { LoginModuleMonitor lmm = getLoginModuleMonitor(); if (lmm != null) { lmm.loginError(); } }  @Override void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState, Map<String, ?> options); @Override boolean logout(); @Override boolean abort(); static final String SHARED_KEY_CREDENTIALS; static final String SHARED_KEY_LOGIN_NAME; static final String SHARED_KEY_ATTRIBUTES; static final String SHARED_KEY_PRE_AUTH_LOGIN; }
@Test public void testOnError() { LoginModuleStats stats = newLoginModuleStats(); CallbackHandler cbh = callbacks -> { for (Callback cb : callbacks) { if (cb instanceof RepositoryCallback) { ((RepositoryCallback) cb).setLoginModuleMonitor(stats); } } }; AbstractLoginModule lm = initLoginModule(cbh); assertTrue(lm.getLoginModuleMonitor() instanceof LoginModuleStats); lm.onError(); assertEquals(1, stats.getLoginErrors()); }