fix(Mock测试): 解决Mock接口测试时部分rest参数无法匹配的缺陷
--bug=1009070 --user=宋天阳 【接口测试】mock测试,rest参数匹配失败 https://www.tapd.cn/55049933/s/1084084
This commit is contained in:
parent
463fa89850
commit
3d2e0362c8
|
@ -489,14 +489,7 @@ public class MockApiUtils {
|
|||
return returnJson;
|
||||
} else if (StringUtils.startsWithIgnoreCase(request.getContentType(), "text/xml")) {
|
||||
String xmlString = readXml(request);
|
||||
|
||||
org.json.JSONObject xmlJSONObj = XML.toJSONObject(xmlString);
|
||||
String jsonStr = xmlJSONObj.toString();
|
||||
JSONObject object = null;
|
||||
try {
|
||||
object = JSONObject.parseObject(jsonStr);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
JSONObject object = XMLUtils.XmlToJson(xmlString);
|
||||
return object;
|
||||
} else if (StringUtils.startsWithIgnoreCase(request.getContentType(), "application/x-www-form-urlencoded")) {
|
||||
JSONObject object = new JSONObject();
|
||||
|
|
|
@ -365,12 +365,14 @@ public class MockConfigService {
|
|||
if (jsonObject.containsKey("name") && jsonObject.containsKey("value")) {
|
||||
String headerName = jsonObject.getString("name");
|
||||
String headerValue = jsonObject.getString("value");
|
||||
if(StringUtils.isNotEmpty(headerName)){
|
||||
if (!requestHeaderMap.containsKey(headerName) || !StringUtils.equals(requestHeaderMap.get(headerName), headerValue)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (expectParamsObj.containsKey("body")) {
|
||||
JSONObject expectBodyObject = expectParamsObj.getJSONObject("body");
|
||||
|
|
Loading…
Reference in New Issue