/** * 用户认证测试. * * <p>分别测试正确的用户与正确,空,错误的密码三种情况. */ @Test public void authUser() { EasyMock.expect(mockUserDao.countUserByLoginNamePassword("admin", "admin")).andReturn(1L); EasyMock.expect(mockUserDao.countUserByLoginNamePassword("admin", "errorPasswd")).andReturn(0L); control.replay(); assertEquals(true, accountManager.authenticate("admin", "admin")); assertEquals(false, accountManager.authenticate("admin", "")); assertEquals(false, accountManager.authenticate("admin", "errorPasswd")); }
@Before public void setUp() { accountManager = new AccountManager(); mockUserDao = control.createMock(UserDao.class); accountManager.setUserDao(mockUserDao); }