use of org.apache.jorphan.collections.ListedHashTree in project jmeter by apache.
the class ModuleController method getReplacementSubTree.
/**
* {@inheritDoc}
*/
@Override
public HashTree getReplacementSubTree() {
HashTree tree = new ListedHashTree();
if (selectedNode != null) {
// Use a local variable to avoid replacing reference by modified clone (see Bug 54950)
JMeterTreeNode nodeToReplace = selectedNode;
// We clone to avoid enabling existing node
if (!nodeToReplace.isEnabled()) {
nodeToReplace = cloneTreeNode(selectedNode);
nodeToReplace.setEnabled(true);
}
HashTree subtree = tree.add(nodeToReplace);
createSubTree(subtree, nodeToReplace);
}
return tree;
}
use of org.apache.jorphan.collections.ListedHashTree in project jmeter by apache.
the class Start method startEngine.
/**
* Start JMeter engine
* @param ignoreTimer flag to ignore timers
* @param isValidationShot
* @param threadGroupsToRun Array of AbstractThreadGroup to run
*/
private void startEngine(boolean ignoreTimer, boolean isValidationShot, AbstractThreadGroup[] threadGroupsToRun) {
GuiPackage gui = GuiPackage.getInstance();
HashTree testTree = gui.getTreeModel().getTestPlan();
JMeter.convertSubTree(testTree);
if (threadGroupsToRun != null && threadGroupsToRun.length > 0) {
removeThreadGroupsFromHashTree(testTree, threadGroupsToRun);
}
testTree.add(testTree.getArray()[0], gui.getMainFrame());
if (log.isDebugEnabled()) {
log.debug("test plan before cloning is running version: {}", ((TestPlan) testTree.getArray()[0]).isRunningVersion());
}
ListedHashTree clonedTree = null;
if (isValidationShot) {
TreeCloner cloner = createTreeClonerForValidation();
testTree.traverse(cloner);
clonedTree = cloner.getClonedTree();
} else {
TreeCloner cloner = cloneTree(testTree, ignoreTimer);
clonedTree = cloner.getClonedTree();
}
if (popupCheckExistingFileListener(testTree)) {
engine = new StandardJMeterEngine();
engine.configure(clonedTree);
try {
engine.runTest();
} catch (JMeterEngineException e) {
JOptionPane.showMessageDialog(gui.getMainFrame(), e.getMessage(), JMeterUtils.getResString("error_occurred"), //$NON-NLS-1$
JOptionPane.ERROR_MESSAGE);
}
if (log.isDebugEnabled()) {
log.debug("test plan after cloning and running test is running version: {}", ((TestPlan) testTree.getArray()[0]).isRunningVersion());
}
}
}
use of org.apache.jorphan.collections.ListedHashTree in project jmeter by apache.
the class JMeterTreeModel method getCurrentSubTree.
/**
* Get the current sub tree for a {@link JMeterTreeNode}
* @param node The {@link JMeterTreeNode} from which the sub tree is to be taken
* @return newly copied sub tree
*/
public HashTree getCurrentSubTree(JMeterTreeNode node) {
ListedHashTree hashTree = new ListedHashTree(node);
Enumeration<JMeterTreeNode> enumNode = node.children();
while (enumNode.hasMoreElements()) {
JMeterTreeNode child = enumNode.nextElement();
hashTree.add(node, getCurrentSubTree(child));
}
return hashTree;
}
use of org.apache.jorphan.collections.ListedHashTree in project jmeter by apache.
the class TestSave method testTreeConversion.
@Test
public void testTreeConversion() throws Exception {
HashTree tree = new ListedHashTree();
JMeterTreeNode root = new JMeterTreeNode(new Arguments(), null);
tree.add(root, root);
tree.getTree(root).add(root, root);
save.convertSubTree(tree);
assertEquals(tree.getArray()[0].getClass().getName(), root.getTestElement().getClass().getName());
tree = tree.getTree(tree.getArray()[0]);
assertEquals(tree.getArray()[0].getClass().getName(), root.getTestElement().getClass().getName());
assertEquals(tree.getTree(tree.getArray()[0]).getArray()[0].getClass().getName(), root.getTestElement().getClass().getName());
}
use of org.apache.jorphan.collections.ListedHashTree in project jmeter by apache.
the class TestTestCompiler method testConfigGathering.
@Test
public void testConfigGathering() throws Exception {
ListedHashTree testing = new ListedHashTree();
GenericController controller = new GenericController();
ConfigTestElement config1 = new ConfigTestElement();
config1.setName("config1");
config1.setProperty("test.property", "A test value");
TestSampler sampler = new TestSampler();
sampler.setName("sampler");
testing.add(controller, config1);
testing.add(controller, sampler);
TestCompiler.initialize();
TestCompiler compiler = new TestCompiler(testing);
testing.traverse(compiler);
sampler = (TestSampler) compiler.configureSampler(sampler).getSampler();
assertEquals("A test value", sampler.getPropertyAsString("test.property"));
}
Aggregations