替换jmx值

This commit is contained in:
Captain.B 2020-03-03 14:22:09 +08:00
parent 07f286322d
commit c23f5bd795
1 changed files with 25 additions and 10 deletions

View File

@ -21,6 +21,7 @@ import java.nio.charset.StandardCharsets;
public class JmeterDocumentParser implements DocumentParser { public class JmeterDocumentParser implements DocumentParser {
private final static String HASH_TREE_ELEMENT = "hashTree"; private final static String HASH_TREE_ELEMENT = "hashTree";
private final static String STRING_PROP = "stringProp"; private final static String STRING_PROP = "stringProp";
private final static String COLLECTION_PROP = "collectionProp";
private final static String CONCURRENCY_THREAD_GROUP = "com.blazemeter.jmeter.threads.concurrency.ConcurrencyThreadGroup"; private final static String CONCURRENCY_THREAD_GROUP = "com.blazemeter.jmeter.threads.concurrency.ConcurrencyThreadGroup";
private final static String VARIABLE_THROUGHPUT_TIMER = "kg.apc.jmeter.timers.VariableThroughputTimer"; private final static String VARIABLE_THROUGHPUT_TIMER = "kg.apc.jmeter.timers.VariableThroughputTimer";
private EngineContext context; private EngineContext context;
@ -106,7 +107,6 @@ public class JmeterDocumentParser implements DocumentParser {
private void processVariableThroughputTimer(Element variableThroughputTimer) { private void processVariableThroughputTimer(Element variableThroughputTimer) {
if (variableThroughputTimer.getChildNodes().getLength() > 0) { if (variableThroughputTimer.getChildNodes().getLength() > 0) {
final NodeList childNodes = variableThroughputTimer.getChildNodes(); final NodeList childNodes = variableThroughputTimer.getChildNodes();
int stringPropCount = 0;
for (int i = 0; i < childNodes.getLength(); i++) { for (int i = 0; i < childNodes.getLength(); i++) {
Node node = childNodes.item(i); Node node = childNodes.item(i);
if (node instanceof Element) { if (node instanceof Element) {
@ -115,17 +115,32 @@ public class JmeterDocumentParser implements DocumentParser {
continue; continue;
} }
// kg.apc.jmeter.timers.VariableThroughputTimer的stringProp的name属性是动态的 // TODO kg.apc.jmeter.timers.VariableThroughputTimer的stringProp的name属性是动态的
if (nodeNameEquals(ele, STRING_PROP)) { if (nodeNameEquals(ele, COLLECTION_PROP)) {
if (stringPropCount < 2) { NodeList eleChildNodes = ele.getChildNodes();
stringPropCount++; for (int j = 0; j < eleChildNodes.getLength(); j++) {
} else { Node item = eleChildNodes.item(j);
stringPropCount = 0; if (nodeNameEquals(item, COLLECTION_PROP)) {
ele.getFirstChild().setNodeValue(context.getProperty("duration").toString()); int stringPropCount = 0;
continue; NodeList itemChildNodes = item.getChildNodes();
for (int k = 0; k < itemChildNodes.getLength(); k++) {
Node prop = itemChildNodes.item(k);
if (nodeNameEquals(prop, STRING_PROP)) {
if (stringPropCount < 2) {
stringPropCount++;
} else {
stringPropCount = 0;
prop.getFirstChild().setNodeValue(context.getProperty("duration").toString());
continue;
}
prop.getFirstChild().setNodeValue(context.getProperty("rpsLimit").toString());
}
}
}
} }
ele.getFirstChild().setNodeValue(context.getProperty("rpsLimit").toString());
} }
} }
} }
} }