@Test
public void testAuthenticationUnknownUser() {

  expect(mockAuthPropsConfig.isAuthFileEnabled()).andReturn(true);
  expect(mockUserDetailsService.loadUserByUsername("principal")).andReturn(null);
  
  replay(mockAuthPropsConfig, mockUserDetailsService);
  
  Authentication authentication = new TestingAuthenticationToken("principal", "credentials");
  try {
    provider.authenticate(authentication);
    assertTrue("Should have thrown BadCredentialsException", false);
  } catch (BadCredentialsException e) {
    assertEquals("User not found.", e.getMessage());
  }
  
  verify(mockAuthPropsConfig, mockUserDetailsService);
}