当前位置:网站首页>EasyMock日记1[通俗易懂]
EasyMock日记1[通俗易懂]
2022-07-31 12:50:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
private PayController payController;
private HttpServletRequest request;
private User user;
private HttpSession session;
@Before
public void before(){
payController=new PayController();
user=new User();
user.setUsername("18350591915");
user.setUseNo("4f62f0e5516346748843df6131072ae0");
}
@Test
public void Testalipay_notify(){
request=EasyMock.createMock(HttpServletRequest.class);
session=EasyMock.createMock(HttpSession.class);
EasyMock.expect(request.getParameter("type")).andReturn("1");
EasyMock.expect(request.getParameter("money")).andReturn("1");
EasyMock.expect(request.getParameter("paymentId")).andReturn("1");
//EasyMock.expect((User)request.getSession().getAttribute("user")).andReturn(user);
//这句话不知道为什么不能实现``
EasyMock.expect(request.getSession()).andReturn(session);
EasyMock.expect(session.getAttribute("user")).andReturn(user);
EasyMock.replay(request);
assertNotNull(payController.recharge(null, request));
EasyMock.verify(request);
}
参考http://blog.csdn.net/chjttony/article/details/14522771[参考地址](http://blog.csdn.net/chjttony/article/details/14522771%20%E5%8F%82%E8%80%83%E5%8D%9A%E5%AE%A2easymock)发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/128637.html原文链接:https://javaforall.cn
边栏推荐
- Comparison of ipv4 and ipv6 (IPV4)
- CWE4.8 -- 2022年危害最大的25种软件安全问题
- A Week of Wonderful Content Sharing (Issue 14)
- Use IN List Population in Your JDBC Application to Avoid Cursor Cache Contention Issues
- 纷享销客罗旭对话元气森林黄晓枫:零售数字化的终点不是创新,而是数据
- 攻防演练丨赛宁红方管控平台走进广东三地 助力数字政府网络安全建设
- The cluster of safe mode
- 函数递归1.0
- 中望3D 2023正式发布,设计仿真制造一体化缩短产品开发周期
- centos7安装mysql5.7步骤(图解版)
猜你喜欢
随机推荐
行业案例 | 全面防护 赛宁助力能源工控安全建设
集群的安全模式
jmeter性能测试步骤入门(性能测试工具jmeter)
IDEA的database使用教程(使用mysql数据库)
Optimization of five data submission methods
Use docker to build mysql master-slave
The cluster of safe mode
查看Mysql数据库版本
alert(1) (haozi.me)靶场练习
榕树贷款GPU 硬件架构
函数的参数
亲测可用!!!WPF中遍历整个窗口的所有TextBox组件,对每个输入框做非空判断。
求一份常见Oracle故障模拟场景
深度学习基本概念
三相PWM整流器预测直接功率控制
NameNode (NN) and SecondaryNameNode (2NN) working mechanism
PyQt5快速开发与实战 9.7 UI层的自动化测试
kernel syscore
尚硅谷–MySQL–基础篇(P1~P95)
docker部署完mysql无法连接








