Search in sources :

Example 71 with Arguments

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");
    }
}
Also used : JMeterVariables(org.apache.jmeter.threads.JMeterVariables) DebugSampler(org.apache.jmeter.sampler.DebugSampler) JMeterContext(org.apache.jmeter.threads.JMeterContext) CounterConfig(org.apache.jmeter.modifiers.CounterConfig) DebugSampler(org.apache.jmeter.sampler.DebugSampler) TestSampler(org.apache.jmeter.junit.stubs.TestSampler) Sampler(org.apache.jmeter.samplers.Sampler) Arguments(org.apache.jmeter.config.Arguments) Test(org.junit.Test)

Example 72 with Arguments

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);
    }
}
Also used : Arguments(org.apache.jmeter.config.Arguments) SampleResult(org.apache.jmeter.samplers.SampleResult)

Example 73 with Arguments

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;
}
Also used : Arguments(org.apache.jmeter.config.Arguments)

Example 74 with Arguments

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);
}
Also used : Argument(org.apache.jmeter.config.Argument) Arguments(org.apache.jmeter.config.Arguments) Iterator(java.util.Iterator)

Example 75 with Arguments

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();
}
Also used : Arguments(org.apache.jmeter.config.Arguments) TestElement(org.apache.jmeter.testelement.TestElement)

Aggregations

Arguments (org.apache.jmeter.config.Arguments)75 Test (org.junit.Test)27 HTTPSamplerBase (org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase)18 SampleResult (org.apache.jmeter.samplers.SampleResult)15 Argument (org.apache.jmeter.config.Argument)13 HTTPArgument (org.apache.jmeter.protocol.http.util.HTTPArgument)9 JMeterProperty (org.apache.jmeter.testelement.property.JMeterProperty)7 ConfigTestElement (org.apache.jmeter.config.ConfigTestElement)5 HTTPFileArg (org.apache.jmeter.protocol.http.util.HTTPFileArg)5 JMeterTreeNode (org.apache.jmeter.gui.tree.JMeterTreeNode)3 TestElement (org.apache.jmeter.testelement.TestElement)3 TestPlan (org.apache.jmeter.testelement.TestPlan)3 TestElementProperty (org.apache.jmeter.testelement.property.TestElementProperty)3 File (java.io.File)2 Iterator (java.util.Iterator)2 InvalidVariableException (org.apache.jmeter.functions.InvalidVariableException)2 HTTPFileArgs (org.apache.jmeter.protocol.http.util.HTTPFileArgs)2 ResultCollector (org.apache.jmeter.reporters.ResultCollector)2 CollectionProperty (org.apache.jmeter.testelement.property.CollectionProperty)2 JMeterVariables (org.apache.jmeter.threads.JMeterVariables)2