去掉 removeChildren

This commit is contained in:
Captain.B 2020-04-03 18:12:08 +08:00
parent e5b9800a2c
commit 9d9e1c1984
2 changed files with 51 additions and 23 deletions

View File

@ -123,7 +123,6 @@ public class JmeterDocumentParser implements DocumentParser {
for (int i = 0; i < childNodes.getLength(); i++) { for (int i = 0; i < childNodes.getLength(); i++) {
Node item = childNodes.item(i); Node item = childNodes.item(i);
if (item instanceof Element && nodeNameEquals(item, "collectionProp")) { if (item instanceof Element && nodeNameEquals(item, "collectionProp")) {
removeChildren(item);
Document document = item.getOwnerDocument(); Document document = item.getOwnerDocument();
Object params = context.getProperty("statusCode"); Object params = context.getProperty("statusCode");
if (params instanceof List) { if (params instanceof List) {
@ -152,6 +151,15 @@ public class JmeterDocumentParser implements DocumentParser {
Node item = childNodes.item(i); Node item = childNodes.item(i);
if (nodeNameEquals(item, RESPONSE_ASSERTION)) { 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; return;
} }
} }
@ -181,7 +189,7 @@ public class JmeterDocumentParser implements DocumentParser {
responseAssertion.appendChild(createStringProp(document, "Assertion.custom_message", "")); responseAssertion.appendChild(createStringProp(document, "Assertion.custom_message", ""));
responseAssertion.appendChild(createStringProp(document, "Assertion.test_field", "Assertion.response_code")); responseAssertion.appendChild(createStringProp(document, "Assertion.test_field", "Assertion.response_code"));
responseAssertion.appendChild(createBoolProp(document, "Assertion.assume_success", false)); 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(responseAssertion);
hashTree.appendChild(document.createElement(HASH_TREE_ELEMENT)); hashTree.appendChild(document.createElement(HASH_TREE_ELEMENT));
} }
@ -352,7 +360,7 @@ public class JmeterDocumentParser implements DocumentParser {
for (int i = 0; i < childNodes.getLength(); i++) { for (int i = 0; i < childNodes.getLength(); i++) {
Node item = childNodes.item(i); Node item = childNodes.item(i);
if (item instanceof Element && nodeNameEquals(item, "collectionProp")) { if (item instanceof Element && nodeNameEquals(item, "collectionProp")) {
removeChildren(item); //
Document document = item.getOwnerDocument(); Document document = item.getOwnerDocument();
Object params = context.getProperty("params"); Object params = context.getProperty("params");
if (params instanceof List) { if (params instanceof List) {
@ -377,16 +385,20 @@ public class JmeterDocumentParser implements DocumentParser {
private void processDnsCacheManager(Element ele) { 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(); NodeList childNodes = ele.getChildNodes();
for (int i = 0, size = childNodes.getLength(); i < size; i++) { for (int i = 0, size = childNodes.getLength(); i < size; i++) {
Node item = childNodes.item(i); Node item = childNodes.item(i);
if (item instanceof Element && nodeNameEquals(item, "collectionProp") if (item instanceof Element && nodeNameEquals(item, "collectionProp")
&& org.apache.commons.lang3.StringUtils.equals(((Element) item).getAttribute("name"), "DNSCacheManager.hosts")) { && org.apache.commons.lang3.StringUtils.equals(((Element) item).getAttribute("name"), "DNSCacheManager.hosts")) {
removeChildren(item);
Document document = item.getOwnerDocument(); Document document = item.getOwnerDocument();
Object domains = context.getProperty("domains");
if (domains instanceof List) {
for (Object d : (List) domains) { for (Object d : (List) domains) {
JSONObject jsonObject = JSON.parseObject(d.toString()); JSONObject jsonObject = JSON.parseObject(d.toString());
if (!jsonObject.getBooleanValue("enable")) { if (!jsonObject.getBooleanValue("enable")) {
@ -400,8 +412,6 @@ public class JmeterDocumentParser implements DocumentParser {
item.appendChild(elementProp); item.appendChild(elementProp);
} }
} }
}
if (item instanceof Element && nodeNameEquals(item, "boolProp") if (item instanceof Element && nodeNameEquals(item, "boolProp")
&& org.apache.commons.lang3.StringUtils.equals(((Element) item).getAttribute("name"), "DNSCacheManager.isCustomResolver")) { && org.apache.commons.lang3.StringUtils.equals(((Element) item).getAttribute("name"), "DNSCacheManager.isCustomResolver")) {
item.getFirstChild().setNodeValue("true"); item.getFirstChild().setNodeValue("true");

View File

@ -22,11 +22,6 @@
width="150" width="150"
show-overflow-tooltip> show-overflow-tooltip>
</el-table-column> </el-table-column>
<el-table-column
prop="description"
:label="$t('commons.description')"
show-overflow-tooltip>
</el-table-column>
<el-table-column <el-table-column
prop="projectName" prop="projectName"
:label="$t('load_test.project_name')" :label="$t('load_test.project_name')"
@ -47,6 +42,29 @@
<span>{{ scope.row.updateTime | timestampFormatDate }}</span> <span>{{ scope.row.updateTime | timestampFormatDate }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column
prop="status"
:label="$t('commons.status')">
<template v-slot:default="{row}">
<el-tag size="mini" type="primary" v-if="row.status === 'Starting'">
{{ row.status }}
</el-tag>
<el-tag size="mini" type="success" v-else-if="row.status === 'Running'">
{{ row.status }}
</el-tag>
<el-tooltip placement="top" v-else-if="row.status === 'Error'" effect="light">
<template v-slot:content>
<div>{{row.description}}</div>
</template>
<el-tag size="mini" type="danger">
{{ row.status }}
</el-tag>
</el-tooltip>
<el-tag size="mini" type="info" v-else>
{{ row.status }}
</el-tag>
</template>
</el-table-column>
<el-table-column <el-table-column
width="150" width="150"
:label="$t('commons.operating')"> :label="$t('commons.operating')">