Search in sources :

Example 21 with TestElement

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

the class TestThroughputController method testByNumberZero.

@Test
public void testByNumberZero() throws Exception {
    ThroughputController sub_1 = new ThroughputController();
    sub_1.setStyle(ThroughputController.BYNUMBER);
    sub_1.setMaxThroughput(0);
    sub_1.addTestElement(new TestSampler("one"));
    sub_1.addTestElement(new TestSampler("two"));
    LoopController controller = new LoopController();
    controller.setLoops(5);
    controller.addTestElement(new TestSampler("zero"));
    controller.addTestElement(sub_1);
    controller.addIterationListener(sub_1);
    controller.addTestElement(new TestSampler("three"));
    String[] order = new String[] { "zero", "three", "zero", "three", "zero", "three", "zero", "three", "zero", "three" };
    int counter = 0;
    controller.setRunningVersion(true);
    sub_1.setRunningVersion(true);
    sub_1.testStarted();
    controller.initialize();
    for (int i = 0; i < 3; i++) {
        TestElement sampler = null;
        while ((sampler = controller.next()) != null) {
            assertEquals("Counter: " + counter + ", i: " + i, order[counter], sampler.getName());
            counter++;
        }
        assertEquals(counter, order.length);
        counter = 0;
    }
    sub_1.testEnded();
}
Also used : TestSampler(org.apache.jmeter.junit.stubs.TestSampler) TestElement(org.apache.jmeter.testelement.TestElement) Test(org.junit.Test)

Example 22 with TestElement

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

the class TestThroughputController method testByPercent33.

@Test
public void testByPercent33() throws Exception {
    ThroughputController sub_1 = new ThroughputController();
    sub_1.setStyle(ThroughputController.BYPERCENT);
    sub_1.setPercentThroughput(33.33f);
    sub_1.addTestElement(new TestSampler("one"));
    sub_1.addTestElement(new TestSampler("two"));
    LoopController controller = new LoopController();
    controller.setLoops(6);
    controller.addTestElement(new TestSampler("zero"));
    controller.addTestElement(sub_1);
    controller.addIterationListener(sub_1);
    controller.addTestElement(new TestSampler("three"));
    // Expected results established using the DDA
    // algorithm (see
    // http://www.siggraph.org/education/materials/HyperGraph/scanline/outprims/drawline.htm):
    String[] order = new String[] { // 0/1 vs. 1/1 -> 0 is
    "zero", // 0/2 vs. 1/2 -> 50.0 is closer to
    "three", // 0/2 vs. 1/2 -> 50.0 is closer to
    "zero", // 1/3 vs. 2/3 -> 33.33 is
    "one", // 1/3 vs. 2/3 -> 33.33 is
    "two", // 1/3 vs. 2/3 -> 33.33 is
    "three", // 1/3 vs. 2/3 -> 33.33 is
    "zero", // 1/4 vs. 2/4 -> 25.0 is closer to
    "three", // 1/4 vs. 2/4 -> 25.0 is closer to
    "zero", // 1/5 vs. 2/5 -> 40.0 is closer to
    "three", // 1/5 vs. 2/5 -> 40.0 is closer to
    "zero", // 2/6 vs. 3/6 -> 33.33 is
    "one", // 2/6 vs. 3/6 -> 33.33 is
    "two", // 2/6 vs. 3/6 -> 33.33 is
    "three", // 2/6 vs. 3/6 -> 33.33 is
    "zero", // closer to 33.33
    "three" };
    int counter = 0;
    controller.setRunningVersion(true);
    sub_1.setRunningVersion(true);
    sub_1.testStarted();
    controller.initialize();
    for (int i = 0; i < 3; i++) {
        TestElement sampler = null;
        while ((sampler = controller.next()) != null) {
            assertEquals("Counter: " + counter + ", i: " + i, order[counter], sampler.getName());
            counter++;
        }
        assertEquals(counter, order.length);
        counter = 0;
    }
    sub_1.testEnded();
}
Also used : TestSampler(org.apache.jmeter.junit.stubs.TestSampler) TestElement(org.apache.jmeter.testelement.TestElement) Test(org.junit.Test)

Example 23 with TestElement

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

the class TestThroughputController method testByNumber.

@Test
public void testByNumber() throws Exception {
    ThroughputController sub_1 = new ThroughputController();
    sub_1.setStyle(ThroughputController.BYNUMBER);
    sub_1.setMaxThroughput(2);
    sub_1.addTestElement(new TestSampler("one"));
    sub_1.addTestElement(new TestSampler("two"));
    LoopController loop = new LoopController();
    loop.setLoops(5);
    loop.addTestElement(new TestSampler("zero"));
    loop.addTestElement(sub_1);
    loop.addIterationListener(sub_1);
    loop.addTestElement(new TestSampler("three"));
    LoopController test = new LoopController();
    test.setLoops(2);
    test.addTestElement(loop);
    String[] order = new String[] { "zero", "one", "two", "three", "zero", "one", "two", "three", "zero", "three", "zero", "three", "zero", "three", "zero", "three", "zero", "three", "zero", "three", "zero", "three", "zero", "three" };
    sub_1.testStarted();
    test.setRunningVersion(true);
    sub_1.setRunningVersion(true);
    loop.setRunningVersion(true);
    test.initialize();
    for (int counter = 0; counter < order.length; counter++) {
        TestElement sampler = test.next();
        assertNotNull(sampler);
        assertEquals("Counter: " + counter, order[counter], sampler.getName());
    }
    assertNull(test.next());
    sub_1.testEnded();
}
Also used : TestSampler(org.apache.jmeter.junit.stubs.TestSampler) TestElement(org.apache.jmeter.testelement.TestElement) Test(org.junit.Test)

Example 24 with TestElement

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

the class TestGenericController method testProcessing.

@Test
public void testProcessing() throws Exception {
    testLog.debug("Testing Generic Controller");
    GenericController controller = new GenericController();
    GenericController sub_1 = new GenericController();
    sub_1.addTestElement(new TestSampler("one"));
    sub_1.addTestElement(new TestSampler("two"));
    controller.addTestElement(sub_1);
    controller.addTestElement(new TestSampler("three"));
    GenericController sub_2 = new GenericController();
    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[] order = new String[] { "one", "two", "three", "four", "five", "six", "seven" };
    int counter = 7;
    controller.initialize();
    for (int i = 0; i < 2; i++) {
        assertEquals(7, counter);
        counter = 0;
        TestElement sampler = null;
        while ((sampler = controller.next()) != null) {
            assertEquals(order[counter++], sampler.getName());
        }
    }
}
Also used : TestSampler(org.apache.jmeter.junit.stubs.TestSampler) TestElement(org.apache.jmeter.testelement.TestElement) Test(org.junit.Test)

Example 25 with TestElement

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

the class TestInterleaveControl method testProcessing.

@Test
public void testProcessing() throws Exception {
    testLog.debug("Testing Interleave Controller 1");
    GenericController controller = new GenericController();
    InterleaveControl sub_1 = new InterleaveControl();
    sub_1.setStyle(InterleaveControl.IGNORE_SUB_CONTROLLERS);
    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[] { "dummy", "three", "four", "five", "six", "seven", "four", "five", "six", "seven", "four", "five", "six", "seven" };
    int counter = 14;
    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(14, counter);
        counter = 0;
        TestElement sampler = null;
        while ((sampler = controller.next()) != null) {
            if (counter == 0) {
                assertEquals(interleaveOrder[i % 2], 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)

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