use of org.apache.jmeter.junit.stubs.TestSampler in project jmeter by apache.
the class TestOnceOnlyController method testProcessing.
@Test
public void testProcessing() throws Exception {
GenericController controller = new GenericController();
GenericController sub_1 = new OnceOnlyController();
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"));
controller.addTestElement(sub_2);
String[] interleaveOrder = new String[] { "one", "two" };
String[] order = new String[] { "", "", "three", "four", "five", "six", "seven", "four", "five", "six", "seven", "four", "five", "six", "seven" };
int counter = 15;
controller.setRunningVersion(true);
sub_1.setRunningVersion(true);
sub_2.setRunningVersion(true);
sub_3.setRunningVersion(true);
controller.initialize();
for (int i = 0; i < 4; i++) {
assertEquals(15, counter);
counter = 0;
if (i > 0) {
counter = 2;
}
TestElement sampler = null;
while ((sampler = controller.next()) != null) {
if (i == 0 && counter < 2) {
assertEquals(interleaveOrder[counter], sampler.getName());
} else {
assertEquals(order[counter], sampler.getName());
}
counter++;
}
}
}
use of org.apache.jmeter.junit.stubs.TestSampler in project jmeter by apache.
the class TestSamplerNameFunction method testSamplerNameWithVar.
@Test
public void testSamplerNameWithVar() throws Exception {
variable.setParameters(params);
TestSampler sampler = new TestSampler("UnitTestSampler");
variable.setParameters(FunctionTestHelper.makeParams("var1", null, null));
value = variable.execute(result, sampler);
assertEquals("UnitTestSampler", value);
assertEquals("UnitTestSampler", vars.get("var1"));
}
use of org.apache.jmeter.junit.stubs.TestSampler in project jmeter by apache.
the class TestSamplerNameFunction method testSamplerName.
@Test
public void testSamplerName() throws Exception {
variable.setParameters(params);
TestSampler sampler = new TestSampler("UnitTestSampler");
value = variable.execute(result, sampler);
assertEquals("UnitTestSampler", value);
}
use of org.apache.jmeter.junit.stubs.TestSampler in project jmeter by apache.
the class TestLoopController method testBug54467.
@Test
public void testBug54467() throws Exception {
JMeterContext jmctx = JMeterContextService.getContext();
LoopController loop = new LoopController();
Map<String, String> variables = new HashMap<>();
ReplaceStringWithFunctions transformer = new ReplaceStringWithFunctions(new CompoundVariable(), variables);
jmctx.setVariables(new JMeterVariables());
StringProperty prop = new StringProperty(LoopController.LOOPS, "${__Random(1,12,)}");
JMeterProperty newProp = transformer.transformValue(prop);
newProp.setRunningVersion(true);
loop.setProperty(newProp);
loop.addTestElement(new TestSampler("random run"));
loop.setRunningVersion(true);
loop.initialize();
int loops = loop.getLoops();
for (int i = 0; i < loops; i++) {
Sampler s = loop.next();
assertNotNull(s);
}
assertNull(loop.next());
}
use of org.apache.jmeter.junit.stubs.TestSampler in project jmeter by apache.
the class TestLoopController method testProcessing.
@Test
public void testProcessing() throws Exception {
GenericController controller = new GenericController();
GenericController sub_1 = new GenericController();
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"));
controller.addTestElement(sub_2);
String[] order = new String[] { "one", "two", "three", "four", "five", "six", "seven", "four", "five", "six", "seven", "four", "five", "six", "seven" };
int counter = 15;
controller.setRunningVersion(true);
sub_1.setRunningVersion(true);
sub_2.setRunningVersion(true);
sub_3.setRunningVersion(true);
controller.initialize();
for (int i = 0; i < 2; i++) {
assertEquals(15, counter);
counter = 0;
TestElement sampler = null;
while ((sampler = controller.next()) != null) {
assertEquals(order[counter++], sampler.getName());
}
}
}
Aggregations