??EasyMock???е???????????EasyMoc
???????????? ???????[ 2013/7/11 14:13:17 ] ????????
?????????????????????????д???????????????????????????????????????????????????????TestCase?????д?Щassert?????????ɡ????????????????????????Java????дmain???????????????????????????仰????????????д????δ???????????е????????????????????????????????????????????????????????????е??????????????дSSH??????????????????????????DAO?????????????????????Щ???????????DAO???????????????????????????
?????????????????????????????????е???壬????????????????????????????
??????????????
????????????
???????????????
?????????????κε????????????
???????????ú?????????????
???????????????£?????????????????????????????У????????????????????????????????????????????????????е??????????????????????????????е???????????????????????????????????е???????ù滮?????????????
???????????????????????WebService?????????????????????????????????SOA??????????????????????е?????????????????????????????????????WebService??鷳??????????????????????????????????????е??????????WebService????????????????е??
???????????????????EasyMock??????????????????????????壬EasyMock???????????Easy?????Mock??????????????????????????У?EasyMock????????????????????????????????????????WebService?????????????????Mock???????record?????????????????????????????????replay????????????????????????????????????????????????????????????????verify????????????????У?Mock????????????record??ε??趨??????????????????????????????WebService??????????
???????WebService?????????????WSDL????????????Щ???????????stub class??stub class?????????ServiceClientBuilder?????ServiceClient?????ЩModel???????????ServiceClient????
??????????????У?????????????????????????
public interface ServiceClient {
public List<String> getGroupsByUser(String username);
}
??????????У?????????????????????????
public class UserDao {
private ServiceClient client;
public boolean validate(String username) {
List<String> groups = client.getGroupsByUser(username);
for (String group : groups) {
if (group.equals("admin")) {
return true;
}
}
return false;
}
/**
* Used by Unit Test and other injection work
* @param client
*/
public void setClient(ServiceClient client) {
this.client = client;
}
}
??????
???·???
??????????????????
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