diff --git a/backend/src/main/java/io/metersphere/performance/engine/EngineFactory.java b/backend/src/main/java/io/metersphere/performance/engine/EngineFactory.java index b96318cf54..fb18acdff2 100644 --- a/backend/src/main/java/io/metersphere/performance/engine/EngineFactory.java +++ b/backend/src/main/java/io/metersphere/performance/engine/EngineFactory.java @@ -301,53 +301,54 @@ public class EngineFactory { try { Element hashTree = null; Document rootDocument = null; - for (FileMetadata fileMetadata : jmxFiles) { - // 兼容处理 - byte[] bytes = fileMetadataService.loadFileAsBytes(fileMetadata.getId()); - InputStream inputSource = new ByteArrayInputStream(bytes); - if (hashTree == null) { - rootDocument = EngineSourceParserFactory.getDocument(inputSource); - Element jmeterTestPlan = rootDocument.getRootElement(); - List childNodes = jmeterTestPlan.elements(); + if (CollectionUtils.isNotEmpty(jmxFiles)) { + for (FileMetadata fileMetadata : jmxFiles) { + // 兼容处理 + byte[] bytes = fileMetadataService.loadFileAsBytes(fileMetadata.getId()); + InputStream inputSource = new ByteArrayInputStream(bytes); + if (hashTree == null) { + rootDocument = EngineSourceParserFactory.getDocument(inputSource); + Element jmeterTestPlan = rootDocument.getRootElement(); + List childNodes = jmeterTestPlan.elements(); - outer: - for (Element node : childNodes) { - // jmeterTestPlan的子元素肯定是 - List childNodes1 = node.elements(); - for (Element item : childNodes1) { - if (StringUtils.equalsIgnoreCase("TestPlan", item.getName())) { - hashTree = getNextSibling(item); - break outer; + outer: + for (Element node : childNodes) { + // jmeterTestPlan的子元素肯定是 + List childNodes1 = node.elements(); + for (Element item : childNodes1) { + if (StringUtils.equalsIgnoreCase("TestPlan", item.getName())) { + hashTree = getNextSibling(item); + break outer; + } } } + } else { + Document document = EngineSourceParserFactory.getDocument(inputSource); + Element jmeterTestPlan = document.getRootElement(); + List childNodes = jmeterTestPlan.elements(); + for (Element node : childNodes) { + // jmeterTestPlan的子元素肯定是 + Element secondHashTree = node; + List secondChildNodes = secondHashTree.elements(); + for (Element item : secondChildNodes) { + if (StringUtils.equalsIgnoreCase("TestPlan", item.getName())) { + secondHashTree = getNextSibling(item); + break; + } + } + if (StringUtils.equalsIgnoreCase("hashTree", secondHashTree.getName())) { + List itemChildNodes = secondHashTree.elements(); + for (Element item1 : itemChildNodes) { + hashTree.add((Element) item1.clone()); + } + } + + } } - } else { - Document document = EngineSourceParserFactory.getDocument(inputSource); - Element jmeterTestPlan = document.getRootElement(); - List childNodes = jmeterTestPlan.elements(); - for (Element node : childNodes) { - // jmeterTestPlan的子元素肯定是 - Element secondHashTree = node; - List secondChildNodes = secondHashTree.elements(); - for (Element item : secondChildNodes) { - if (StringUtils.equalsIgnoreCase("TestPlan", item.getName())) { - secondHashTree = getNextSibling(item); - break; - } - } - if (StringUtils.equalsIgnoreCase("hashTree", secondHashTree.getName())) { - List itemChildNodes = secondHashTree.elements(); - for (Element item1 : itemChildNodes) { - hashTree.add((Element) item1.clone()); - } - } - - } + inputSource.close(); } - // - inputSource.close(); + return EngineSourceParserFactory.getBytes(rootDocument); } - return EngineSourceParserFactory.getBytes(rootDocument); } catch (Exception e) { MSException.throwException(e); } diff --git a/frontend/src/business/components/performance/test/components/ExistScenarios.vue b/frontend/src/business/components/performance/test/components/ExistScenarios.vue index bcc6f784d8..bb7dca45f8 100644 --- a/frontend/src/business/components/performance/test/components/ExistScenarios.vue +++ b/frontend/src/business/components/performance/test/components/ExistScenarios.vue @@ -143,6 +143,9 @@ export default { let data = returnData.scenarioJmxList; data.forEach(d => { let jmxName = d.name + "_" + new Date().getTime() + ".jmx"; + if (jmxName.indexOf("/") !== -1) { + jmxName = jmxName.replace(/\//g, ""); + } let threadGroups = findThreadGroup(d.jmx, jmxName); threadGroups.forEach(tg => { tg.options = {};