}
public void testAlreadyInitialisedAuthManagersAreClosedWhenAnotherAuthManagerInitFails() throws Exception
{
AuthenticationManager authManger1 = mock(MockAuthenticationManager1.class);
AuthenticationManagerFactory authManager1Factory = newMockFactoryProducing(authManger1);
AuthenticationManager authManager2 = mock(MockAuthenticationManager2.class);
AuthenticationManagerFactory authManagerFactory2 = newMockFactoryProducing(authManager2);
List<AuthenticationManagerFactory> factoryList = Arrays.asList(authManager1Factory, authManagerFactory2);
when(_authManagerServiceLoader.atLeastOneInstanceOf(AuthenticationManagerFactory.class)).thenReturn(factoryList);
doThrow(new RuntimeException("mock auth manager 2 init exception")).when(authManager2).initialise();