Search in sources :

Example 41 with TestSampler

use of org.apache.jmeter.junit.stubs.TestSampler in project jmeter by apache.

the class TestLoopController method testInfiniteLoop.

@Test
public void testInfiniteLoop() throws Exception {
    LoopController loop = new LoopController();
    loop.setLoops(LoopController.INFINITE_LOOP_COUNT);
    loop.addTestElement(new TestSampler("never run"));
    loop.setRunningVersion(true);
    loop.initialize();
    for (int i = 0; i < 42; i++) {
        assertNotNull(loop.next());
    }
}
Also used : TestSampler(org.apache.jmeter.junit.stubs.TestSampler) Test(org.junit.Test)

Example 42 with TestSampler

use of org.apache.jmeter.junit.stubs.TestSampler in project jmeter by apache.

the class TestLoopController method testLoopZeroTimes.

@Test
public void testLoopZeroTimes() throws Exception {
    LoopController loop = new LoopController();
    loop.setLoops(0);
    loop.addTestElement(new TestSampler("never run"));
    loop.initialize();
    assertNull(loop.next());
}
Also used : TestSampler(org.apache.jmeter.junit.stubs.TestSampler) Test(org.junit.Test)

Example 43 with TestSampler

use of org.apache.jmeter.junit.stubs.TestSampler in project jmeter by apache.

the class TestIfController method testProcessingTrueWithExpression.

@Test
public void testProcessingTrueWithExpression() throws Exception {
    LoopController controller = new LoopController();
    controller.setLoops(2);
    controller.addTestElement(new TestSampler("Sample1"));
    IfController ifCont = new IfController("true");
    ifCont.setUseExpression(true);
    ifCont.setEvaluateAll(false);
    ifCont.addTestElement(new TestSampler("Sample2"));
    TestSampler sample3 = new TestSampler("Sample3");
    ifCont.addTestElement(sample3);
    controller.addTestElement(ifCont);
    String[] order = new String[] { "Sample1", "Sample2", "Sample3", "Sample1", "Sample2", "Sample3" };
    int counter = 0;
    controller.initialize();
    controller.setRunningVersion(true);
    ifCont.setRunningVersion(true);
    Sampler sampler = null;
    while ((sampler = controller.next()) != null) {
        sampler.sample(null);
        assertEquals(order[counter], sampler.getName());
        counter++;
    }
    assertEquals(counter, 6);
}
Also used : DebugSampler(org.apache.jmeter.sampler.DebugSampler) TestSampler(org.apache.jmeter.junit.stubs.TestSampler) Sampler(org.apache.jmeter.samplers.Sampler) TestSampler(org.apache.jmeter.junit.stubs.TestSampler) Test(org.junit.Test)

Aggregations

TestSampler (org.apache.jmeter.junit.stubs.TestSampler)43 Test (org.junit.Test)36 TestElement (org.apache.jmeter.testelement.TestElement)21 Sampler (org.apache.jmeter.samplers.Sampler)7 DebugSampler (org.apache.jmeter.sampler.DebugSampler)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)2 CompoundVariable (org.apache.jmeter.engine.util.CompoundVariable)2 ReplaceStringWithFunctions (org.apache.jmeter.engine.util.ReplaceStringWithFunctions)2 ValueReplacer (org.apache.jmeter.engine.util.ValueReplacer)2 JMeterProperty (org.apache.jmeter.testelement.property.JMeterProperty)2 StringProperty (org.apache.jmeter.testelement.property.StringProperty)2 JMeterContext (org.apache.jmeter.threads.JMeterContext)2 JMeterVariables (org.apache.jmeter.threads.JMeterVariables)2