Search in sources :

Example 1 with TestAction

use of org.apache.jmeter.sampler.TestAction in project jmeter-plugins by undera.

the class ArrivalsThreadGroupTest method getListedHashTree.

public static ListedHashTree getListedHashTree(AbstractDynamicThreadGroup atg, boolean stopThread) {
    ListedHashTree tree = new ListedHashTree();
    TestAction pauser = new TestAction();
    if (stopThread) {
        pauser.setAction(TestAction.STOP);
    } else {
        pauser.setAction(TestAction.PAUSE);
    }
    pauser.setTarget(TestAction.THREAD);
    pauser.setDuration(String.valueOf(300));
    tree.add(atg, pauser);
    return tree;
}
Also used : ListedHashTree(org.apache.jorphan.collections.ListedHashTree) TestAction(org.apache.jmeter.sampler.TestAction)

Example 2 with TestAction

use of org.apache.jmeter.sampler.TestAction in project jmeter by apache.

the class TestActionGui method createTestElement.

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

Example 3 with TestAction

use of org.apache.jmeter.sampler.TestAction in project jmeter by apache.

the class TestActionGui 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 element) {
    super.configureTestElement(element);
    TestAction ta = (TestAction) element;
    ta.setAction(action);
    ta.setTarget(target);
    ta.setDuration(durationField.getText());
}
Also used : TestAction(org.apache.jmeter.sampler.TestAction)

Example 4 with TestAction

use of org.apache.jmeter.sampler.TestAction in project jmeter by apache.

the class DefaultThinkTimeCreator method createThinkTime.

@Override
public JMeterTreeNode[] createThinkTime(GuiPackage guiPackage, JMeterTreeNode parentNode) throws IllegalUserActionException {
    TestAction testAction = (TestAction) guiPackage.createTestElement(TestActionGui.class.getName());
    testAction.setAction(TestAction.PAUSE);
    testAction.setDuration("0");
    JMeterTreeNode thinkTimeNode = new JMeterTreeNode(testAction, guiPackage.getTreeModel());
    thinkTimeNode.setName("Think Time");
    RandomTimer randomTimer = (RandomTimer) guiPackage.createTestElement(DEFAULT_TIMER_IMPLEMENTATION);
    randomTimer.setDelay(DEFAULT_PAUSE);
    randomTimer.setRange(DEFAULT_RANGE);
    randomTimer.setName("Pause");
    JMeterTreeNode urtNode = new JMeterTreeNode(randomTimer, guiPackage.getTreeModel());
    return new JMeterTreeNode[] { thinkTimeNode, urtNode };
}
Also used : RandomTimer(org.apache.jmeter.timers.RandomTimer) JMeterTreeNode(org.apache.jmeter.gui.tree.JMeterTreeNode) TestAction(org.apache.jmeter.sampler.TestAction)

Example 5 with TestAction

use of org.apache.jmeter.sampler.TestAction in project jmeter-plugins by undera.

the class ConcurrencyThreadGroupTest method testStartNextLoop.

@Test
public void testStartNextLoop() throws Exception {
    JMeterContextService.getContext().setVariables(new JMeterVariables());
    TestSampleListener listener = new TestSampleListener();
    DebugSampler beforeSampler = new DebugSamplerExt();
    beforeSampler.setName("Before Test Action sampler");
    TestAction testAction = new TestAction();
    testAction.setAction(TestAction.RESTART_NEXT_LOOP);
    DebugSampler afterSampler = new DebugSamplerExt();
    afterSampler.setName("After Test Action sampler");
    ConcurrencyThreadGroup ctg = new ConcurrencyThreadGroup();
    ctg.setProperty(new StringProperty(AbstractThreadGroup.ON_SAMPLE_ERROR, AbstractThreadGroup.ON_SAMPLE_ERROR_CONTINUE));
    ctg.setRampUp("0");
    ctg.setTargetLevel("1");
    ctg.setSteps("0");
    // TODO: increase this value for debugging
    ctg.setHold("5");
    ctg.setIterationsLimit("10");
    ctg.setUnit("S");
    ListedHashTree hashTree = new ListedHashTree();
    hashTree.add(ctg);
    hashTree.add(ctg, beforeSampler);
    hashTree.add(ctg, testAction);
    hashTree.add(ctg, afterSampler);
    hashTree.add(ctg, listener);
    TestCompiler compiler = new TestCompiler(hashTree);
    hashTree.traverse(compiler);
    ListenerNotifier notifier = new ListenerNotifier();
    ctg.start(1, notifier, hashTree, new StandardJMeterEngine());
    ctg.waitThreadsStopped();
}
Also used : JMeterVariables(org.apache.jmeter.threads.JMeterVariables) ListedHashTree(org.apache.jorphan.collections.ListedHashTree) DebugSampler(org.apache.jmeter.sampler.DebugSampler) TestCompiler(org.apache.jmeter.threads.TestCompiler) StandardJMeterEngine(org.apache.jmeter.engine.StandardJMeterEngine) StringProperty(org.apache.jmeter.testelement.property.StringProperty) ListenerNotifier(org.apache.jmeter.threads.ListenerNotifier) TestAction(org.apache.jmeter.sampler.TestAction) ArrivalsThreadGroupTest(com.blazemeter.jmeter.threads.arrivals.ArrivalsThreadGroupTest) Test(org.junit.Test)

Aggregations

TestAction (org.apache.jmeter.sampler.TestAction)6 ListedHashTree (org.apache.jorphan.collections.ListedHashTree)2 ArrivalsThreadGroupTest (com.blazemeter.jmeter.threads.arrivals.ArrivalsThreadGroupTest)1 StandardJMeterEngine (org.apache.jmeter.engine.StandardJMeterEngine)1 JMeterTreeNode (org.apache.jmeter.gui.tree.JMeterTreeNode)1 DebugSampler (org.apache.jmeter.sampler.DebugSampler)1 StringProperty (org.apache.jmeter.testelement.property.StringProperty)1 JMeterVariables (org.apache.jmeter.threads.JMeterVariables)1 ListenerNotifier (org.apache.jmeter.threads.ListenerNotifier)1 TestCompiler (org.apache.jmeter.threads.TestCompiler)1 RandomTimer (org.apache.jmeter.timers.RandomTimer)1 Test (org.junit.Test)1