当前位置:网站首页>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
边栏推荐
猜你喜欢

centos7安装mysql5.7

Exploring Plain Vision Transformer Backbones for Object Detection Paper Reading Notes

串的基本概念与操作

SAP ABAP OData 服务如何支持 $filter (过滤)操作试读版

Optimization of five data submission methods

CentOS7 安装MySQL 图文详细教程

CentOS7 installation MySQL graphic detailed tutorial

使用docker搭建mysql主从

消息队列面试题(2022最新整理)

AMBA APB学习记录(AMBA 2.0)
随机推荐
Qt鼠标穿透
kernel syscore
手撕Verilog PWM呼吸灯
Using SQL Server FOR XML and FOR JSON syntax on other RDBMSs with jOOQ
CentOS7 —— yum安装mysql
Error EPERM operation not permitted, mkdir ‘Dsoftwarenodejsnode_cache_cacach两种解决办法
Flutter键盘可见性
Introduction to using NPM
五种数据提交方式的优化
alert(1) (haozi.me)靶场练习
深度学习基本概念
架构实战营|模块8
CentOS7 - yum install mysql
聊聊 SAP 产品 UI 上的消息显示机制
NameNode (NN) and SecondaryNameNode (2NN) working mechanism
The 2nd activity of the TOGAF10 Standard Reading Club continues wonderfully, and the highlights will be reviewed!
榕树贷款GPU 硬件架构
centos7安装mysql5.7步骤(图解版)
busybox之reboot命令流程分析
WPF中报错:“未将对象引用设置到对象的实例。”