fix(接口测试): 修复自定义请求变量缺失的缺陷
--bug=1019069 --user=王孝刚 【接口测试】github#19227,脚本中设置url变量,在请定义请求时,变量值会缺失 https://www.tapd.cn/55049933/s/1288741
This commit is contained in:
parent
6bd21b3314
commit
835d4fb8a4
|
@ -427,22 +427,12 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String url = this.getUrl();
|
String url = this.getUrl();
|
||||||
if (StringUtils.isNotEmpty(url) && !url.startsWith("http://") && !url.startsWith("https://")) {
|
|
||||||
url = "http://" + url;
|
|
||||||
}
|
|
||||||
if (StringUtils.isNotEmpty(this.getPort()) && this.getPort().startsWith("${")) {
|
if (StringUtils.isNotEmpty(this.getPort()) && this.getPort().startsWith("${")) {
|
||||||
url = url.replace(this.getPort(), "10990");
|
url = url.replace(this.getPort(), "10990");
|
||||||
}
|
}
|
||||||
if (StringUtils.isEmpty(url)) {
|
if (StringUtils.isEmpty(url)) {
|
||||||
MSException.throwException("请重新选择环境");
|
MSException.throwException("请重新选择环境");
|
||||||
}
|
}
|
||||||
URL urlObject = new URL(url);
|
|
||||||
if (urlObject.getPort() > 0 && urlObject.getPort() == 10990 && StringUtils.isNotEmpty(this.getPort()) && this.getPort().startsWith("${")) {
|
|
||||||
sampler.setProperty("HTTPSampler.port", this.getPort());
|
|
||||||
} else if (urlObject.getPort() != -1) {
|
|
||||||
sampler.setPort(urlObject.getPort());
|
|
||||||
}
|
|
||||||
sampler.setProtocol(urlObject.getProtocol());
|
|
||||||
String envPath = url;
|
String envPath = url;
|
||||||
sampler.setProperty("HTTPSampler.path", envPath, StandardCharsets.UTF_8.name());
|
sampler.setProperty("HTTPSampler.path", envPath, StandardCharsets.UTF_8.name());
|
||||||
if (CollectionUtils.isNotEmpty(this.getRest()) && this.isRest()) {
|
if (CollectionUtils.isNotEmpty(this.getRest()) && this.isRest()) {
|
||||||
|
|
Loading…
Reference in New Issue