use of org.apache.jmeter.junit.stubs.TestSampler 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.junit.stubs.TestSampler in project jmeter by apache.
the class TestInterleaveControl method testProcessing4.
@Test
public void testProcessing4() throws Exception {
testLog.debug("Testing Interleave Controller 4");
GenericController controller = new GenericController();
InterleaveControl sub_1 = new InterleaveControl();
sub_1.setStyle(InterleaveControl.IGNORE_SUB_CONTROLLERS);
controller.addTestElement(sub_1);
GenericController sub_2 = new GenericController();
sub_2.addTestElement(new TestSampler("one"));
sub_2.addTestElement(new TestSampler("two"));
sub_1.addTestElement(sub_2);
GenericController sub_3 = new GenericController();
sub_3.addTestElement(new TestSampler("three"));
sub_3.addTestElement(new TestSampler("four"));
sub_1.addTestElement(sub_3);
String[] order = new String[] { "one", "three", "two", "four" };
int counter = 0;
controller.setRunningVersion(true);
sub_1.setRunningVersion(true);
sub_2.setRunningVersion(true);
sub_3.setRunningVersion(true);
controller.initialize();
while (counter < order.length) {
TestElement sampler = null;
while ((sampler = controller.next()) != null) {
assertEquals("failed on" + counter, order[counter], sampler.getName());
counter++;
}
}
}
use of org.apache.jmeter.junit.stubs.TestSampler in project jmeter by apache.
the class TestInterleaveControl method testProcessing2.
@Test
public void testProcessing2() throws Exception {
testLog.debug("Testing Interleave Controller 2");
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"));
sub_1.addTestElement(sub_2);
String[] order = new String[] { "one", "three", "two", "three", "four", "three", "one", "three", "two", "three", "five", "three", "one", "three", "two", "three", "six", "three", "one", "three" };
int counter = 0;
controller.setRunningVersion(true);
sub_1.setRunningVersion(true);
sub_2.setRunningVersion(true);
sub_3.setRunningVersion(true);
controller.initialize();
while (counter < order.length) {
TestElement sampler = null;
while ((sampler = controller.next()) != null) {
assertEquals("failed on " + counter, order[counter], sampler.getName());
counter++;
}
}
}
use of org.apache.jmeter.junit.stubs.TestSampler in project jmeter by apache.
the class TestInterleaveControl method testProcessing3.
@Test
public void testProcessing3() throws Exception {
testLog.debug("Testing Interleave Controller 3");
GenericController controller = new GenericController();
InterleaveControl sub_1 = new InterleaveControl();
sub_1.setStyle(InterleaveControl.USE_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"));
sub_1.addTestElement(sub_2);
String[] order = new String[] { "one", "three", "two", "three", "four", "five", "six", "seven", "four", "five", "six", "seven", "four", "five", "six", "seven", "three", "one", "three", "two", "three" };
int counter = 0;
controller.setRunningVersion(true);
sub_1.setRunningVersion(true);
sub_2.setRunningVersion(true);
sub_3.setRunningVersion(true);
controller.initialize();
while (counter < order.length) {
TestElement sampler = null;
while ((sampler = controller.next()) != null) {
assertEquals("failed on" + counter, order[counter], sampler.getName());
counter++;
}
}
}
use of org.apache.jmeter.junit.stubs.TestSampler in project jmeter by apache.
the class TestInterleaveControl method testProcessing5.
@Test
public void testProcessing5() throws Exception {
testLog.debug("Testing Interleave Controller 5");
GenericController controller = new GenericController();
InterleaveControl sub_1 = new InterleaveControl();
sub_1.setStyle(InterleaveControl.USE_SUB_CONTROLLERS);
controller.addTestElement(sub_1);
GenericController sub_2 = new GenericController();
sub_2.addTestElement(new TestSampler("one"));
sub_2.addTestElement(new TestSampler("two"));
sub_1.addTestElement(sub_2);
GenericController sub_3 = new GenericController();
sub_3.addTestElement(new TestSampler("three"));
sub_3.addTestElement(new TestSampler("four"));
sub_1.addTestElement(sub_3);
String[] order = new String[] { "one", "two", "three", "four" };
int counter = 0;
controller.setRunningVersion(true);
sub_1.setRunningVersion(true);
sub_2.setRunningVersion(true);
sub_3.setRunningVersion(true);
controller.initialize();
while (counter < order.length) {
TestElement sampler = null;
while ((sampler = controller.next()) != null) {
assertEquals("failed on" + counter, order[counter], sampler.getName());
counter++;
}
}
}
Aggregations