当前位置:网站首页>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
边栏推荐
- 中望3D 2023正式发布,设计仿真制造一体化缩短产品开发周期
- Indoor real-time laser SLAM control method based on biological excitation neural network
- A Week of Wonderful Content Sharing (Issue 14)
- SAP 电商云 Spartacus SSR Optimization Engine 几处 timeout 的执行顺序
- MySQL面试八股文(2022最新整理)
- Anaconda安装labelImg图像标注软件
- Qt鼠标穿透
- JVM 运行时数据区与JMM 内存模型详解
- 关于我放弃考研这件事儿
- [CPU Design Practice] Simple Pipeline CPU Design
猜你喜欢
随机推荐
Flutter键盘可见性
分布式监视 Zabbix 和 Prometheus 到底怎么选?千万别用错了!
深圳某游戏研发公司每个工位都装监控,网友:堪比“坐牢”!
IDEA版Postman插件Restful Fast Request,细节到位,功能好用
Structural controllability of switched linear systems with symmetry constraints
chroot命令
A40i/T3 uboot启动时对PMU部分初始化
A Week of Wonderful Content Sharing (Issue 14)
[Shader] Shader official example [easy to understand]
sqlalchemy 判断一个array 类型的字段是否和一个array有至少一个一致的数据
线性表的基本概念
FastAPI 封装一个通用的response
初识QEMU
CentOS7 安装MySQL 图文详细教程
基本语法(二)
Encapsulation of conversion between Json and objects (Gson)
基于生物激励神经网络的室内实时激光SLAM控制方法
全动力学约束的机器人高效时间最优轨迹规划
Optimization of five data submission methods
dosbox基础使用[通俗易懂]


![LRU缓存[线性表 -> 链表 -> hash定位 -> 双向链表]](/img/ad/dd80541514d6fedde8c730218fdf5a.png)





