Search in sources :

Example 26 with TestElement

use of org.apache.jmeter.testelement.TestElement in project jmeter by apache.

the class TestInterleaveControl method testProcessing6.

@Test
public void testProcessing6() throws Exception {
    testLog.debug("Testing Interleave Controller 6");
    GenericController controller = new GenericController();
    InterleaveControl sub_1 = new InterleaveControl();
    controller.addTestElement(new TestSampler("one"));
    sub_1.setStyle(InterleaveControl.IGNORE_SUB_CONTROLLERS);
    controller.addTestElement(sub_1);
    LoopController sub_2 = new LoopController();
    sub_1.addTestElement(sub_2);
    sub_2.setLoops(3);
    int counter = 1;
    controller.setRunningVersion(true);
    sub_1.setRunningVersion(true);
    sub_2.setRunningVersion(true);
    controller.initialize();
    for (int i = 0; i < 4; i++) {
        assertEquals(1, counter);
        counter = 0;
        TestElement sampler = null;
        while ((sampler = controller.next()) != null) {
            assertEquals("one", sampler.getName());
            counter++;
        }
    }
}
Also used : TestSampler(org.apache.jmeter.junit.stubs.TestSampler) TestElement(org.apache.jmeter.testelement.TestElement) Test(org.junit.Test)

Example 27 with TestElement

use of org.apache.jmeter.testelement.TestElement in project jmeter by apache.

the class TestOnceOnlyController method testProcessing2.

@Test
public void testProcessing2() throws Exception {
    GenericController controller = new GenericController();
    GenericController sub_1 = new OnceOnlyController();
    sub_1.addTestElement(new TestSampler("one"));
    sub_1.addTestElement(new TestSampler("two"));
    controller.addTestElement(sub_1);
    controller.addTestElement(new TestSampler("three"));
    LoopController sub_2 = new LoopController();
    sub_2.setLoops(3);
    OnceOnlyController sub_3 = new OnceOnlyController();
    sub_2.addTestElement(new TestSampler("four"));
    sub_3.addTestElement(new TestSampler("five"));
    sub_3.addTestElement(new TestSampler("six"));
    sub_2.addTestElement(sub_3);
    sub_2.addIterationListener(sub_3);
    sub_2.addTestElement(new TestSampler("seven"));
    controller.addTestElement(sub_2);
    String[] interleaveOrder = new String[] { "one", "two" };
    String[] order = new String[] { "", "", "three", "four", "five", "six", "seven", "four", "seven", "four", "seven" };
    int counter = 11;
    controller.setRunningVersion(true);
    sub_1.setRunningVersion(true);
    sub_2.setRunningVersion(true);
    sub_3.setRunningVersion(true);
    controller.initialize();
    for (int i = 0; i < 4; i++) {
        assertEquals(11, counter);
        counter = 0;
        if (i > 0) {
            counter = 2;
        }
        TestElement sampler = null;
        while ((sampler = controller.next()) != null) {
            if (i == 0 && counter < 2) {
                assertEquals(interleaveOrder[counter], sampler.getName());
            } else {
                assertEquals(order[counter], sampler.getName());
            }
            counter++;
        }
    }
}
Also used : TestSampler(org.apache.jmeter.junit.stubs.TestSampler) TestElement(org.apache.jmeter.testelement.TestElement) Test(org.junit.Test)

Example 28 with TestElement

use of org.apache.jmeter.testelement.TestElement in project jmeter by apache.

the class TestOnceOnlyController method testProcessing.

@Test
public void testProcessing() throws Exception {
    GenericController controller = new GenericController();
    GenericController sub_1 = new OnceOnlyController();
    sub_1.addTestElement(new TestSampler("one"));
    sub_1.addTestElement(new TestSampler("two"));
    controller.addTestElement(sub_1);
    controller.addTestElement(new TestSampler("three"));
    LoopController sub_2 = new LoopController();
    sub_2.setLoops(3);
    GenericController sub_3 = new GenericController();
    sub_2.addTestElement(new TestSampler("four"));
    sub_3.addTestElement(new TestSampler("five"));
    sub_3.addTestElement(new TestSampler("six"));
    sub_2.addTestElement(sub_3);
    sub_2.addTestElement(new TestSampler("seven"));
    controller.addTestElement(sub_2);
    String[] interleaveOrder = new String[] { "one", "two" };
    String[] order = new String[] { "", "", "three", "four", "five", "six", "seven", "four", "five", "six", "seven", "four", "five", "six", "seven" };
    int counter = 15;
    controller.setRunningVersion(true);
    sub_1.setRunningVersion(true);
    sub_2.setRunningVersion(true);
    sub_3.setRunningVersion(true);
    controller.initialize();
    for (int i = 0; i < 4; i++) {
        assertEquals(15, counter);
        counter = 0;
        if (i > 0) {
            counter = 2;
        }
        TestElement sampler = null;
        while ((sampler = controller.next()) != null) {
            if (i == 0 && counter < 2) {
                assertEquals(interleaveOrder[counter], sampler.getName());
            } else {
                assertEquals(order[counter], sampler.getName());
            }
            counter++;
        }
    }
}
Also used : TestSampler(org.apache.jmeter.junit.stubs.TestSampler) TestElement(org.apache.jmeter.testelement.TestElement) Test(org.junit.Test)

Example 29 with TestElement

use of org.apache.jmeter.testelement.TestElement in project jmeter by apache.

the class GuiPackage method getCurrentGui.

/**
     * Convenience method for grabbing the gui for the current node.
     *
     * @return the GUI component associated with the currently selected node
     */
public JMeterGUIComponent getCurrentGui() {
    try {
        updateCurrentNode();
        TestElement curNode = treeListener.getCurrentNode().getTestElement();
        JMeterGUIComponent comp = getGui(curNode);
        if (comp == null) {
            log.debug("No Component found for {}.", treeListener.getCurrentNode().getName());
            return null;
        }
        comp.clearGui();
        log.debug("Updating gui to new node");
        comp.configure(curNode);
        currentNodeUpdated = false;
        return comp;
    } catch (Exception e) {
        log.error("Problem retrieving gui", e);
        return null;
    }
}
Also used : TestElement(org.apache.jmeter.testelement.TestElement) IllegalUserActionException(org.apache.jmeter.exceptions.IllegalUserActionException)

Example 30 with TestElement

use of org.apache.jmeter.testelement.TestElement in project jmeter by apache.

the class GuiPackage method updateCurrentNode.

/**
     * This method should be called in order for GuiPackage to change the
     * current node. This will save any changes made to the earlier node before
     * choosing the new node.
     */
public void updateCurrentNode() {
    try {
        if (currentNode != null && !currentNodeUpdated) {
            log.debug("Updating current node " + currentNode.getName());
            JMeterGUIComponent comp = getGui(currentNode.getTestElement());
            if (comp == null) {
                log.debug("No component found for {}", currentNode.getName());
                return;
            }
            TestElement el = currentNode.getTestElement();
            int before = 0;
            int after = 0;
            final boolean historyEnabled = UndoHistory.isEnabled();
            if (historyEnabled) {
                before = getTestElementCheckSum(el);
            }
            comp.modifyTestElement(el);
            if (historyEnabled) {
                after = getTestElementCheckSum(el);
            }
            if (!historyEnabled || (before != after)) {
                // Bug 50221 - ensure label is updated
                currentNode.nameChanged();
            }
        }
        // The current node is now updated
        currentNodeUpdated = true;
        currentNode = treeListener.getCurrentNode();
    } catch (Exception e) {
        log.error("Problem retrieving gui", e);
    }
}
Also used : TestElement(org.apache.jmeter.testelement.TestElement) IllegalUserActionException(org.apache.jmeter.exceptions.IllegalUserActionException)

Aggregations

TestElement (org.apache.jmeter.testelement.TestElement)83 Test (org.junit.Test)27 ConfigTestElement (org.apache.jmeter.config.ConfigTestElement)26 TestSampler (org.apache.jmeter.junit.stubs.TestSampler)21 JMeterTreeNode (org.apache.jmeter.gui.tree.JMeterTreeNode)18 TestPlan (org.apache.jmeter.testelement.TestPlan)12 ArrayList (java.util.ArrayList)9 IllegalUserActionException (org.apache.jmeter.exceptions.IllegalUserActionException)9 StringProperty (org.apache.jmeter.testelement.property.StringProperty)7 Controller (org.apache.jmeter.control.Controller)6 JMeterTreeModel (org.apache.jmeter.gui.tree.JMeterTreeModel)6 JMeterProperty (org.apache.jmeter.testelement.property.JMeterProperty)6 TreePath (javax.swing.tree.TreePath)5 GuiPackage (org.apache.jmeter.gui.GuiPackage)5 ActionEvent (java.awt.event.ActionEvent)4 IOException (java.io.IOException)4 LinkedList (java.util.LinkedList)4 Arguments (org.apache.jmeter.config.Arguments)4 WorkBench (org.apache.jmeter.testelement.WorkBench)4 TestElementProperty (org.apache.jmeter.testelement.property.TestElementProperty)4