fix(接口测试): 修复TCP接口环境缓存问题

--bug=1013451 --user=赵勇 【接口测试】TCP请求,在TEST页面执行,环境信息没带上【+github#13897】 https://www.tapd.cn/55049933/s/1163999
This commit is contained in:
fit2-zhao 2022-05-25 17:04:37 +08:00 committed by f2c-ci-robot[bot]
parent 819e224115
commit 98de930ae6
3 changed files with 9 additions and 5 deletions

View File

@ -11,6 +11,7 @@ import io.metersphere.jmeter.utils.ScriptEngineUtils;
import io.metersphere.utils.LoggerUtil;
import lombok.Data;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.entity.ContentType;
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy;
@ -72,9 +73,9 @@ public class Body {
body = this.getKvs().stream().filter(KeyValue::isValid).collect(Collectors.toList());
HTTPFileArg[] httpFileArgs = httpFileArgs(requestId);
// 文件上传
if (httpFileArgs.length > 0) {
if (ArrayUtils.isNotEmpty(httpFileArgs)) {
sampler.setHTTPFiles(httpFileArgs(requestId));
sampler.setDoMultipart(true);
sampler.setDoMultipart(!StringUtils.equalsIgnoreCase(this.type, "BINARY"));
}
} else {
if (StringUtils.isNotEmpty(this.getRaw()) || this.getJsonSchema() != null) {
@ -157,7 +158,7 @@ public class Body {
if (StringUtils.isBlank(mimetype)) {
mimetype = ContentType.APPLICATION_OCTET_STREAM.getMimeType();
}
list.add(new HTTPFileArg(path, paramName, mimetype));
list.add(new HTTPFileArg(path, isBinary ? "" : paramName, mimetype));
});
}
}

View File

@ -13,7 +13,7 @@ import io.metersphere.utils.LoggerUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.jmeter.samplers.SampleResult;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@ -26,7 +26,7 @@ public class APISingleResultListener implements MsExecListener {
*/
@Override
public void setupTest() {
queues = new ArrayList<>();
queues = new LinkedList<>();
LoggerUtil.info("初始化监听");
}

View File

@ -128,6 +128,9 @@ export default {
props: {apiData: {}, currentProtocol: String, syncTabs: Array, projectId: String},
watch: {
'$store.state.useEnvironment': function () {
if(this.api && this.api.request) {
this.api.request.useEnvironment = this.$store.state.useEnvironment;
}
this.api.environmentId = this.$store.state.useEnvironment;
}
},