@SuppressWarnings("deprecation")// Deliberate use of deprecated ctor JMeterTreeModeltreeModel=newJMeterTreeModel(newObject());// NOSONAR Create non-GUI version to avoid headless problems JMeterTreeNoderoot= (JMeterTreeNode) treeModel.getRoot(); treeModel.addSubTree(tree, root);
// Hack to resolve ModuleControllers in non GUI mode SearchByClass<ReplaceableController> replaceableControllers = newSearchByClass<>(ReplaceableController.class); tree.traverse(replaceableControllers); Collection<ReplaceableController> replaceableControllersRes = replaceableControllers.getSearchResults(); for (ReplaceableController replaceableController : replaceableControllersRes) { replaceableController.resolveReplacementSubTree(root); }
// Ensure tree is interpreted (ReplaceableControllers are replaced) // For GUI runs this is done in Start.java HashTreeclonedTree= convertSubTree(tree, true);
Summarisersummariser=null; StringsummariserName= JMeterUtils.getPropDefault("summariser.name", "");//$NON-NLS-1$ if (summariserName.length() > 0) { log.info("Creating summariser <{}>", summariserName); println("Creating summariser <" + summariserName + ">"); summariser = newSummariser(summariserName); } ResultCollectorresultCollector=null; if (logFile != null) { resultCollector = newResultCollector(summariser); resultCollector.setFilename(logFile); clonedTree.add(clonedTree.getArray()[0], resultCollector); } else { // only add Summariser if it can not be shared with the ResultCollector if (summariser != null) { clonedTree.add(clonedTree.getArray()[0], summariser); } }
// Used for remote notification of threads start/stop,see BUG 54152 // Summariser uses this feature to compute correctly number of threads // when NON GUI mode is used clonedTree.add(clonedTree.getArray()[0], newRemoteThreadsListenerTestElement());
@SuppressWarnings("deprecation")// Deliberate use of deprecated ctor JMeterTreeModeltreeModel=newJMeterTreeModel(newObject());// NOSONAR Create non-GUI version to avoid headless problems JMeterTreeNoderoot= (JMeterTreeNode) treeModel.getRoot(); treeModel.addSubTree(tree, root);
创建一个JMeterTreeModel,并使用HashTree填充它,以构建完整的测试计划模型。
处理模块控制器:
1 2 3 4 5 6 7
// Hack to resolve ModuleControllers in non GUI mode SearchByClass<ReplaceableController> replaceableControllers = newSearchByClass<>(ReplaceableController.class); tree.traverse(replaceableControllers); Collection<ReplaceableController> replaceableControllersRes = replaceableControllers.getSearchResults(); for (ReplaceableController replaceableController : replaceableControllersRes) { replaceableController.resolveReplacementSubTree(root); }
Creating summariser <summary> Created the tree successfully using test.jmx Starting standalone test @ Sat Aug 03 16:57:49 CST 2024 (1722675469483) Waiting for possible Shutdown/StopTestNow/HeapDump/ThreadDump message on port 4445
1 2 3 4 5 6 7 8 9 10 11 12
ResultCollectorresultCollector=null; if (logFile != null) { resultCollector = newResultCollector(summariser); resultCollector.setFilename(logFile); clonedTree.add(clonedTree.getArray()[0], resultCollector); } else { // only add Summariser if it can not be shared with the ResultCollector if (summariser != null) { clonedTree.add(clonedTree.getArray()[0], summariser); } }