fix (接口自动化): 修复引用步骤执行问题
This commit is contained in:
parent
99ca5a6e08
commit
9636a37199
|
@ -72,7 +72,7 @@ public class MsJSR223Processor extends MsTestElement {
|
|||
processor.setName(this.getName() + DelimiterConstants.SEPARATOR.toString() + name);
|
||||
}
|
||||
processor.setProperty("MS-ID", this.getId());
|
||||
processor.setProperty("MS-RESOURCE-ID", this.getResourceId());
|
||||
processor.setProperty("MS-RESOURCE-ID", this.getResourceId()+ "_" + this.getIndex());
|
||||
List<String> id_names = new LinkedList<>();
|
||||
this.getScenarioSet(this, id_names);
|
||||
processor.setProperty("MS-SCENARIO", JSON.toJSONString(id_names));
|
||||
|
|
|
@ -244,7 +244,7 @@ public class MsJDBCPostProcessor extends MsTestElement {
|
|||
jdbcPostProcessor.setProperty(TestElement.TEST_CLASS, JDBCPostProcessor.class.getName());
|
||||
jdbcPostProcessor.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI"));
|
||||
jdbcPostProcessor.setProperty("MS-ID", this.getId());
|
||||
jdbcPostProcessor.setProperty("MS-RESOURCE-ID", this.getResourceId());
|
||||
jdbcPostProcessor.setProperty("MS-RESOURCE-ID", this.getResourceId()+ "_" + this.getIndex());
|
||||
List<String> id_names = new LinkedList<>();
|
||||
this.getScenarioSet(this, id_names);
|
||||
jdbcPostProcessor.setProperty("MS-SCENARIO", JSON.toJSONString(id_names));
|
||||
|
|
|
@ -244,7 +244,7 @@ public class MsJDBCPreProcessor extends MsTestElement {
|
|||
jdbcPreProcessor.setProperty(TestElement.TEST_CLASS, JDBCPreProcessor.class.getName());
|
||||
jdbcPreProcessor.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI"));
|
||||
jdbcPreProcessor.setProperty("MS-ID", this.getId());
|
||||
jdbcPreProcessor.setProperty("MS-RESOURCE-ID", this.getResourceId());
|
||||
jdbcPreProcessor.setProperty("MS-RESOURCE-ID", this.getResourceId()+ "_" + this.getIndex());
|
||||
List<String> id_names = new LinkedList<>();
|
||||
this.getScenarioSet(this, id_names);
|
||||
jdbcPreProcessor.setProperty("MS-SCENARIO", JSON.toJSONString(id_names));
|
||||
|
|
|
@ -141,7 +141,7 @@ public class MsDubboSampler extends MsTestElement {
|
|||
sampler.setProperty(TestElement.TEST_CLASS, DubboSample.class.getName());
|
||||
sampler.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("DubboSampleGui"));
|
||||
sampler.setProperty("MS-ID", this.getId());
|
||||
sampler.setProperty("MS-RESOURCE-ID", this.getResourceId());
|
||||
sampler.setProperty("MS-RESOURCE-ID", this.getResourceId()+ "_" + this.getIndex());
|
||||
List<String> id_names = new LinkedList<>();
|
||||
this.getScenarioSet(this, id_names);
|
||||
sampler.setProperty("MS-SCENARIO", JSON.toJSONString(id_names));
|
||||
|
|
|
@ -182,7 +182,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
sampler.setProperty(TestElement.TEST_CLASS, HTTPSamplerProxy.class.getName());
|
||||
sampler.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("HttpTestSampleGui"));
|
||||
sampler.setProperty("MS-ID", this.getId());
|
||||
sampler.setProperty("MS-RESOURCE-ID", this.getResourceId());
|
||||
sampler.setProperty("MS-RESOURCE-ID", this.getResourceId()+ "_" + this.getIndex());
|
||||
List<String> id_names = new LinkedList<>();
|
||||
this.getScenarioSet(this, id_names);
|
||||
sampler.setProperty("MS-SCENARIO", JSON.toJSONString(id_names));
|
||||
|
|
|
@ -240,7 +240,7 @@ public class MsJDBCSampler extends MsTestElement {
|
|||
sampler.setProperty(TestElement.TEST_CLASS, JDBCSampler.class.getName());
|
||||
sampler.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI"));
|
||||
sampler.setProperty("MS-ID", this.getId());
|
||||
sampler.setProperty("MS-RESOURCE-ID", this.getResourceId());
|
||||
sampler.setProperty("MS-RESOURCE-ID", this.getResourceId()+ "_" + this.getIndex());
|
||||
List<String> id_names = new LinkedList<>();
|
||||
this.getScenarioSet(this, id_names);
|
||||
sampler.setProperty("MS-SCENARIO", JSON.toJSONString(id_names));
|
||||
|
|
|
@ -184,10 +184,10 @@ public class MsTCPSampler extends MsTestElement {
|
|||
if (!isCustomizeReq() && config != null && config.getTcpConfig() != null) {
|
||||
this.server = config.getTcpConfig().getServer();
|
||||
this.port = config.getTcpConfig().getPort();
|
||||
if(StringUtils.equals(this.eolByte," ")){
|
||||
if (StringUtils.equals(this.eolByte, " ")) {
|
||||
this.eolByte = "";
|
||||
}else{
|
||||
if(StringUtils.isEmpty(this.eolByte)){
|
||||
} else {
|
||||
if (StringUtils.isEmpty(this.eolByte)) {
|
||||
this.eolByte = config.getTcpConfig().getEolByte();
|
||||
}
|
||||
}
|
||||
|
@ -204,7 +204,7 @@ public class MsTCPSampler extends MsTestElement {
|
|||
tcpSampler.setName(this.getName() + DelimiterConstants.SEPARATOR.toString() + name);
|
||||
}
|
||||
tcpSampler.setProperty("MS-ID", this.getId());
|
||||
tcpSampler.setProperty("MS-RESOURCE-ID", this.getResourceId());
|
||||
tcpSampler.setProperty("MS-RESOURCE-ID", this.getResourceId() + "_" + this.getIndex());
|
||||
List<String> id_names = new LinkedList<>();
|
||||
this.getScenarioSet(this, id_names);
|
||||
tcpSampler.setProperty("MS-SCENARIO", JSON.toJSONString(id_names));
|
||||
|
@ -222,16 +222,16 @@ public class MsTCPSampler extends MsTestElement {
|
|||
tcpSampler.setEolByte(this.getEolByte());
|
||||
|
||||
String value = this.getRequest();
|
||||
if(StringUtils.isNotEmpty(this.getConnectEncoding())){
|
||||
if(StringUtils.equalsIgnoreCase("utf-8",this.getConnectEncoding())){
|
||||
if (StringUtils.isNotEmpty(this.getConnectEncoding())) {
|
||||
if (StringUtils.equalsIgnoreCase("utf-8", this.getConnectEncoding())) {
|
||||
try {
|
||||
value = new String(value.getBytes(),StandardCharsets.UTF_8);
|
||||
}catch (Exception e){
|
||||
value = new String(value.getBytes(), StandardCharsets.UTF_8);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}else if(StringUtils.equalsIgnoreCase("gbk",this.getConnectEncoding())){
|
||||
} else if (StringUtils.equalsIgnoreCase("gbk", this.getConnectEncoding())) {
|
||||
try {
|
||||
value = new String(value.getBytes(),"GBK");
|
||||
}catch (Exception e){
|
||||
value = new String(value.getBytes(), "GBK");
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -256,18 +256,18 @@ public class MsTCPSampler extends MsTestElement {
|
|||
this.parameters.forEach(item -> {
|
||||
names.add(new StringProperty(new Integer(new Random().nextInt(1000000)).toString(), item.getName()));
|
||||
String value = item.getValue();
|
||||
if(StringUtils.isNotEmpty(value)){
|
||||
if (StringUtils.isNotEmpty(value)) {
|
||||
value = this.formatMockValue(value);
|
||||
if(StringUtils.isNotEmpty(this.getConnectEncoding())){
|
||||
if(StringUtils.equalsIgnoreCase("utf-8",this.getConnectEncoding())){
|
||||
if (StringUtils.isNotEmpty(this.getConnectEncoding())) {
|
||||
if (StringUtils.equalsIgnoreCase("utf-8", this.getConnectEncoding())) {
|
||||
try {
|
||||
value = new String(value.getBytes(),StandardCharsets.UTF_8);
|
||||
}catch (Exception e){
|
||||
value = new String(value.getBytes(), StandardCharsets.UTF_8);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}else if(StringUtils.equalsIgnoreCase("gbk",this.getConnectEncoding())){
|
||||
} else if (StringUtils.equalsIgnoreCase("gbk", this.getConnectEncoding())) {
|
||||
try {
|
||||
value = new String(value.getBytes(),"GBK");
|
||||
}catch (Exception e){
|
||||
value = new String(value.getBytes(), "GBK");
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -281,29 +281,31 @@ public class MsTCPSampler extends MsTestElement {
|
|||
userParameters.setThreadLists(new CollectionProperty(UserParameters.THREAD_VALUES, collectionPropertyList));
|
||||
tree.add(userParameters);
|
||||
}
|
||||
|
||||
private String formatMockValue(String value) {
|
||||
|
||||
String patten = ">@[^>@]+</?";
|
||||
Pattern r = Pattern.compile(patten);
|
||||
try{
|
||||
try {
|
||||
Matcher m = r.matcher(value);
|
||||
while (m.find()){
|
||||
while (m.find()) {
|
||||
String findStr = m.group();
|
||||
if(findStr.length() > 3){
|
||||
findStr = findStr.substring(1,findStr.length()-2);
|
||||
if (findStr.length() > 3) {
|
||||
findStr = findStr.substring(1, findStr.length() - 2);
|
||||
String replaceStr = ScriptEngineUtils.buildFunctionCallString(findStr);
|
||||
if(StringUtils.equals(findStr,replaceStr)){
|
||||
if (StringUtils.equals(findStr, replaceStr)) {
|
||||
replaceStr = "";
|
||||
}
|
||||
value = value.replace(">"+findStr+"</",">"+replaceStr+"</");
|
||||
m = r.matcher(value);
|
||||
value = value.replace(">" + findStr + "</", ">" + replaceStr + "</");
|
||||
m = r.matcher(value);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
private ConfigTestElement tcpConfig() {
|
||||
ConfigTestElement configTestElement = new ConfigTestElement();
|
||||
configTestElement.setEnabled(true);
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
<ms-main-container>
|
||||
<el-card>
|
||||
<section class="report-container">
|
||||
<ms-api-report-view-header :debug="debug" :export-flag="exportFlag" :report="report" @reportExport="handleExport" @reportSave="handleSave"/>
|
||||
<div style="margin-top: 10px">
|
||||
<ms-api-report-view-header :debug="debug" :export-flag="exportFlag" :report="report" @reportExport="handleExport" @reportSave="handleSave"/>
|
||||
</div>
|
||||
<main>
|
||||
<ms-metric-chart :content="content" :totalTime="totalTime" v-if="!loading"/>
|
||||
<div>
|
||||
|
@ -71,7 +73,7 @@ export default {
|
|||
fullTreeNodes: [],
|
||||
debugResult: new Map,
|
||||
scenarioMap: new Map,
|
||||
exportFlag:false,
|
||||
exportFlag: false,
|
||||
}
|
||||
},
|
||||
activated() {
|
||||
|
@ -156,7 +158,7 @@ export default {
|
|||
hashTree.forEach(item => {
|
||||
if (item.enable) {
|
||||
let name = item.name ? item.name : item.type;
|
||||
let obj = {resId: item.resourceId, index: Number(item.index), label: name, value: {name: name, responseResult: {}, unexecute: true}, children: [], unsolicited: true};
|
||||
let obj = {resId: item.resourceId + "_" + item.index, index: Number(item.index), label: name, value: {name: name, responseResult: {}, unexecute: true}, children: [], unsolicited: true};
|
||||
tree.children.push(obj);
|
||||
if (ELEMENTS.get("AllSamplerProxy").indexOf(item.type) != -1) {
|
||||
obj.unsolicited = false;
|
||||
|
@ -503,10 +505,6 @@ export default {
|
|||
font-size: 15px;
|
||||
}
|
||||
|
||||
/deep/ .el-card__body {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.report-header a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
|
|
@ -533,7 +533,7 @@ export default {
|
|||
},
|
||||
resultEvaluationChild(arr, resourceId, status) {
|
||||
arr.forEach(item => {
|
||||
if (item.data.resourceId === resourceId) {
|
||||
if (item.data.resourceId + "_" + item.data.index === resourceId) {
|
||||
item.data.testing = false;
|
||||
this.evaluationParent(item.parent, status);
|
||||
}
|
||||
|
@ -545,7 +545,7 @@ export default {
|
|||
resultEvaluation(resourceId, status) {
|
||||
if (this.$refs.stepTree && this.$refs.stepTree.root) {
|
||||
this.$refs.stepTree.root.childNodes.forEach(item => {
|
||||
if (item.data.resourceId === resourceId) {
|
||||
if (item.data.resourceId + "_" + item.data.index === resourceId) {
|
||||
item.data.testing = false;
|
||||
}
|
||||
if (item.childNodes && item.childNodes.length > 0) {
|
||||
|
@ -622,7 +622,7 @@ export default {
|
|||
},
|
||||
runningNodeChild(arr, resourceId) {
|
||||
arr.forEach(item => {
|
||||
if (item.data && item.data.resourceId === resourceId) {
|
||||
if (item.data && item.data.resourceId + "_" + item.data.index === resourceId) {
|
||||
item.data.testing = true;
|
||||
this.runningEditParent(item.parent);
|
||||
}
|
||||
|
@ -634,7 +634,7 @@ export default {
|
|||
runningEvaluation(resourceId) {
|
||||
if (this.$refs.stepTree && this.$refs.stepTree.root) {
|
||||
this.$refs.stepTree.root.childNodes.forEach(item => {
|
||||
if (item.data && item.data.resourceId === resourceId) {
|
||||
if (item.data && item.data.resourceId + "_" + item.data.index === resourceId) {
|
||||
item.data.testing = true;
|
||||
}
|
||||
if (item.childNodes && item.childNodes.length > 0) {
|
||||
|
@ -866,7 +866,7 @@ export default {
|
|||
}
|
||||
}
|
||||
// 添加debug结果
|
||||
let key = stepArray[i].resourceId;
|
||||
let key = stepArray[i].resourceId + "_" + stepArray[i].index;
|
||||
if (this.debugResult && this.debugResult.get(key)) {
|
||||
stepArray[i].requestResult = this.debugResult.get(key);
|
||||
stepArray[i].result = null;
|
||||
|
|
Loading…
Reference in New Issue