Search in sources :

Example 1 with CounterConfig

use of org.apache.jmeter.modifiers.CounterConfig in project jmeter by apache.

the class CounterConfigGui method modifyTestElement.

/**
     * Modifies a given TestElement to mirror the data in the gui components.
     *
     * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
     */
@Override
public void modifyTestElement(TestElement c) {
    if (c instanceof CounterConfig) {
        CounterConfig config = (CounterConfig) c;
        config.setStart(startField.getText());
        config.setEnd(endField.getText());
        config.setIncrement(incrField.getText());
        config.setVarName(varNameField.getText());
        config.setFormat(formatField.getText());
        config.setIsPerUser(perUserField.isSelected());
        config.setResetOnThreadGroupIteration(resetCounterOnEachThreadGroupIteration.isEnabled() && resetCounterOnEachThreadGroupIteration.isSelected());
    }
    super.configureTestElement(c);
}
Also used : CounterConfig(org.apache.jmeter.modifiers.CounterConfig)

Example 2 with CounterConfig

use of org.apache.jmeter.modifiers.CounterConfig 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 3 with CounterConfig

use of org.apache.jmeter.modifiers.CounterConfig in project jmeter by apache.

the class CounterConfigGui method configure.

@Override
public void configure(TestElement element) {
    super.configure(element);
    CounterConfig config = (CounterConfig) element;
    startField.setText(config.getStartAsString());
    endField.setText(config.getEndAsString());
    incrField.setText(config.getIncrementAsString());
    formatField.setText(config.getFormat());
    varNameField.setText(config.getVarName());
    perUserField.setSelected(config.isPerUser());
    if (config.isPerUser()) {
        resetCounterOnEachThreadGroupIteration.setEnabled(true);
        resetCounterOnEachThreadGroupIteration.setSelected(config.isResetOnThreadGroupIteration());
    } else {
        resetCounterOnEachThreadGroupIteration.setEnabled(false);
    }
}
Also used : CounterConfig(org.apache.jmeter.modifiers.CounterConfig)

Example 4 with CounterConfig

use of org.apache.jmeter.modifiers.CounterConfig in project jmeter by apache.

the class CounterConfigGui method createTestElement.

/**
     * @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
     */
@Override
public TestElement createTestElement() {
    CounterConfig config = new CounterConfig();
    modifyTestElement(config);
    return config;
}
Also used : CounterConfig(org.apache.jmeter.modifiers.CounterConfig)

Aggregations

CounterConfig (org.apache.jmeter.modifiers.CounterConfig)4 Arguments (org.apache.jmeter.config.Arguments)1 TestSampler (org.apache.jmeter.junit.stubs.TestSampler)1 DebugSampler (org.apache.jmeter.sampler.DebugSampler)1 Sampler (org.apache.jmeter.samplers.Sampler)1 JMeterContext (org.apache.jmeter.threads.JMeterContext)1 JMeterVariables (org.apache.jmeter.threads.JMeterVariables)1 Test (org.junit.Test)1