org.apache.jmeter.control.Controller Java Examples

The following examples show how to use org.apache.jmeter.control.Controller. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WeightedSwitchController.java    From jmeter-bzm-plugins with Apache License 2.0 6 votes vote down vote up
@Override
public Sampler next() {
    if (chosen) {
        Sampler result = super.next();

        if (result == null || currentCopy != current) {
            reset();
            for (TestElement element : super.getSubControllers()) {
                if (element instanceof Controller) {
                    resetController((Controller) element);
                }
            }
            return null;
        }
        return result;
    } else {
        chosen = true;
        choose();
        return super.next();
    }
}
 
Example #2
Source File: WeightedSwitchControllerGui.java    From jmeter-bzm-plugins with Apache License 2.0 6 votes vote down vote up
private Map<JMeterTreeNode, Boolean> getChildItems(JMeterTreeNode root, WeightedSwitchController element) {
    Map<JMeterTreeNode, Boolean> result = new LinkedHashMap<>();
    for (int i = 0; i < root.getChildCount(); i++) {
        JMeterTreeNode child = (JMeterTreeNode) root.getChildAt(i);

        TestElement te = child.getTestElement();
        if (element != root.getTestElement()) {
            result.putAll(getChildItems(child, element));
        } else {
            if (te instanceof Sampler || te instanceof Controller) {
                result.put(child, te.isEnabled());
            }
        }
    }
    return result;
}
 
Example #3
Source File: DebuggerTest.java    From jmeter-debugger with Apache License 2.0 6 votes vote down vote up
@Test
public void testMain() throws Exception {
    TestJMeterUtils.createJmeterEnv();
    TestProvider treeProvider = new TestProvider();
    Debugger dbg = new Debugger(treeProvider, new FrontendMock());
    dbg.selectThreadGroup(treeProvider.getTG(0));

    Debugger.toggleBreakpoint(treeProvider.getTG(0));

    dbg.start();
    Thread.sleep(5000);
    Assert.assertFalse(dbg.isContinuing());
    Assert.assertTrue(dbg.getCurrentElement() instanceof Controller);
    dbg.proceed();
    Thread.sleep(1000);
    dbg.proceed();
    Assert.assertTrue(dbg.getCurrentSampler() != null);
    Thread.sleep(1000);
    dbg.continueRun();
    Thread.sleep(2000);
    dbg.pause();
    Thread.sleep(1000);
    dbg.stop();
}
 
Example #4
Source File: ParallelSampler.java    From jmeter-bzm-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public void addTestElement(TestElement te) {
    if (te instanceof Controller || te instanceof Sampler) {
        controllers.add(te);
    }
    log.debug("Added {}, list size: {}", te, controllers.size());
}
 
Example #5
Source File: WeightedSwitchController.java    From jmeter-bzm-plugins with Apache License 2.0 5 votes vote down vote up
private void resetController(Controller element) {
    if (element instanceof TransactionController) {
        if (element.getPropertyAsBoolean("TransactionController.parent")) {
            // we should skip org.apache.jmeter.control.TransactionController.triggerEndOfLoop(),
            // because org.apache.jmeter.control.TransactionController.transactionSampler is NULL,
            // but we should call GenericController.triggerEndOfLoop() or GenericController.reInitialize()
            // for reInit this controller
            reInitializeController((TransactionController) element);
            return;
        } else {
            // when currentCopy != current && result != null we should
            // set org.apache.jmeter.control.TransactionController.res = null
            // because if it is not null org.apache.jmeter.control.TransactionController.triggerEndOfLoop()
            // will generate new parent Sample
            nullifyRes((TransactionController) element);
        }
    } else if (element instanceof GenericController) {
        // reset all nested controllers
        GenericController ctrl = (GenericController) element;
        List<TestElement> subControllersAndSamplers = getSubControllersAndSamplers(ctrl);
        for (TestElement te : subControllersAndSamplers) {
            if (te instanceof Controller) {
                resetController((Controller) te);
            }
        }
    }
    element.triggerEndOfLoop();
}
 
Example #6
Source File: TestPlanCheckTool.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public void addNode(Object node, HashTree subTree) {
    if (node instanceof AbstractThreadGroup) {
        tGroups++;
    } else if (node instanceof Controller) {
        controllers++;
    } else if (node instanceof Sampler) {
        samplers++;
    } else if (node instanceof AbstractListenerElement) {
        listeners++;
    } else if (node instanceof PreProcessor) {
        preProc++;
    } else if (node instanceof PostProcessor) {
        postProc++;
    } else if (node instanceof Assertion) {
        assertions++;
    } else if (node instanceof Timer) {
        timers++;
    } else if (node instanceof ConfigElement) {
        configs++;
    } else if (node instanceof TestPlan) {
        log.debug("Ok, we got the root of test plan");
    } else if (node instanceof WorkBench) {
        log.debug("Ok, we got the root of test plan");
    } else {
        log.warn("Strange object in tree: " + node);
        others++;
    }
}
 
Example #7
Source File: ControllerDebugGui.java    From jmeter-debugger with Apache License 2.0 4 votes vote down vote up
@Override
public Controller getOriginal() {
    return original;
}
 
Example #8
Source File: ControllerDebugGui.java    From jmeter-debugger with Apache License 2.0 4 votes vote down vote up
@Override
public void setOriginal(Controller orig) {
    original = orig;
}