Spring Boot 接口并发测试,开启多线程使用Http 请求并行测试接口来测试并发。
此处测试注册接口
http://localhost:8080/manage/app/user/register
测试项目代码未提交到Github,下面简单说明一下注册接口。
/**
* 用户注册
* @param baseResult
* @return
*/
@RequestMapping(value = "user/register" , produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
@ResponseBody
public BaseResult UserRegister(@RequestBody BaseResult baseResult){
customFile.info( "appId:"+ baseResult.getTreasureID()+"用户注册访问:" + baseResult.toString() );
return appUserService.userRegister(baseResult);
}
请求参数封装
public class BaseResult implements Serializable {
private static final long serialVersionUID = 3401781428101852075L;
private String ip;
/**
* appId
*/
private String treasureID;
/**
* 请求响应加密数据
*/
private String treasureData;
/**
* desKey
*/
private String treasureDESKey;
...
}
开启多线程通过Http 请求并行访问接口。
TransObjectByHttp: 请求数据 - {"treasureID":"402216352","treasureDESKey":"u+p50xk3Ak0sdCP2OfB144Vi/sBPl/UbXE0qVyYOoWopjky9Cj2TbfptQuFRAno8LrREdL43JQTI6IZR1bGT/tRBTAEySbMaSCqAKBMplRPCnJoF6hsux0oJ2o/dJW+q9MRmtdwOCVWjfsp25nrkCwt6TTbiYAmULWrkC/8Mwlk=","treasureData":"{\"userPhone\":\"15738539120\",\"userPassword\":\"1357ac90\",\"phoneCode\":\"666666\"}"}
TransObjectByHttp: 请求数据 - {"treasureID":"402216352","treasureDESKey":"u+p50xk3Ak0sdCP2OfB144Vi/sBPl/UbXE0qVyYOoWopjky9Cj2TbfptQuFRAno8LrREdL43JQTI6IZR1bGT/tRBTAEySbMaSCqAKBMplRPCnJoF6hsux0oJ2o/dJW+q9MRmtdwOCVWjfsp25nrkCwt6TTbiYAmULWrkC/8Mwlk=","treasureData":"{\"userPhone\":\"15738539120\",\"userPassword\":\"1357ac90\",\"phoneCode\":\"666666\"}"}
TransObjectByHttp: 请求数据 - {"treasureID":"402216352","treasureDESKey":"u+p50xk3Ak0sdCP2OfB144Vi/sBPl/UbXE0qVyYOoWopjky9Cj2TbfptQuFRAno8LrREdL43JQTI6IZR1bGT/tRBTAEySbMaSCqAKBMplRPCnJoF6hsux0oJ2o/dJW+q9MRmtdwOCVWjfsp25nrkCwt6TTbiYAmULWrkC/8Mwlk=","treasureData":"{\"userPhone\":\"15738539120\",\"userPassword\":\"1357ac90\",\"phoneCode\":\"666666\"}"}
TransObjectByHttp: 请求数据 - {"treasureID":"402216352","treasureDESKey":"u+p50xk3Ak0sdCP2OfB144Vi/sBPl/UbXE0qVyYOoWopjky9Cj2TbfptQuFRAno8LrREdL43JQTI6IZR1bGT/tRBTAEySbMaSCqAKBMplRPCnJoF6hsux0oJ2o/dJW+q9MRmtdwOCVWjfsp25nrkCwt6TTbiYAmULWrkC/8Mwlk=","treasureData":"{\"userPhone\":\"15738539120\",\"userPassword\":\"1357ac90\",\"phoneCode\":\"666666\"}"}
TransObjectByHttp: 请求数据 - {"treasureID":"402216352","treasureDESKey":"u+p50xk3Ak0sdCP2OfB144Vi/sBPl/UbXE0qVyYOoWopjky9Cj2TbfptQuFRAno8LrREdL43JQTI6IZR1bGT/tRBTAEySbMaSCqAKBMplRPCnJoF6hsux0oJ2o/dJW+q9MRmtdwOCVWjfsp25nrkCwt6TTbiYAmULWrkC/8Mwlk=","treasureData":"{\"userPhone\":\"15738539120\",\"userPassword\":\"1357ac90\",\"phoneCode\":\"666666\"}"}
TransObjectByHttp: 请求数据 - {"treasureID":"402216352","treasureDESKey":"u+p50xk3Ak0sdCP2OfB144Vi/sBPl/UbXE0qVyYOoWopjky9Cj2TbfptQuFRAno8LrREdL43JQTI6IZR1bGT/tRBTAEySbMaSCqAKBMplRPCnJoF6hsux0oJ2o/dJW+q9MRmtdwOCVWjfsp25nrkCwt6TTbiYAmULWrkC/8Mwlk=","treasureData":"{\"userPhone\":\"15738539120\",\"userPassword\":\"1357ac90\",\"phoneCode\":\"666666\"}"}
TransObjectByHttp: 请求数据 - {"treasureID":"402216352","treasureDESKey":"u+p50xk3Ak0sdCP2OfB144Vi/sBPl/UbXE0qVyYOoWopjky9Cj2TbfptQuFRAno8LrREdL43JQTI6IZR1bGT/tRBTAEySbMaSCqAKBMplRPCnJoF6hsux0oJ2o/dJW+q9MRmtdwOCVWjfsp25nrkCwt6TTbiYAmULWrkC/8Mwlk=","treasureData":"{\"userPhone\":\"15738539120\",\"userPassword\":\"1357ac90\",\"phoneCode\":\"666666\"}"}
TransObjectByHttp: 请求数据 - {"treasureID":"402216352","treasureDESKey":"u+p50xk3Ak0sdCP2OfB144Vi/sBPl/UbXE0qVyYOoWopjky9Cj2TbfptQuFRAno8LrREdL43JQTI6IZR1bGT/tRBTAEySbMaSCqAKBMplRPCnJoF6hsux0oJ2o/dJW+q9MRmtdwOCVWjfsp25nrkCwt6TTbiYAmULWrkC/8Mwlk=","treasureData":"{\"userPhone\":\"15738539120\",\"userPassword\":\"1357ac90\",\"phoneCode\":\"666666\"}"}
TransObjectByHttp: 请求数据 - {"treasureID":"402216352","treasureDESKey":"u+p50xk3Ak0sdCP2OfB144Vi/sBPl/UbXE0qVyYOoWopjky9Cj2TbfptQuFRAno8LrREdL43JQTI6IZR1bGT/tRBTAEySbMaSCqAKBMplRPCnJoF6hsux0oJ2o/dJW+q9MRmtdwOCVWjfsp25nrkCwt6TTbiYAmULWrkC/8Mwlk=","treasureData":"{\"userPhone\":\"15738539120\",\"userPassword\":\"1357ac90\",\"phoneCode\":\"666666\"}"}
TransObjectByHttp: 请求数据 - {"treasureID":"402216352","treasureDESKey":"u+p50xk3Ak0sdCP2OfB144Vi/sBPl/UbXE0qVyYOoWopjky9Cj2TbfptQuFRAno8LrREdL43JQTI6IZR1bGT/tRBTAEySbMaSCqAKBMplRPCnJoF6hsux0oJ2o/dJW+q9MRmtdwOCVWjfsp25nrkCwt6TTbiYAmULWrkC/8Mwlk=","treasureData":"{\"userPhone\":\"15738539120\",\"userPassword\":\"1357ac90\",\"phoneCode\":\"666666\"}"}
TransObjectByHttp: 返回数据 - {"ip":null,"treasureID":"402216352","treasureData":"{\"errCode\":\"100188\",\"errMsg\":\"当前用户已经注册过\",\"responseTime\":\"1536737371\",\"result\":{\"flag\":false}}","treasureDESKey":"u+p50xk3Ak0sdCP2OfB144Vi/sBPl/UbXE0qVyYOoWopjky9Cj2TbfptQuFRAno8LrREdL43JQTI6IZR1bGT/tRBTAEySbMaSCqAKBMplRPCnJoF6hsux0oJ2o/dJW+q9MRmtdwOCVWjfsp25nrkCwt6TTbiYAmULWrkC/8Mwlk="}
TransObjectByHttp: 返回数据 - {"ip":null,"treasureID":"402216352","treasureData":"{\"errCode\":\"100188\",\"errMsg\":\"当前用户已经注册过\",\"responseTime\":\"1536737371\",\"result\":{\"flag\":false}}","treasureDESKey":"u+p50xk3Ak0sdCP2OfB144Vi/sBPl/UbXE0qVyYOoWopjky9Cj2TbfptQuFRAno8LrREdL43JQTI6IZR1bGT/tRBTAEySbMaSCqAKBMplRPCnJoF6hsux0oJ2o/dJW+q9MRmtdwOCVWjfsp25nrkCwt6TTbiYAmULWrkC/8Mwlk="}
TransObjectByHttp: 返回数据 - {"ip":null,"treasureID":"402216352","treasureData":"{\"errCode\":\"100188\",\"errMsg\":\"当前用户已经注册过\",\"responseTime\":\"1536737371\",\"result\":{\"flag\":false}}","treasureDESKey":"u+p50xk3Ak0sdCP2OfB144Vi/sBPl/UbXE0qVyYOoWopjky9Cj2TbfptQuFRAno8LrREdL43JQTI6IZR1bGT/tRBTAEySbMaSCqAKBMplRPCnJoF6hsux0oJ2o/dJW+q9MRmtdwOCVWjfsp25nrkCwt6TTbiYAmULWrkC/8Mwlk="}
TransObjectByHttp: 返回数据 - {"ip":null,"treasureID":"402216352","treasureData":"{\"errCode\":\"100188\",\"errMsg\":\"当前用户已经注册过\",\"responseTime\":\"1536737371\",\"result\":{\"flag\":false}}","treasureDESKey":"u+p50xk3Ak0sdCP2OfB144Vi/sBPl/UbXE0qVyYOoWopjky9Cj2TbfptQuFRAno8LrREdL43JQTI6IZR1bGT/tRBTAEySbMaSCqAKBMplRPCnJoF6hsux0oJ2o/dJW+q9MRmtdwOCVWjfsp25nrkCwt6TTbiYAmULWrkC/8Mwlk="}
TransObjectByHttp: 返回数据 - {"ip":null,"treasureID":"402216352","treasureData":"{\"errCode\":\"100188\",\"errMsg\":\"当前用户已经注册过\",\"responseTime\":\"1536737371\",\"result\":{\"flag\":false}}","treasureDESKey":"u+p50xk3Ak0sdCP2OfB144Vi/sBPl/UbXE0qVyYOoWopjky9Cj2TbfptQuFRAno8LrREdL43JQTI6IZR1bGT/tRBTAEySbMaSCqAKBMplRPCnJoF6hsux0oJ2o/dJW+q9MRmtdwOCVWjfsp25nrkCwt6TTbiYAmULWrkC/8Mwlk="}
TransObjectByHttp: 返回数据 - {"ip":null,"treasureID":"402216352","treasureData":"{\"errCode\":\"100188\",\"errMsg\":\"当前用户已经注册过\",\"responseTime\":\"1536737371\",\"result\":{\"flag\":false}}","treasureDESKey":"u+p50xk3Ak0sdCP2OfB144Vi/sBPl/UbXE0qVyYOoWopjky9Cj2TbfptQuFRAno8LrREdL43JQTI6IZR1bGT/tRBTAEySbMaSCqAKBMplRPCnJoF6hsux0oJ2o/dJW+q9MRmtdwOCVWjfsp25nrkCwt6TTbiYAmULWrkC/8Mwlk="}
TransObjectByHttp: 返回数据 - {"ip":null,"treasureID":"402216352","treasureData":"{\"errCode\":\"100188\",\"errMsg\":\"当前用户已经注册过\",\"responseTime\":\"1536737371\",\"result\":{\"flag\":false}}","treasureDESKey":"u+p50xk3Ak0sdCP2OfB144Vi/sBPl/UbXE0qVyYOoWopjky9Cj2TbfptQuFRAno8LrREdL43JQTI6IZR1bGT/tRBTAEySbMaSCqAKBMplRPCnJoF6hsux0oJ2o/dJW+q9MRmtdwOCVWjfsp25nrkCwt6TTbiYAmULWrkC/8Mwlk="}
TransObjectByHttp: 返回数据 - {"ip":null,"treasureID":"402216352","treasureData":"{\"errCode\":\"100188\",\"errMsg\":\"当前用户已经注册过\",\"responseTime\":\"1536737371\",\"result\":{\"flag\":false}}","treasureDESKey":"u+p50xk3Ak0sdCP2OfB144Vi/sBPl/UbXE0qVyYOoWopjky9Cj2TbfptQuFRAno8LrREdL43JQTI6IZR1bGT/tRBTAEySbMaSCqAKBMplRPCnJoF6hsux0oJ2o/dJW+q9MRmtdwOCVWjfsp25nrkCwt6TTbiYAmULWrkC/8Mwlk="}
TransObjectByHttp: 返回数据 - {"ip":null,"treasureID":"402216352","treasureData":"{\"errCode\":\"100188\",\"errMsg\":\"当前用户已经注册过\",\"responseTime\":\"1536737371\",\"result\":{\"flag\":false}}","treasureDESKey":"u+p50xk3Ak0sdCP2OfB144Vi/sBPl/UbXE0qVyYOoWopjky9Cj2TbfptQuFRAno8LrREdL43JQTI6IZR1bGT/tRBTAEySbMaSCqAKBMplRPCnJoF6hsux0oJ2o/dJW+q9MRmtdwOCVWjfsp25nrkCwt6TTbiYAmULWrkC/8Mwlk="}
TransObjectByHttp: 返回数据 - {"ip":null,"treasureID":"402216352","treasureData":"{\"errCode\":\"100188\",\"errMsg\":\"当前用户已经注册过\",\"responseTime\":\"1536737371\",\"result\":{\"flag\":false}}","treasureDESKey":"u+p50xk3Ak0sdCP2OfB144Vi/sBPl/UbXE0qVyYOoWopjky9Cj2TbfptQuFRAno8LrREdL43JQTI6IZR1bGT/tRBTAEySbMaSCqAKBMplRPCnJoF6hsux0oJ2o/dJW+q9MRmtdwOCVWjfsp25nrkCwt6TTbiYAmULWrkC/8Mwlk="}