fix(性能测试): 修复性能测试文件上传时文件名没有转化的问题
--bug=1012020 --user=刘瑞斌 【接口测试】github #12379,在接口自动化上传文件成功,转成性能测试后报错fileNotFound,因为路径没有转换 https://www.tapd.cn/55049933/s/1132266 Closes #12379
This commit is contained in:
parent
bc7fd9c37b
commit
d1f54a5bc6
|
@ -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();
|
|
||||||
for (Element strPop : strProps) {
|
|
||||||
if (StringUtils.equals(strPop.attributeValue("name"), "File.path")) {
|
|
||||||
// 截取文件名
|
// 截取文件名
|
||||||
handleFilename(strPop);
|
handleFilename(item);
|
||||||
break;
|
}
|
||||||
|
if (StringUtils.equals(item.attributeValue("elementType"), "HTTPFileArg")) {
|
||||||
|
// 截取文件名
|
||||||
|
String filename = item.attributeValue("name");
|
||||||
|
filename = extractFilename(filename);
|
||||||
|
item.addAttribute("name", filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String extractFilename(String filename) {
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleFilename(Node item) {
|
|
||||||
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) {
|
||||||
|
|
Loading…
Reference in New Issue