Search in sources :

Example 31 with Sampler

use of org.apache.jmeter.samplers.Sampler in project jmeter by apache.

the class TestIfController method testEvaluateAllChildrenWithSubController.

/**
     * test 2 loops with a sub generic controller (sample4 doesn't execute)
     * 
     * @throws Exception
     *             if something fails
     */
@Test
public void testEvaluateAllChildrenWithSubController() throws Exception {
    LoopController controller = new LoopController();
    controller.setLoops(2);
    controller.addTestElement(new TestSampler("Sample1"));
    IfController ifCont = new IfController("true==true");
    ifCont.setEvaluateAll(true);
    controller.addTestElement(ifCont);
    ifCont.addTestElement(new TestSampler("Sample2"));
    GenericController genericCont = new GenericController();
    TestSampler sample3 = new TestSampler("Sample3");
    genericCont.addTestElement(sample3);
    TestSampler sample4 = new TestSampler("Sample4");
    genericCont.addTestElement(sample4);
    ifCont.addTestElement(genericCont);
    String[] order = new String[] { "Sample1", "Sample2", "Sample3", "Sample1", "Sample2", "Sample3" };
    int counter = 0;
    controller.initialize();
    controller.setRunningVersion(true);
    ifCont.setRunningVersion(true);
    genericCont.setRunningVersion(true);
    Sampler sampler = null;
    while ((sampler = controller.next()) != null) {
        sampler.sample(null);
        if (sampler.getName().equals("Sample3")) {
            ifCont.setCondition("true==false");
        }
        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)

Example 32 with Sampler

use of org.apache.jmeter.samplers.Sampler 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)

Example 33 with Sampler

use of org.apache.jmeter.samplers.Sampler in project jmeter by apache.

the class InterleaveControl method nextIsAController.

/**
     * {@inheritDoc}
     */
@Override
protected Sampler nextIsAController(Controller controller) throws NextIsNullException {
    Sampler sampler = controller.next();
    if (sampler == null) {
        currentReturnedNull(controller);
        return next();
    }
    currentReturnedAtLeastOne = true;
    if (getStyle() == IGNORE_SUB_CONTROLLERS) {
        incrementCurrent();
        skipNext = true;
    } else {
        searchStart = null;
    }
    return sampler;
}
Also used : Sampler(org.apache.jmeter.samplers.Sampler)

Aggregations

Sampler (org.apache.jmeter.samplers.Sampler)33 SampleResult (org.apache.jmeter.samplers.SampleResult)11 TestSampler (org.apache.jmeter.junit.stubs.TestSampler)9 JMeterContext (org.apache.jmeter.threads.JMeterContext)9 Test (org.junit.Test)9 TransactionSampler (org.apache.jmeter.control.TransactionSampler)6 DebugSampler (org.apache.jmeter.sampler.DebugSampler)6 JMeterVariables (org.apache.jmeter.threads.JMeterVariables)5 Controller (org.apache.jmeter.control.Controller)3 HTTPSamplerBase (org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase)3 JMeterProperty (org.apache.jmeter.testelement.property.JMeterProperty)3 JMeterStopTestException (org.apache.jorphan.util.JMeterStopTestException)3 JMeterStopTestNowException (org.apache.jorphan.util.JMeterStopTestNowException)3 JMeterStopThreadException (org.apache.jorphan.util.JMeterStopThreadException)3 Logger (org.slf4j.Logger)3 Properties (java.util.Properties)2 Argument (org.apache.jmeter.config.Argument)2 CompoundVariable (org.apache.jmeter.engine.util.CompoundVariable)2 TestElement (org.apache.jmeter.testelement.TestElement)2 Cache (com.github.benmanes.caffeine.cache.Cache)1