use of org.apache.jmeter.config.Arguments in project jmeter by apache.
the class TestIfController method testBug53768.
/**
* See Bug 53768
*
* @throws Exception
* if something fails
*/
@Test
public void testBug53768() throws Exception {
LoopController controller = new LoopController();
controller.setLoops(1);
controller.setContinueForever(false);
Arguments arguments = new Arguments();
arguments.addArgument("VAR1", "0", "=");
DebugSampler debugSampler1 = new DebugSampler();
debugSampler1.setName("VAR1 = ${VAR1}");
IfController ifCont = new IfController("true==false");
ifCont.setUseExpression(false);
ifCont.setEvaluateAll(false);
IfController ifCont2 = new IfController("true==true");
ifCont2.setUseExpression(false);
ifCont2.setEvaluateAll(false);
CounterConfig counterConfig = new CounterConfig();
counterConfig.setStart(1);
counterConfig.setIncrement(1);
counterConfig.setVarName("VAR1");
DebugSampler debugSampler2 = new DebugSampler();
debugSampler2.setName("VAR1 = ${VAR1}");
controller.addTestElement(arguments);
controller.addTestElement(debugSampler1);
controller.addTestElement(ifCont);
ifCont.addTestElement(ifCont2);
ifCont2.addTestElement(counterConfig);
controller.addTestElement(debugSampler2);
controller.initialize();
controller.setRunningVersion(true);
ifCont.setRunningVersion(true);
ifCont2.setRunningVersion(true);
counterConfig.setRunningVersion(true);
arguments.setRunningVersion(true);
debugSampler1.setRunningVersion(true);
debugSampler2.setRunningVersion(true);
ifCont2.addIterationListener(counterConfig);
JMeterVariables vars = new JMeterVariables();
JMeterContext jmctx = JMeterContextService.getContext();
jmctx.setVariables(vars);
vars.put("VAR1", "0");
try {
Sampler sampler = controller.next();
sampler.sample(null);
assertEquals("0", vars.get("VAR1"));
sampler = controller.next();
sampler.sample(null);
assertEquals("0", vars.get("VAR1"));
} catch (StackOverflowError e) {
fail("Stackoverflow occurred in testStackOverflow");
}
}
use of org.apache.jmeter.config.Arguments in project jmeter by apache.
the class BackendListener method sampleOccurred.
/* (non-Javadoc)
* @see org.apache.jmeter.samplers.SampleListener#sampleOccurred(org.apache.jmeter.samplers.SampleEvent)
*/
@Override
public void sampleOccurred(SampleEvent event) {
Arguments args = getArguments();
BackendListenerContext context = new BackendListenerContext(args);
SampleResult sr = listenerClientData.client.createSampleResult(context, event.getResult());
if (sr == null) {
if (log.isDebugEnabled()) {
log.debug("{} => Dropping SampleResult: {}", getName(), event.getResult());
}
return;
}
try {
if (!listenerClientData.queue.offer(sr)) {
// we failed to add the element first time
listenerClientData.queueWaits.add(1L);
long t1 = System.nanoTime();
listenerClientData.queue.put(sr);
long t2 = System.nanoTime();
listenerClientData.queueWaitTime.add(t2 - t1);
}
} catch (Exception err) {
log.error("sampleOccurred, failed to queue the sample", err);
}
}
use of org.apache.jmeter.config.Arguments in project jmeter by apache.
the class ArgumentsPanel method createTestElement.
/* Implements JMeterGUIComponent.createTestElement() */
@Override
public TestElement createTestElement() {
Arguments args = new Arguments();
modifyTestElement(args);
return args;
}
use of org.apache.jmeter.config.Arguments in project jmeter by apache.
the class ArgumentsPanel method modifyTestElement.
/* Implements JMeterGUIComponent.modifyTestElement(TestElement) */
@Override
public void modifyTestElement(TestElement args) {
GuiUtils.stopTableEditing(table);
if (args instanceof Arguments) {
Arguments arguments = (Arguments) args;
arguments.clear();
// only contains Argument (or HTTPArgument)
@SuppressWarnings("unchecked") Iterator<Argument> modelData = (Iterator<Argument>) tableModel.iterator();
while (modelData.hasNext()) {
Argument arg = modelData.next();
if (StringUtils.isEmpty(arg.getName()) && StringUtils.isEmpty(arg.getValue())) {
continue;
}
// $NON-NLS-1$
arg.setMetaData("=");
arguments.addArgument(arg);
}
}
super.configureTestElement(args);
}
use of org.apache.jmeter.config.Arguments in project jmeter by apache.
the class HTTPArgumentsPanel method createTestElement.
@Override
public TestElement createTestElement() {
Arguments args = getUnclonedParameters();
super.configureTestElement(args);
return (TestElement) args.clone();
}
Aggregations