fix(接口测试): 修复导入JMX文件自定义请求标记错误问题

--bug=1012410 --user=赵勇 [接口测试] github#12793接口自动化导入jmx文件, 第一次执行,接口请求返回404 https://www.tapd.cn/55049933/s/1139654
This commit is contained in:
fit2-zhao 2022-04-19 17:10:11 +08:00 committed by 刘瑞斌
parent d402f37317
commit b49a8bde80
2 changed files with 5 additions and 0 deletions

View File

@ -333,6 +333,7 @@ public class MsJmeterParser extends ApiImportAbstractParser<ScenarioImport> {
if (url != null) { if (url != null) {
samplerProxy.setUrl(this.getUrl(source)); samplerProxy.setUrl(this.getUrl(source));
samplerProxy.setPath(null); samplerProxy.setPath(null);
samplerProxy.setCustomizeReq(true);
} }
samplerProxy.setId(UUID.randomUUID().toString()); samplerProxy.setId(UUID.randomUUID().toString());
samplerProxy.setType("HTTPSamplerProxy"); samplerProxy.setType("HTTPSamplerProxy");

View File

@ -114,6 +114,10 @@ public class MsJmeterElement extends MsTestElement {
for (ScenarioVariable item : list) { for (ScenarioVariable item : list) {
if (CollectionUtils.isNotEmpty(item.getFiles())) { if (CollectionUtils.isNotEmpty(item.getFiles())) {
List<String> names = item.getFiles().stream().map(BodyFile::getName).collect(Collectors.toList()); List<String> names = item.getFiles().stream().map(BodyFile::getName).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(names) && !names.contains(name) && name.contains("_")) {
String pathArr[] = name.split("_");
name = pathArr[pathArr.length - 1];
}
if (CollectionUtils.isNotEmpty(names) && names.contains(name)) { if (CollectionUtils.isNotEmpty(names) && names.contains(name)) {
if (!config.isOperating() && !new File(FileUtils.BODY_FILE_DIR + "/" + item.getFiles().get(0).getId() + "_" + item.getFiles().get(0).getName()).exists()) { if (!config.isOperating() && !new File(FileUtils.BODY_FILE_DIR + "/" + item.getFiles().get(0).getId() + "_" + item.getFiles().get(0).getName()).exists()) {
MSException.throwException(StringUtils.isEmpty(item.getName()) ? "CSVDataSet" : item.getName() + "[ CSV文件不存在 ]"); MSException.throwException(StringUtils.isEmpty(item.getName()) ? "CSVDataSet" : item.getName() + "[ CSV文件不存在 ]");