fix(接口测试): 修复mock匹配xml失败的缺陷

--bug=1040879 --user=王孝刚
【接口测试】Mockl-匹配规则为请求体xml,请求Mock地址时,请求体与匹配规则不匹配依然返回Mock响应
https://www.tapd.cn/55049933/s/1520575
This commit is contained in:
wxg0103 2024-05-24 15:41:22 +08:00 committed by Craftsman
parent af19dab80b
commit 8366bf33e3
1 changed files with 2 additions and 1 deletions

View File

@ -46,11 +46,12 @@ public class MockServerUtils {
try {
if (request instanceof ShiroHttpServletRequest shiroHttpServletRequest) {
List<String> contentTypeLists = List.of(MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE, MediaType.TEXT_XML_VALUE, MediaType.TEXT_PLAIN_VALUE);
if (StringUtils.equals(request.getContentType(), MediaType.APPLICATION_OCTET_STREAM_VALUE)) {
InputStream inputStream = shiroHttpServletRequest.getRequest().getInputStream();
byte[] binaryParams = inputStream.readAllBytes();
requestParam.setBinaryParamsObj(binaryParams);
} else if (StringUtils.equals(request.getContentType(), MediaType.APPLICATION_JSON_VALUE)) {
} else if (contentTypeLists.contains(request.getContentType())) {
String inputLine;
StringBuilder receiveData = new StringBuilder();
try (BufferedReader in = new BufferedReader(new InputStreamReader(