refactor: 更新jmx文件的DubboDefaultConfigGui信息
更新jmx文件的DubboDefaultConfigGui信息
This commit is contained in:
parent
cb1b9b1d67
commit
608ba81baa
|
@ -464,13 +464,14 @@ public class APITestService {
|
|||
|
||||
/**
|
||||
* 更新jmx数据,处理jmx里的各种参数
|
||||
*
|
||||
* <p>
|
||||
* 注: 与1.7分支合并时,如果该方法产生冲突,请以master为准
|
||||
* @author song tianyang
|
||||
*
|
||||
* @param jmxString 原JMX文件
|
||||
* @param testNameParam 某些节点要替换的testName
|
||||
* @param isFromScenario 是否来源于场景 (来源于场景的话,testName要进行处理)
|
||||
* @return
|
||||
* @author song tianyang
|
||||
*/
|
||||
public String updateJmxString(String jmxString, String testNameParam, boolean isFromScenario) {
|
||||
//注: 与1.7分支合并时,如果该方法产生冲突,请以master为准
|
||||
|
@ -485,14 +486,19 @@ public class APITestService {
|
|||
|
||||
List<Element> innerHashTreeElementList = rootHashTreeElement.elements("hashTree");
|
||||
for (Element innerHashTreeElement : innerHashTreeElementList) {
|
||||
List<Element> thirdHashTreeElementList = innerHashTreeElement.elements("hashTree");
|
||||
//转换DubboDefaultConfigGui
|
||||
List<Element> configTestElementList = innerHashTreeElement.elements("ConfigTestElement");
|
||||
for (Element configTestElement : configTestElementList) {
|
||||
this.updateDubboDefaultConfigGuiElement(configTestElement);
|
||||
}
|
||||
|
||||
List<Element> theadGroupElementList = innerHashTreeElement.elements("ThreadGroup");
|
||||
for (Element theadGroupElement : theadGroupElementList) {
|
||||
if (StringUtils.isNotEmpty(testNameParam)) {
|
||||
theadGroupElement.attribute(attribute_testName).setText(testNameParam);
|
||||
}
|
||||
}
|
||||
|
||||
List<Element> thirdHashTreeElementList = innerHashTreeElement.elements("hashTree");
|
||||
for (Element element : thirdHashTreeElementList) {
|
||||
String testName = testNameParam;
|
||||
|
||||
|
@ -500,15 +506,36 @@ public class APITestService {
|
|||
this.updateRequestElementInfo(element, testNameParam, requestElementNameArr, isFromScenario);
|
||||
//检查有无jmeter不是别的自定义参数
|
||||
this.checkPrivateFunctionNode(element);
|
||||
|
||||
//转换DubboDefaultConfigGui
|
||||
List<Element> hashTreeConfigTestElementList = element.elements("ConfigTestElement");
|
||||
for (Element configTestElement : hashTreeConfigTestElementList) {
|
||||
this.updateDubboDefaultConfigGuiElement(configTestElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
jmxString = root.asXML();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (!jmxString.startsWith("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")) {
|
||||
jmxString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + jmxString;
|
||||
}
|
||||
return jmxString;
|
||||
}
|
||||
|
||||
private void updateDubboDefaultConfigGuiElement(Element configTestElement) {
|
||||
String dubboDefaultConfigGuiClassName = "io.github.ningyu.jmeter.plugin.dubbo.gui.DubboDefaultConfigGui";
|
||||
if (configTestElement == null) {
|
||||
return;
|
||||
}
|
||||
String guiClassValue = configTestElement.attributeValue("guiclass");
|
||||
if (StringUtils.equals(guiClassValue, "DubboDefaultConfigGui")) {
|
||||
configTestElement.attribute("guiclass").setText(dubboDefaultConfigGuiClassName);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkPrivateFunctionNode(Element element) {
|
||||
List<Element> scriptHashTreeElementList = element.elements("hashTree");
|
||||
for (Element scriptHashTreeElement : scriptHashTreeElementList) {
|
||||
|
|
Loading…
Reference in New Issue