Search in sources :

Example 1 with ListedHashTree

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;
}
Also used : ListedHashTree(org.apache.jorphan.collections.ListedHashTree) HashTree(org.apache.jorphan.collections.HashTree) ListedHashTree(org.apache.jorphan.collections.ListedHashTree) JMeterTreeNode(org.apache.jmeter.gui.tree.JMeterTreeNode)

Example 2 with ListedHashTree

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());
        }
    }
}
Also used : ListedHashTree(org.apache.jorphan.collections.ListedHashTree) HashTree(org.apache.jorphan.collections.HashTree) ListedHashTree(org.apache.jorphan.collections.ListedHashTree) StandardJMeterEngine(org.apache.jmeter.engine.StandardJMeterEngine) GuiPackage(org.apache.jmeter.gui.GuiPackage) TreeCloner(org.apache.jmeter.engine.TreeCloner) JMeterEngineException(org.apache.jmeter.engine.JMeterEngineException)

Example 3 with ListedHashTree

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;
}
Also used : ListedHashTree(org.apache.jorphan.collections.ListedHashTree)

Example 4 with ListedHashTree

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());
}
Also used : ListedHashTree(org.apache.jorphan.collections.ListedHashTree) HashTree(org.apache.jorphan.collections.HashTree) ListedHashTree(org.apache.jorphan.collections.ListedHashTree) Arguments(org.apache.jmeter.config.Arguments) JMeterTreeNode(org.apache.jmeter.gui.tree.JMeterTreeNode) Test(org.junit.Test)

Example 5 with ListedHashTree

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"));
}
Also used : ListedHashTree(org.apache.jorphan.collections.ListedHashTree) GenericController(org.apache.jmeter.control.GenericController) ConfigTestElement(org.apache.jmeter.config.ConfigTestElement) Test(org.junit.Test)

Aggregations

ListedHashTree (org.apache.jorphan.collections.ListedHashTree)11 HashTree (org.apache.jorphan.collections.HashTree)5 JMeterTreeNode (org.apache.jmeter.gui.tree.JMeterTreeNode)4 Test (org.junit.Test)4 IOException (java.io.IOException)2 Arguments (org.apache.jmeter.config.Arguments)2 GenericController (org.apache.jmeter.control.GenericController)2 TreeCloner (org.apache.jmeter.engine.TreeCloner)2 IllegalUserActionException (org.apache.jmeter.exceptions.IllegalUserActionException)2 GuiPackage (org.apache.jmeter.gui.GuiPackage)2 TestPlan (org.apache.jmeter.testelement.TestPlan)2 ThreadGroup (org.apache.jmeter.threads.ThreadGroup)2 ActionEvent (java.awt.event.ActionEvent)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 JFileChooser (javax.swing.JFileChooser)1 HttpHost (org.apache.http.HttpHost)1 HttpGet (org.apache.http.client.methods.HttpGet)1 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)1