private void setupMocksWithInitialiser() throws Exception
{
_principalDatabase = mock(PrincipalDatabase.class);
UsernamePasswordInitialiser usernamePasswordInitialiser = new UsernamePasswordInitialiser()
{
@Override
public Class<? extends SaslServerFactory> getServerFactoryClassForJCARegistration()
{
return MySaslServerFactory.class;
}
@Override
public String getMechanismName()
{
return MOCK_MECH_NAME;
}
};
Map<String,AuthenticationProviderInitialiser> initialisers = new HashMap<String, AuthenticationProviderInitialiser>();
initialisers.put(MOCK_MECH_NAME, usernamePasswordInitialiser);
when(_principalDatabase.getMechanisms()).thenReturn(initialisers);
usernamePasswordInitialiser.initialise(_principalDatabase);
_manager = new PrincipalDatabaseAuthenticationManager(_principalDatabase);
_manager.initialise();
}