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