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);
}
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);
}
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;
}
Aggregations