EasyMock日记1[通俗易懂]

privatePayControllerpayController;privateHttpServletRequestrequest;privateUseruser;privateHttpSessionsession;@Beforepublicvoidbefore(){payController=newPayController();user=ne

大家好,又见面了,我是你们的朋友全栈君。

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)
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/128637.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

  • React 时间控件

    React 时间控件使用bootstrap的datetimepicker安装:npminstallreact-bootstrap-datetimepicker使用bootstrap的datetime安装:npminstall–savereact-datetime若使用中文,还需要安装moment,这样datetime插件中的locale属性(控制语言)才能够正常使用:安装moment:npminstal

  • 分页 模糊查询「建议收藏」

    分页 模糊查询「建议收藏」一、所有的web项目都会用到分页显示和模糊查询,对于有些人不知道该怎么写二、今天我用springMVC和myBatis写的分页和模糊分享给大家,不喜勿喷三、数据库是mysql四、其实写分页就是新建一个分页的类,定义页码每页数量共几页当前页数总数量五、判断多少页,获取总数量除以每页显示的数量,有余数+1页六、sql语句就是用…

  • laravel中跟据某个特定顺序去排序查出来的数据:FIND_IN_SET

    laravel中跟据某个特定顺序去排序查出来的数据:FIND_IN_SET

    2021年11月10日
  • JSONObject获取JSONArray转JSONObject获取某个属性值

    JSONObject获取JSONArray转JSONObject获取某个属性值StringhttpPost4Instream=http.httpPost4InstreamJSONObjectjsonbject=JSONObject.fromObject(httpPost4Instream);JSONArrayjsonArray=jsonbject.getJSONArray("stores");Stringstring=jsonArray.get…

  • linux启动nginx命令_linuxzip解压命令

    linux启动nginx命令_linuxzip解压命令1,首先找到nginx的安装目录whichnginx会找到对应的目录,如图2,查看进程是否存在ps-ef|grepnginx3,杀死进程kill-QUIT1282强制停止kill-912824,进入到nginx的sbin目录,启动nginxcd/usr/local/nginx/sbin/./nginx./nginx-sstop./nginx-squit./nginx-sreload4,但是上面这个..

  • .net mysql transactionscope_C#中的事务TransactionScope

    .net mysql transactionscope_C#中的事务TransactionScopeTransactionOptionstransactionOption=newTransactionOptions();//设置事务隔离级别transactionOption.IsolationLevel=System.Transactions.IsolationLevel.Serializable;//设置事务超时时间为60秒transactionOption.Timeout=new…

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号