Search in sources :

Example 1 with TransactionController

use of org.apache.jmeter.control.TransactionController in project jmeter by apache.

the class TransactionControllerGui method createTestElement.

@Override
public TestElement createTestElement() {
    TransactionController lc = new TransactionController();
    // change default for new test elements
    lc.setIncludeTimers(false);
    configureTestElement(lc);
    return lc;
}
Also used : TransactionController(org.apache.jmeter.control.TransactionController)

Example 2 with TransactionController

use of org.apache.jmeter.control.TransactionController in project jmeter by apache.

the class TestCompiler method subtractNode.

/**
 * {@inheritDoc}
 */
@Override
public void subtractNode() {
    if (log.isDebugEnabled()) {
        log.debug("Subtracting node, stack size = {}", stack.size());
    }
    TestElement child = stack.getLast();
    trackIterationListeners(stack);
    if (child instanceof Sampler) {
        saveSamplerConfigs((Sampler) child);
    } else if (child instanceof TransactionController) {
        saveTransactionControllerConfigs((TransactionController) child);
    }
    stack.removeLast();
    if (!stack.isEmpty()) {
        TestElement parent = stack.getLast();
        boolean duplicate = false;
        // Bug 53750: this condition used to be in ObjectPair#addTestElements()
        if (parent instanceof Controller && (child instanceof Sampler || child instanceof Controller)) {
            if (parent instanceof TestCompilerHelper) {
                TestCompilerHelper te = (TestCompilerHelper) parent;
                duplicate = !te.addTestElementOnce(child);
            } else {
                // this is only possible for 3rd party controllers by default
                ObjectPair pair = new ObjectPair(child, parent);
                synchronized (PAIRING) {
                    // Called from multiple threads
                    if (!PAIRING.contains(pair)) {
                        parent.addTestElement(child);
                        PAIRING.add(pair);
                    } else {
                        duplicate = true;
                    }
                }
            }
        }
        if (duplicate) {
            if (log.isWarnEnabled()) {
                log.warn("Unexpected duplicate for {} and {}", parent.getClass(), child.getClass());
            }
        }
    }
}
Also used : TransactionSampler(org.apache.jmeter.control.TransactionSampler) Sampler(org.apache.jmeter.samplers.Sampler) TestElement(org.apache.jmeter.testelement.TestElement) ConfigTestElement(org.apache.jmeter.config.ConfigTestElement) TransactionController(org.apache.jmeter.control.TransactionController) Controller(org.apache.jmeter.control.Controller) TransactionController(org.apache.jmeter.control.TransactionController)

Example 3 with TransactionController

use of org.apache.jmeter.control.TransactionController in project jmeter by apache.

the class TestCompiler method saveTransactionControllerConfigs.

private void saveTransactionControllerConfigs(TransactionController tc) {
    List<ConfigTestElement> configs = new ArrayList<>();
    List<Controller> controllers = new ArrayList<>();
    List<SampleListener> listeners = new ArrayList<>();
    List<Timer> timers = new ArrayList<>();
    List<Assertion> assertions = new ArrayList<>();
    List<PostProcessor> posts = new ArrayList<>();
    List<PreProcessor> pres = new ArrayList<>();
    for (int i = stack.size(); i > 0; i--) {
        addDirectParentControllers(controllers, stack.get(i - 1));
        for (Object item : testTree.list(stack.subList(0, i))) {
            if (item instanceof SampleListener) {
                listeners.add((SampleListener) item);
            }
            if (item instanceof Assertion) {
                assertions.add((Assertion) item);
            }
        }
    }
    SamplePackage pack = new SamplePackage(configs, listeners, timers, assertions, posts, pres, controllers);
    pack.setSampler(new TransactionSampler(tc, tc.getName()));
    pack.setRunningVersion(true);
    transactionControllerConfigMap.put(tc, pack);
}
Also used : ArrayList(java.util.ArrayList) Assertion(org.apache.jmeter.assertions.Assertion) PreProcessor(org.apache.jmeter.processor.PreProcessor) Controller(org.apache.jmeter.control.Controller) TransactionController(org.apache.jmeter.control.TransactionController) SampleListener(org.apache.jmeter.samplers.SampleListener) Timer(org.apache.jmeter.timers.Timer) TransactionSampler(org.apache.jmeter.control.TransactionSampler) ConfigTestElement(org.apache.jmeter.config.ConfigTestElement) PostProcessor(org.apache.jmeter.processor.PostProcessor)

Example 4 with TransactionController

use of org.apache.jmeter.control.TransactionController in project jmeter by apache.

the class ProxyControl method addTransactionController.

/**
 * Helper method to add a Transaction Controller to contain the samplers.
 * Called from Application Thread that needs to update GUI (JMeterTreeModel)
 *
 * @param model Test component tree model
 * @param node  Node in the tree where we will add the Controller
 * @param name  A name for the Controller
 */
private void addTransactionController(final JMeterTreeModel model, final JMeterTreeNode node, String name) {
    final TransactionController sc = new TransactionController();
    sc.setIncludeTimers(false);
    sc.setProperty(TestElement.GUI_CLASS, TRANSACTION_CONTROLLER_GUI);
    sc.setName(name);
    safelyAddComponent(model, node, sc);
}
Also used : TransactionController(org.apache.jmeter.control.TransactionController)

Example 5 with TransactionController

use of org.apache.jmeter.control.TransactionController in project jmeter by apache.

the class TransactionControllerGui method modifyTestElement.

@Override
public void modifyTestElement(TestElement el) {
    configureTestElement(el);
    ((TransactionController) el).setGenerateParentSample(generateParentSample.isSelected());
    TransactionController tc = (TransactionController) el;
    tc.setGenerateParentSample(generateParentSample.isSelected());
    tc.setIncludeTimers(includeTimers.isSelected());
}
Also used : TransactionController(org.apache.jmeter.control.TransactionController)

Aggregations

TransactionController (org.apache.jmeter.control.TransactionController)6 ConfigTestElement (org.apache.jmeter.config.ConfigTestElement)2 Controller (org.apache.jmeter.control.Controller)2 TransactionSampler (org.apache.jmeter.control.TransactionSampler)2 ArrayList (java.util.ArrayList)1 Assertion (org.apache.jmeter.assertions.Assertion)1 PostProcessor (org.apache.jmeter.processor.PostProcessor)1 PreProcessor (org.apache.jmeter.processor.PreProcessor)1 SampleListener (org.apache.jmeter.samplers.SampleListener)1 Sampler (org.apache.jmeter.samplers.Sampler)1 TestElement (org.apache.jmeter.testelement.TestElement)1 Timer (org.apache.jmeter.timers.Timer)1