fix(性能测试): 修复性能测试文件上传时文件名没有转化的问题

--bug=1012020 --user=刘瑞斌 【接口测试】github #12379,在接口自动化上传文件成功,转成性能测试后报错fileNotFound,因为路径没有转换 https://www.tapd.cn/55049933/s/1132266

Closes #12379
This commit is contained in:
CaptainB 2022-04-11 11:36:34 +08:00 committed by 刘瑞斌
parent bc7fd9c37b
commit d1f54a5bc6
1 changed files with 19 additions and 19 deletions

View File

@ -186,37 +186,37 @@ public class JmeterDocumentParser implements EngineSourceParser {
private void processArgumentFiles(Element element) { private void processArgumentFiles(Element element) {
List<Element> childNodes = element.elements(); List<Element> childNodes = element.elements();
if (childNodes.size() == 0) {
return;
}
for (Element item : childNodes) { for (Element item : childNodes) {
if (isHTTPFileArgs(item)) { processArgumentFiles(item);
List<Element> elementProps = item.elements(); if (StringUtils.equals(item.attributeValue("name"), "File.path")) {
for (Element eleProp : elementProps) { // 截取文件名
List<Element> strProps = eleProp.elements(); handleFilename(item);
for (Element strPop : strProps) { }
if (StringUtils.equals(strPop.attributeValue("name"), "File.path")) { if (StringUtils.equals(item.attributeValue("elementType"), "HTTPFileArg")) {
// 截取文件名 // 截取文件名
handleFilename(strPop); String filename = item.attributeValue("name");
break; filename = extractFilename(filename);
} item.addAttribute("name", filename);
}
}
} }
} }
} }
private void handleFilename(Node item) { private String extractFilename(String filename) {
String separator = "/"; String separator = "/";
String filename = item.getText();
if (!StringUtils.contains(filename, "/")) { if (!StringUtils.contains(filename, "/")) {
separator = "\\"; separator = "\\";
} }
filename = filename.substring(filename.lastIndexOf(separator) + 1); filename = filename.substring(filename.lastIndexOf(separator) + 1);
item.setText(filename); return filename;
} }
private boolean isHTTPFileArgs(Element ele) { private void handleFilename(Node item) {
return "HTTPFileArgs".equals(ele.attributeValue("elementType")); String filename = item.getText();
filename = extractFilename(filename);
item.setText(filename);
} }
private void processCsvDataSet(Element element) { private void processCsvDataSet(Element element) {