????????е????????Service?????
???????????? ???????[ 2015/5/28 14:37:45 ] ???????????????
????????Service?????Service??????Dao?????????Mock???Dao???ɡ??????????????????????????????????
????java????
????public interface IAccountService extends IBaseService{
????Account findAccountById(String id);
????Account findAccounByName(String name);
????void regist(Account account)throws ObjectExistsException;
????}
??????????????
????java????
????public void regist(Account account)throws ObjectExistsException{
????if(accountDao.findAccounByName(account.getName())!=null)
????throw new ObjectExistsException("User's name is exists!");
????accountDao.save(account);
????}
???????????
????java????
????protected void setUp()throws Exception{
????control=MockControl.createControl(IAccountDao.class);
????accountDao=(IAccountDao)control.getMock();
????as=new AccountService();
????as.setAccountDao(accountDao);
????}
????public void testFindAccountByName(){
????String name="wuhua";
????accountDao.findAccounByName(name);
????Account a=new Account("wuhua");
????a.setId(name);
????control.setReturnValue(a);
????control.replay();
????Account at=as.findAccounByName(name);
????Assert.assertEquals(name??at.getId());
????Assert.assertEquals(a??at);
????control.verify();
????}
???????????????????????????name??"wuhua";
??????????Dao???????
???????????巵???????????????
????????????????????ж????????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11