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