@Test public void authenticate_firstOneWorks() { String userName = "userName"; String password = "password"; Map<String, LdapAuthenticateService> ldapAuthServiceMap = getLdapAuthServiceMap(); expect(mockContextHolder.getAllBeansOfType(LdapAuthenticateService.class)).andReturn(ldapAuthServiceMap); expect(mockFirstService.authenticate(userName, password)).andReturn(Boolean.TRUE); replayAll(); Boolean authenticated = unit.authenticate(userName, password); verifyAll(); assertTrue(authenticated); }
public Boolean authenticate(String userName, String password) { Map<String, LdapAuthenticateService> ldapAuthServiceMap = getSpringContextHolder().getAllBeansOfType(LdapAuthenticateService.class); Boolean authenticated = Boolean.FALSE; for (Map.Entry<String, LdapAuthenticateService> ldapAuthService : ldapAuthServiceMap.entrySet()) { authenticated = ldapAuthService.getValue().authenticate(userName, password); if (authenticated) { break; } } return authenticated; }
LdapAuthenticateManager { public Boolean authenticate(String userName, String password) { Map<String, LdapAuthenticateService> ldapAuthServiceMap = getSpringContextHolder().getAllBeansOfType(LdapAuthenticateService.class); Boolean authenticated = Boolean.FALSE; for (Map.Entry<String, LdapAuthenticateService> ldapAuthService : ldapAuthServiceMap.entrySet()) { authenticated = ldapAuthService.getValue().authenticate(userName, password); if (authenticated) { break; } } return authenticated; } }
LdapAuthenticateManager { public Boolean authenticate(String userName, String password) { Map<String, LdapAuthenticateService> ldapAuthServiceMap = getSpringContextHolder().getAllBeansOfType(LdapAuthenticateService.class); Boolean authenticated = Boolean.FALSE; for (Map.Entry<String, LdapAuthenticateService> ldapAuthService : ldapAuthServiceMap.entrySet()) { authenticated = ldapAuthService.getValue().authenticate(userName, password); if (authenticated) { break; } } return authenticated; }  }
LdapAuthenticateManager { public Boolean authenticate(String userName, String password) { Map<String, LdapAuthenticateService> ldapAuthServiceMap = getSpringContextHolder().getAllBeansOfType(LdapAuthenticateService.class); Boolean authenticated = Boolean.FALSE; for (Map.Entry<String, LdapAuthenticateService> ldapAuthService : ldapAuthServiceMap.entrySet()) { authenticated = ldapAuthService.getValue().authenticate(userName, password); if (authenticated) { break; } } return authenticated; }  Boolean authenticate(String userName, String password); SpringContextHolder getSpringContextHolder(); void setSpringContextHolder(SpringContextHolder springContextHolder); }
LdapAuthenticateManager { public Boolean authenticate(String userName, String password) { Map<String, LdapAuthenticateService> ldapAuthServiceMap = getSpringContextHolder().getAllBeansOfType(LdapAuthenticateService.class); Boolean authenticated = Boolean.FALSE; for (Map.Entry<String, LdapAuthenticateService> ldapAuthService : ldapAuthServiceMap.entrySet()) { authenticated = ldapAuthService.getValue().authenticate(userName, password); if (authenticated) { break; } } return authenticated; }  Boolean authenticate(String userName, String password); SpringContextHolder getSpringContextHolder(); void setSpringContextHolder(SpringContextHolder springContextHolder);  }