@Test
public void testAuthenticationSuccessful() {

  List<GrantedAuthority> grantedAuths = Arrays.<GrantedAuthority>asList(new SimpleGrantedAuthority("ROLE_USER"));
  User user = new User("principal", CommonUtil.encryptPassword("principal", "credentials"), grantedAuths);
  
  expect(mockAuthPropsConfig.isAuthFileEnabled()).andReturn(true);
  expect(mockUserDetailsService.loadUserByUsername("principal")).andReturn(user);
  
  replay(mockAuthPropsConfig, mockUserDetailsService);
  
  Authentication authentication = new TestingAuthenticationToken("principal", "credentials");
  
  Authentication authenticationResult = provider.authenticate(authentication);
  assertEquals("principal", authenticationResult.getName());
  assertEquals(CommonUtil.encryptPassword("principal", "credentials"), authenticationResult.getCredentials());
  assertEquals(1, authenticationResult.getAuthorities().size());
  assertEquals(new SimpleGrantedAuthority("ROLE_USER"), authenticationResult.getAuthorities().iterator().next());
  
  verify(mockAuthPropsConfig, mockUserDetailsService);
}