Servlet测试的虚拟请求响应(Dummy Request Response for Servlet testing)

编程入门 行业动态 更新时间:2024-10-09 22:21:25
Servlet测试的虚拟请求响应(Dummy Request Response for Servlet testing)

如何为Servlet测试创建虚拟请求和响应。我阅读了关于Apache Jkarta Cactus项目的内容,但不想详细说明。 我们是否可以构造一个虚拟请求响应并将其传递给do()方法(Ofcourse构造的请求将具有URL和请求参数,但是如何构造这种虚拟请求)?

并且也希望junit不依赖于Apache(应该独立于它运行)。

How to Create a Dummy Request and Response for Servlet Testing.I read about the Apache Jkarta Cactus Project but do not want to go in that much details. Can we just construct a dummy request response and pass it to doGet() method (Ofcourse the request constructed would have a URL and request parameters, but how to construct such dummy request)?

and also want no dependency of junit on Apache(should run independent of it).

最满意答案

看看MockHTTPServletRequest(),我认为它会起作用。 这里是你可以阅读的链接。

Look into MockHTTPServletRequest(), I think its going to work. Here is the link which you can read.

更多推荐

本文发布于:2023-08-06 23:39:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1457317.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:测试   Dummy   Servlet   testing   Response

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!