use of org.apache.jmeter.testelement.TestElement in project jmeter by apache.
the class PreCompiler method addNode.
/** {@inheritDoc} */
@Override
public void addNode(Object node, HashTree subTree) {
if (isRemote && node instanceof ResultCollector) {
try {
replacer.replaceValues((TestElement) node);
} catch (InvalidVariableException e) {
log.error("invalid variables", e);
}
}
if (isRemote) {
return;
}
if (node instanceof TestElement) {
try {
replacer.replaceValues((TestElement) node);
} catch (InvalidVariableException e) {
log.error("invalid variables", e);
}
}
if (node instanceof TestPlan) {
//A hack to make user-defined variables in the testplan element more dynamic
((TestPlan) node).prepareForPreCompile();
Map<String, String> args = ((TestPlan) node).getUserDefinedVariables();
replacer.setUserDefinedVariables(args);
JMeterVariables vars = new JMeterVariables();
vars.putAll(args);
JMeterContextService.getContext().setVariables(vars);
}
if (node instanceof Arguments) {
((Arguments) node).setRunningVersion(true);
Map<String, String> args = ((Arguments) node).getArgumentsAsMap();
replacer.addVariables(args);
JMeterContextService.getContext().getVariables().putAll(args);
}
}
use of org.apache.jmeter.testelement.TestElement in project jmeter by apache.
the class SimpleConfigGui method createTestElement.
/* Implements JMeterGUIComponent.createTestElement() */
@Override
public TestElement createTestElement() {
TestElement el = new ConfigTestElement();
modifyTestElement(el);
return el;
}
use of org.apache.jmeter.testelement.TestElement in project jmeter by apache.
the class TestCompiler method trackIterationListeners.
private void trackIterationListeners(LinkedList<TestElement> pStack) {
TestElement child = pStack.getLast();
if (child instanceof LoopIterationListener) {
ListIterator<TestElement> iter = pStack.listIterator(pStack.size());
while (iter.hasPrevious()) {
TestElement item = iter.previous();
if (item == child) {
continue;
}
if (item instanceof Controller) {
TestBeanHelper.prepare(child);
((Controller) item).addIterationListener((LoopIterationListener) child);
break;
}
}
}
}
use of org.apache.jmeter.testelement.TestElement 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.testelement.TestElement 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++;
}
}
}
Aggregations