Search in sources :

Example 11 with Controller

use of org.apache.jmeter.control.Controller in project jmeter by apache.

the class FindTestElementsUpToRootTraverser method getControllersToRoot.

/**
     * Returns all controllers that where in Tree down to nodeToFind in reverse order (from leaf to root)
     * @return List of {@link Controller}
     */
public List<Controller> getControllersToRoot() {
    List<Controller> result = new ArrayList<>(stack.size());
    LinkedList<TestElement> stackLocalCopy = new LinkedList<>(stack);
    while (!stackLocalCopy.isEmpty()) {
        TestElement te = stackLocalCopy.getLast();
        if (te instanceof Controller) {
            result.add((Controller) te);
        }
        stackLocalCopy.removeLast();
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) Controller(org.apache.jmeter.control.Controller) TestElement(org.apache.jmeter.testelement.TestElement) LinkedList(java.util.LinkedList)

Example 12 with Controller

use of org.apache.jmeter.control.Controller in project jmeter by apache.

the class ProxyControlGui method buildNodesModel.

private void buildNodesModel(JMeterTreeNode node, String parentName, int level) {
    String separator = " > ";
    if (node != null) {
        for (int i = 0; i < node.getChildCount(); i++) {
            StringBuilder name = new StringBuilder();
            JMeterTreeNode cur = (JMeterTreeNode) node.getChildAt(i);
            TestElement te = cur.getTestElement();
            /*
                 * Will never be true. Probably intended to use
                 * org.apache.jmeter.threads.ThreadGroup rather than
                 * java.lang.ThreadGroup However, that does not work correctly;
                 * whereas treating it as a Controller does. if (te instanceof
                 * ThreadGroup) { name.append(parent_name);
                 * name.append(cur.getName()); name.append(separator);
                 * buildNodesModel(cur, name.toString(), level); } else
                 */
            if (te instanceof Controller) {
                name.append(parentName);
                name.append(cur.getName());
                TreeNodeWrapper tnw = new TreeNodeWrapper(cur, name.toString());
                targetNodesModel.addElement(tnw);
                name.append(separator);
                buildNodesModel(cur, name.toString(), level + 1);
            } else if (te instanceof TestPlan || te instanceof WorkBench) {
                name.append(cur.getName());
                name.append(separator);
                buildNodesModel(cur, name.toString(), 0);
            }
        // Ignore everything else
        }
    }
}
Also used : TestPlan(org.apache.jmeter.testelement.TestPlan) TreeNodeWrapper(org.apache.jmeter.control.gui.TreeNodeWrapper) JMeterTreeNode(org.apache.jmeter.gui.tree.JMeterTreeNode) TestElement(org.apache.jmeter.testelement.TestElement) Controller(org.apache.jmeter.control.Controller) RecordingController(org.apache.jmeter.protocol.http.control.RecordingController) WorkBench(org.apache.jmeter.testelement.WorkBench)

Example 13 with Controller

use of org.apache.jmeter.control.Controller in project jmeter by apache.

the class TestCompiler method trackIterationListeners.

private void trackIterationListeners(LinkedList<TestElement> pStack) {
    TestElement child = pStack.getLast();
    if (child instanceof LoopIterationListener) {
        ListIterator<TestElement> iter = pStack.listIterator(pStack.size());
        while (iter.hasPrevious()) {
            TestElement item = iter.previous();
            if (item == child) {
                continue;
            }
            if (item instanceof Controller) {
                TestBeanHelper.prepare(child);
                ((Controller) item).addIterationListener((LoopIterationListener) child);
                break;
            }
        }
    }
}
Also used : LoopIterationListener(org.apache.jmeter.engine.event.LoopIterationListener) TestElement(org.apache.jmeter.testelement.TestElement) ConfigTestElement(org.apache.jmeter.config.ConfigTestElement) Controller(org.apache.jmeter.control.Controller) TransactionController(org.apache.jmeter.control.TransactionController)

Aggregations

Controller (org.apache.jmeter.control.Controller)13 JMeterTreeNode (org.apache.jmeter.gui.tree.JMeterTreeNode)7 TestElement (org.apache.jmeter.testelement.TestElement)6 ConfigTestElement (org.apache.jmeter.config.ConfigTestElement)3 TransactionController (org.apache.jmeter.control.TransactionController)3 TransactionSampler (org.apache.jmeter.control.TransactionSampler)3 GuiPackage (org.apache.jmeter.gui.GuiPackage)3 Sampler (org.apache.jmeter.samplers.Sampler)3 LinkedList (java.util.LinkedList)2 IllegalUserActionException (org.apache.jmeter.exceptions.IllegalUserActionException)2 JMeterGUIComponent (org.apache.jmeter.gui.JMeterGUIComponent)2 TestPlan (org.apache.jmeter.testelement.TestPlan)2 Component (java.awt.Component)1 ArrayList (java.util.ArrayList)1 JTree (javax.swing.JTree)1 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1 TreeNode (javax.swing.tree.TreeNode)1 TreePath (javax.swing.tree.TreePath)1 Assertion (org.apache.jmeter.assertions.Assertion)1 LoopController (org.apache.jmeter.control.LoopController)1