easymcok - IDC资讯网_站长学院 - Java PHP Flex Python Ajax CSS 编程 开源 学习 总结 分享

easymcok

[ 2008-06-27 09:11 | by 草山湖 ]
模拟 request, response, session

HttpServletRequest request = createMock(HttpServletRequest.class);
HttpServletResponse response = createMock(HttpServletResponse.class);
HttpSession session = createMock(HttpSession.class);
reset(request);
reset(response);
reset(session);

expect(request.getMethod()).andReturn("POST").anyTimes();
expect(request.getQueryString()).andReturn("test").anyTimes();
expect(request.getContextPath()).andReturn("test").anyTimes();
expect(request.getHeader("add1")).andReturn("test").anyTimes();

replay(request);
replay(response);
replay(session);

参见:http://www.ibm.com/developerworks/cn/opensource/os-cn-easymock/index.html
编程语言 | 评论(0) | 引用(0) | 阅读(3577)