HTTP测试桩
2021-06-21 00:04
标签:bsp hash zha extend 分享 验证 ica ret tps 我们在对某个子系统进行性能测试的时候,可能会依赖外部系统,有的时候依赖的外部系统可能在现有的环境中没有,这个时候模拟桩就派上用场了。 准备工作: 1、 Tomcat 2、 json相关jar包: http://download.csdn.net/detail/zhangy0329/607838 3、 java完整代码,创建的工程没有包名 import java.io.IOException; import javax.servlet.ServletException; import net.sf.json.JSONObject; public class testEE extends HttpServlet { @Override resp.setCharacterEncoding("utf-8"); Map out = resp.getWriter(); } } 4、 导出为为class文件 在项目名称上右键Export>>General>>File System 5、 将导出class文件放在classes目录下 6、 配置web.xml 7、 启动tomcat并验证,如下图表示成功 HTTP测试桩 标签:bsp hash zha extend 分享 验证 ica ret tps 原文地址:http://www.cnblogs.com/perTest/p/7183764.html
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
doPost(req, resp);
}
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
if (null == req) {
return;
}
req.setCharacterEncoding("utf-8");
resp.setContentType("application/json; charset=utf-8");
PrintWriter out;
Map
map1.put("itemType", "S0");
map1.put("itemId", "201707151008");
map1.put("itemName", "型号");
map1.put("quantity", "5");
map.put("result", "200");
map.put("OrderItemVO", map1);
JSONObject json = JSONObject.fromObject(map);
out.println(json);
out.close();