parent
47fb30ad1d
commit
3fc8708c51
|
@ -64,12 +64,16 @@ public class MockScriptEngineUtils {
|
||||||
preScriptBuffer.append("Map vars = new HashMap();\n");
|
preScriptBuffer.append("Map vars = new HashMap();\n");
|
||||||
preScriptBuffer.append("vars.put(\"address\",\"" + url + "\");\n");
|
preScriptBuffer.append("vars.put(\"address\",\"" + url + "\");\n");
|
||||||
//写入请求头
|
//写入请求头
|
||||||
|
if (headerMap != null) {
|
||||||
for (Map.Entry<String, String> headEntry : headerMap.entrySet()) {
|
for (Map.Entry<String, String> headEntry : headerMap.entrySet()) {
|
||||||
String headerKey = headEntry.getKey();
|
String headerKey = headEntry.getKey();
|
||||||
String headerValue = headEntry.getValue();
|
String headerValue = headEntry.getValue();
|
||||||
preScriptBuffer.append("vars.put(\"header." + headerKey + "\",\"" + headerValue + "\");\n");
|
preScriptBuffer.append("vars.put(\"header." + headerKey + "\",\"" + headerValue + "\");\n");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//写入body参数
|
//写入body参数
|
||||||
|
if (requestMockParams != null) {
|
||||||
if (requestMockParams.getBodyParams() != null) {
|
if (requestMockParams.getBodyParams() != null) {
|
||||||
if (requestMockParams.getBodyParams().size() == 1) {
|
if (requestMockParams.getBodyParams().size() == 1) {
|
||||||
//参数是jsonObject
|
//参数是jsonObject
|
||||||
|
@ -110,6 +114,7 @@ public class MockScriptEngineUtils {
|
||||||
preScriptBuffer.append("vars.put(\"rest." + key + "\",\"" + value + "\");\n");
|
preScriptBuffer.append("vars.put(\"rest." + key + "\",\"" + value + "\");\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return preScriptBuffer.toString();
|
return preScriptBuffer.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class TCPServicer {
|
||||||
MockApiUtils mockApiUtils = new MockApiUtils();
|
MockApiUtils mockApiUtils = new MockApiUtils();
|
||||||
boolean useScript = false;
|
boolean useScript = false;
|
||||||
if(respResultObj.containsKey("usePostScript")){
|
if(respResultObj.containsKey("usePostScript")){
|
||||||
useScript = responseObj.getBoolean("usePostScript");
|
useScript = respResultObj.getBoolean("usePostScript");
|
||||||
}
|
}
|
||||||
returnMsg = mockApiUtils.getResultByResponseResult(respResultObj.getJSONObject("body"),"",null,null,useScript);
|
returnMsg = mockApiUtils.getResultByResponseResult(respResultObj.getJSONObject("body"),"",null,null,useScript);
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,7 +150,6 @@ export default {
|
||||||
} else {
|
} else {
|
||||||
this.baseCodeTemplates = this.tcpCodeTemplates;
|
this.baseCodeTemplates = this.tcpCodeTemplates;
|
||||||
}
|
}
|
||||||
alert(JSON.stringify(this.baseCodeTemplates));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
,
|
,
|
||||||
|
|
Loading…
Reference in New Issue