Search in sources :

Example 1 with GenericController

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

the class ProxyControl method addSimpleController.

/**
     * Helper method to add a Simple 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
     * @throws InvocationTargetException
     * @throws InterruptedException
     */
private void addSimpleController(final JMeterTreeModel model, final JMeterTreeNode node, String name) throws InterruptedException, InvocationTargetException {
    final GenericController sc = new GenericController();
    sc.setProperty(TestElement.GUI_CLASS, LOGIC_CONTROLLER_GUI);
    sc.setName(name);
    safelyAddComponent(model, node, sc);
}
Also used : GenericController(org.apache.jmeter.control.GenericController)

Example 2 with GenericController

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

the class TestTestCompiler method testConfigGathering.

@Test
public void testConfigGathering() throws Exception {
    ListedHashTree testing = new ListedHashTree();
    GenericController controller = new GenericController();
    ConfigTestElement config1 = new ConfigTestElement();
    config1.setName("config1");
    config1.setProperty("test.property", "A test value");
    TestSampler sampler = new TestSampler();
    sampler.setName("sampler");
    testing.add(controller, config1);
    testing.add(controller, sampler);
    TestCompiler.initialize();
    TestCompiler compiler = new TestCompiler(testing);
    testing.traverse(compiler);
    sampler = (TestSampler) compiler.configureSampler(sampler).getSampler();
    assertEquals("A test value", sampler.getPropertyAsString("test.property"));
}
Also used : ListedHashTree(org.apache.jorphan.collections.ListedHashTree) GenericController(org.apache.jmeter.control.GenericController) ConfigTestElement(org.apache.jmeter.config.ConfigTestElement) Test(org.junit.Test)

Example 3 with GenericController

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

the class TestTreeCloner method testCloning.

@Test
public void testCloning() throws Exception {
    ListedHashTree original = new ListedHashTree();
    GenericController controller = new GenericController();
    controller.setName("controller");
    Arguments args = new Arguments();
    args.setName("args");
    TestPlan plan = new TestPlan();
    plan.addParameter("server", "jakarta");
    original.add(controller, args);
    original.add(plan);
    ResultCollector listener = new ResultCollector();
    listener.setName("Collector");
    original.add(controller, listener);
    TreeCloner cloner = new TreeCloner();
    original.traverse(cloner);
    ListedHashTree newTree = cloner.getClonedTree();
    assertTrue(original != newTree);
    assertEquals(original.size(), newTree.size());
    assertEquals(original.getTree(original.getArray()[0]).size(), newTree.getTree(newTree.getArray()[0]).size());
    assertTrue(original.getArray()[0] != newTree.getArray()[0]);
    assertEquals(((GenericController) original.getArray()[0]).getName(), ((GenericController) newTree.getArray()[0]).getName());
    assertSame(original.getTree(original.getArray()[0]).getArray()[1], newTree.getTree(newTree.getArray()[0]).getArray()[1]);
    TestPlan clonedTestPlan = (TestPlan) newTree.getArray()[1];
    clonedTestPlan.setRunningVersion(true);
    clonedTestPlan.recoverRunningVersion();
    assertTrue(!plan.getUserDefinedVariablesAsProperty().isRunningVersion());
    assertTrue(clonedTestPlan.getUserDefinedVariablesAsProperty().isRunningVersion());
    Arguments vars = (Arguments) plan.getUserDefinedVariablesAsProperty().getObjectValue();
    PropertyIterator iter = ((CollectionProperty) vars.getProperty(Arguments.ARGUMENTS)).iterator();
    while (iter.hasNext()) {
        JMeterProperty argProp = iter.next();
        assertTrue(!argProp.isRunningVersion());
        assertTrue(argProp.getObjectValue() instanceof Argument);
        Argument arg = (Argument) argProp.getObjectValue();
        arg.setValue("yahoo");
        assertEquals("yahoo", arg.getValue());
    }
    vars = (Arguments) clonedTestPlan.getUserDefinedVariablesAsProperty().getObjectValue();
    iter = vars.propertyIterator();
    while (iter.hasNext()) {
        assertTrue(iter.next().isRunningVersion());
    }
}
Also used : ListedHashTree(org.apache.jorphan.collections.ListedHashTree) CollectionProperty(org.apache.jmeter.testelement.property.CollectionProperty) JMeterProperty(org.apache.jmeter.testelement.property.JMeterProperty) Argument(org.apache.jmeter.config.Argument) TestPlan(org.apache.jmeter.testelement.TestPlan) Arguments(org.apache.jmeter.config.Arguments) PropertyIterator(org.apache.jmeter.testelement.property.PropertyIterator) GenericController(org.apache.jmeter.control.GenericController) ResultCollector(org.apache.jmeter.reporters.ResultCollector) Test(org.junit.Test)

Example 4 with GenericController

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

the class GenerateTreeGui method addSimpleController.

/**
     * Helper method to add a Simple Controller to contain the elements.
     * 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
     * @return the new node
     */
private JMeterTreeNode addSimpleController(JMeterTreeModel model, JMeterTreeNode node, String name) {
    final TestElement sc = new GenericController();
    sc.setProperty(TestElement.GUI_CLASS, LOGIC_CONTROLLER_GUI);
    // Use old style
    sc.setProperty(TestElement.NAME, name);
    return addToTree(model, node, sc);
}
Also used : GenericController(org.apache.jmeter.control.GenericController) TestElement(org.apache.jmeter.testelement.TestElement) ConfigTestElement(org.apache.jmeter.config.ConfigTestElement)

Example 5 with GenericController

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

the class ProxyControl method addDivider.

/**
     * Helper method to add a Divider
     * Called from Application Thread that needs to update GUI (JMeterTreeModel)
     */
private void addDivider(final JMeterTreeModel model, final JMeterTreeNode node) {
    final GenericController sc = new GenericController();
    sc.setProperty(TestElement.GUI_CLASS, LOGIC_CONTROLLER_GUI);
    // $NON-NLS-1$
    sc.setName("-------------------");
    safelyAddComponent(model, node, sc);
}
Also used : GenericController(org.apache.jmeter.control.GenericController)

Aggregations

GenericController (org.apache.jmeter.control.GenericController)7 ConfigTestElement (org.apache.jmeter.config.ConfigTestElement)3 TestElement (org.apache.jmeter.testelement.TestElement)2 ListedHashTree (org.apache.jorphan.collections.ListedHashTree)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 MalformedURLException (java.net.MalformedURLException)1 GeneralSecurityException (java.security.GeneralSecurityException)1 UnrecoverableKeyException (java.security.UnrecoverableKeyException)1 CertificateExpiredException (java.security.cert.CertificateExpiredException)1 CertificateNotYetValidException (java.security.cert.CertificateNotYetValidException)1 Argument (org.apache.jmeter.config.Argument)1 Arguments (org.apache.jmeter.config.Arguments)1 IllegalUserActionException (org.apache.jmeter.exceptions.IllegalUserActionException)1 InvalidVariableException (org.apache.jmeter.functions.InvalidVariableException)1 JMeterTreeModel (org.apache.jmeter.gui.tree.JMeterTreeModel)1 JMeterTreeNode (org.apache.jmeter.gui.tree.JMeterTreeNode)1 ResultCollector (org.apache.jmeter.reporters.ResultCollector)1 TestPlan (org.apache.jmeter.testelement.TestPlan)1