mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-11-29 18:48:13 +08:00
fix(接口测试): 修复mock后置脚本解析参数失败的问题
This commit is contained in:
parent
0729f9c82f
commit
9bcc87934e
@ -132,6 +132,7 @@ public class MockScriptEngineUtils {
|
||||
if (StringUtils.equals(requestMockParams.getParamType(), MockRequestType.JSON.name())) {
|
||||
String jsonBody = requestMockParams.getRaw();
|
||||
jsonBody = StringUtils.replace(jsonBody, "\n", "");
|
||||
jsonBody = StringUtils.replace(jsonBody, "\r", "");
|
||||
jsonBody = StringUtils.replace(jsonBody, "\\", "\\\\");
|
||||
jsonBody = StringUtils.replace(jsonBody, "\"", "\\\"");
|
||||
preScriptBuffer.append("vars.put(\"body.json\",\"").append(jsonBody).append("\");\n");
|
||||
@ -139,11 +140,14 @@ public class MockScriptEngineUtils {
|
||||
String xmlRaw = requestMockParams.getRaw();
|
||||
xmlRaw = StringUtils.chomp(xmlRaw);
|
||||
xmlRaw = StringUtils.replace(xmlRaw, "\n", "");
|
||||
xmlRaw = StringUtils.replace(xmlRaw, "\r", "");
|
||||
xmlRaw = StringUtils.replace(xmlRaw, "\\", "\\\\");
|
||||
xmlRaw = StringUtils.replace(xmlRaw, "\"", "\\\"");
|
||||
preScriptBuffer.append("vars.put(\"body.xml\",\"").append(xmlRaw).append("\");\n");
|
||||
} else if (StringUtils.equals(requestMockParams.getParamType(), MockRequestType.RAW.name())) {
|
||||
String bodyRowString = requestMockParams.getRaw();
|
||||
bodyRowString = StringUtils.replace(bodyRowString, "\n", "");
|
||||
bodyRowString = StringUtils.replace(bodyRowString, "\r", "");
|
||||
bodyRowString = StringUtils.replace(bodyRowString, "\\", "\\\\").replace("\"", "\\\"");
|
||||
preScriptBuffer.append("vars.put(\"bodyRaw\",\"").append(bodyRowString).append("\");\n");
|
||||
}
|
||||
@ -209,6 +213,7 @@ public class MockScriptEngineUtils {
|
||||
String jsonRaw = requestMockParams.getRaw();
|
||||
jsonRaw = StringUtils.chomp(jsonRaw);
|
||||
jsonRaw = StringUtils.replace(jsonRaw, "\n", "");
|
||||
jsonRaw = StringUtils.replace(jsonRaw, "\r", "");
|
||||
jsonRaw = StringUtils.replace(jsonRaw, "\\", "\\\\");
|
||||
jsonRaw = StringUtils.replace(jsonRaw, "\"", "\\\"");
|
||||
preScriptBuffer.append("vars[\"body.json\"]=\"").append(jsonRaw).append("\";\n");
|
||||
@ -216,11 +221,14 @@ public class MockScriptEngineUtils {
|
||||
String xmlRaw = requestMockParams.getRaw();
|
||||
xmlRaw = StringUtils.chomp(xmlRaw);
|
||||
xmlRaw = StringUtils.replace(xmlRaw, "\n", "");
|
||||
xmlRaw = StringUtils.replace(xmlRaw, "\r", "");
|
||||
xmlRaw = StringUtils.replace(xmlRaw, "\\", "\\\\");
|
||||
xmlRaw = StringUtils.replace(xmlRaw, "\"", "\\\"");
|
||||
preScriptBuffer.append("vars[\"body.xml\"]=\"").append(xmlRaw).append("\";\n");
|
||||
} else if (StringUtils.equals(requestMockParams.getParamType(), MockRequestType.RAW.name())) {
|
||||
String bodyRowString = requestMockParams.getRaw();
|
||||
bodyRowString = StringUtils.replace(bodyRowString, "\n", "");
|
||||
bodyRowString = StringUtils.replace(bodyRowString, "\r", "");
|
||||
bodyRowString = StringUtils.replace(bodyRowString, "\\", "\\\\").replace("\"", "\\\"");
|
||||
preScriptBuffer.append("vars[\"bodyRaw\"]=\"").append(bodyRowString).append("\";\n");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user