From 9d9e1c1984c4b8b6c49826b99259d2666b9081bd Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Fri, 3 Apr 2020 18:12:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E6=8E=89=20removeChildren?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xml/reader/jmx/JmeterDocumentParser.java | 46 +++++++++++-------- .../performance/test/PerformanceTestPlan.vue | 28 +++++++++-- 2 files changed, 51 insertions(+), 23 deletions(-) diff --git a/backend/src/main/java/io/metersphere/parse/xml/reader/jmx/JmeterDocumentParser.java b/backend/src/main/java/io/metersphere/parse/xml/reader/jmx/JmeterDocumentParser.java index 625f8a13dc..79c3e4fe5e 100644 --- a/backend/src/main/java/io/metersphere/parse/xml/reader/jmx/JmeterDocumentParser.java +++ b/backend/src/main/java/io/metersphere/parse/xml/reader/jmx/JmeterDocumentParser.java @@ -123,7 +123,6 @@ public class JmeterDocumentParser implements DocumentParser { for (int i = 0; i < childNodes.getLength(); i++) { Node item = childNodes.item(i); if (item instanceof Element && nodeNameEquals(item, "collectionProp")) { - removeChildren(item); Document document = item.getOwnerDocument(); Object params = context.getProperty("statusCode"); if (params instanceof List) { @@ -152,6 +151,15 @@ public class JmeterDocumentParser implements DocumentParser { Node item = childNodes.item(i); if (nodeNameEquals(item, RESPONSE_ASSERTION)) { // 如果已经存在,不再添加 + removeChildren(item); + Element collectionProp = document.createElement(COLLECTION_PROP); + collectionProp.setAttribute("name", "Asserion.test_strings"); + // + item.appendChild(collectionProp); + item.appendChild(createStringProp(document, "Assertion.custom_message", "")); + item.appendChild(createStringProp(document, "Assertion.test_field", "Assertion.response_code")); + item.appendChild(createBoolProp(document, "Assertion.assume_success", false)); + item.appendChild(createIntProp(document, "Assertion.test_type", 40)); return; } } @@ -181,7 +189,7 @@ public class JmeterDocumentParser implements DocumentParser { responseAssertion.appendChild(createStringProp(document, "Assertion.custom_message", "")); responseAssertion.appendChild(createStringProp(document, "Assertion.test_field", "Assertion.response_code")); responseAssertion.appendChild(createBoolProp(document, "Assertion.assume_success", false)); - responseAssertion.appendChild(createIntProp(document, "Assertion.test_type", 33)); + responseAssertion.appendChild(createIntProp(document, "Assertion.test_type", 40)); hashTree.appendChild(responseAssertion); hashTree.appendChild(document.createElement(HASH_TREE_ELEMENT)); } @@ -352,7 +360,7 @@ public class JmeterDocumentParser implements DocumentParser { for (int i = 0; i < childNodes.getLength(); i++) { Node item = childNodes.item(i); if (item instanceof Element && nodeNameEquals(item, "collectionProp")) { - removeChildren(item); + // Document document = item.getOwnerDocument(); Object params = context.getProperty("params"); if (params instanceof List) { @@ -377,31 +385,33 @@ public class JmeterDocumentParser implements DocumentParser { private void processDnsCacheManager(Element ele) { + Object domains = context.getProperty("domains"); + if (!(domains instanceof List)) { + return; + } + if (((List) domains).size() == 0) { + return; + } NodeList childNodes = ele.getChildNodes(); for (int i = 0, size = childNodes.getLength(); i < size; i++) { Node item = childNodes.item(i); if (item instanceof Element && nodeNameEquals(item, "collectionProp") && org.apache.commons.lang3.StringUtils.equals(((Element) item).getAttribute("name"), "DNSCacheManager.hosts")) { - removeChildren(item); Document document = item.getOwnerDocument(); - Object domains = context.getProperty("domains"); - if (domains instanceof List) { - for (Object d : (List) domains) { - JSONObject jsonObject = JSON.parseObject(d.toString()); - if (!jsonObject.getBooleanValue("enable")) { - continue; - } - Element elementProp = document.createElement("elementProp"); - elementProp.setAttribute("name", jsonObject.getString("domain")); - elementProp.setAttribute("elementType", "StaticHost"); - elementProp.appendChild(createStringProp(document, "StaticHost.Name", jsonObject.getString("domain"))); - elementProp.appendChild(createStringProp(document, "StaticHost.Address", jsonObject.getString("ip"))); - item.appendChild(elementProp); + for (Object d : (List) domains) { + JSONObject jsonObject = JSON.parseObject(d.toString()); + if (!jsonObject.getBooleanValue("enable")) { + continue; } + Element elementProp = document.createElement("elementProp"); + elementProp.setAttribute("name", jsonObject.getString("domain")); + elementProp.setAttribute("elementType", "StaticHost"); + elementProp.appendChild(createStringProp(document, "StaticHost.Name", jsonObject.getString("domain"))); + elementProp.appendChild(createStringProp(document, "StaticHost.Address", jsonObject.getString("ip"))); + item.appendChild(elementProp); } } - if (item instanceof Element && nodeNameEquals(item, "boolProp") && org.apache.commons.lang3.StringUtils.equals(((Element) item).getAttribute("name"), "DNSCacheManager.isCustomResolver")) { item.getFirstChild().setNodeValue("true"); diff --git a/frontend/src/business/components/performance/test/PerformanceTestPlan.vue b/frontend/src/business/components/performance/test/PerformanceTestPlan.vue index f6f42cb64e..efab61384c 100644 --- a/frontend/src/business/components/performance/test/PerformanceTestPlan.vue +++ b/frontend/src/business/components/performance/test/PerformanceTestPlan.vue @@ -22,11 +22,6 @@ width="150" show-overflow-tooltip> - - {{ scope.row.updateTime | timestampFormatDate }} + + +