Search in sources :

Example 6 with TestPlan

use of org.apache.jmeter.testelement.TestPlan in project jmeter by apache.

the class TestPlanGui method configure.

/**
     * A newly created component can be initialized with the contents of a Test
     * Element object by calling this method. The component is responsible for
     * querying the Test Element object for the relevant information to display
     * in its GUI.
     *
     * @param el
     *            the TestElement to configure
     */
@Override
public void configure(TestElement el) {
    super.configure(el);
    if (el instanceof TestPlan) {
        TestPlan tp = (TestPlan) el;
        functionalMode.setSelected(tp.isFunctionalMode());
        serializedMode.setSelected(tp.isSerialized());
        tearDownOnShutdown.setSelected(tp.isTearDownOnShutdown());
        final JMeterProperty udv = tp.getUserDefinedVariablesAsProperty();
        if (udv != null) {
            argsPanel.configure((Arguments) udv.getObjectValue());
        }
        browseJar.setFiles(tp.getTestPlanClasspathArray());
    }
}
Also used : JMeterProperty(org.apache.jmeter.testelement.property.JMeterProperty) TestPlan(org.apache.jmeter.testelement.TestPlan)

Example 7 with TestPlan

use of org.apache.jmeter.testelement.TestPlan in project jmeter by apache.

the class TestValueReplacer method replaceWord.

private String replaceWord(String matchRegex, String testData) throws Exception {
    TestPlan plan = new TestPlan();
    plan.addParameter("domainMatcher", matchRegex);
    ValueReplacer replacer = new ValueReplacer(plan);
    TestElement element = new TestPlan();
    element.setProperty(new StringProperty("mail", testData));
    replacer.reverseReplace(element, true);
    return element.getPropertyAsString("mail");
}
Also used : TestPlan(org.apache.jmeter.testelement.TestPlan) StringProperty(org.apache.jmeter.testelement.property.StringProperty) ConfigTestElement(org.apache.jmeter.config.ConfigTestElement) TestElement(org.apache.jmeter.testelement.TestElement)

Example 8 with TestPlan

use of org.apache.jmeter.testelement.TestPlan in project jmeter by apache.

the class TestValueReplacer method testOverlappingMatches.

@Test
public void testOverlappingMatches() throws Exception {
    TestPlan plan = new TestPlan();
    plan.addParameter("longMatch", "servername");
    plan.addParameter("shortMatch", ".*");
    ValueReplacer replacer = new ValueReplacer(plan);
    TestElement element = new TestPlan();
    element.setProperty(new StringProperty("domain", "servername.domain"));
    replacer.reverseReplace(element, true);
    String replacedDomain = element.getPropertyAsString("domain");
    assertEquals("${${shortMatch}", replacedDomain);
}
Also used : TestPlan(org.apache.jmeter.testelement.TestPlan) StringProperty(org.apache.jmeter.testelement.property.StringProperty) ConfigTestElement(org.apache.jmeter.config.ConfigTestElement) TestElement(org.apache.jmeter.testelement.TestElement) Test(org.junit.Test)

Example 9 with TestPlan

use of org.apache.jmeter.testelement.TestPlan in project jmeter by apache.

the class TestValueReplacer method testReverseReplacement.

@Test
public void testReverseReplacement() throws Exception {
    ValueReplacer replacer = new ValueReplacer(variables);
    assertTrue(variables.getUserDefinedVariables().containsKey("server"));
    assertTrue(replacer.containsKey("server"));
    TestElement element = new TestPlan();
    element.setProperty(new StringProperty("domain", "jakarta.apache.org"));
    List<Object> argsin = new ArrayList<>();
    argsin.add("username is jack");
    argsin.add("his_password");
    element.setProperty(new CollectionProperty("args", argsin));
    replacer.reverseReplace(element);
    assertEquals("${server}", element.getPropertyAsString("domain"));
    @SuppressWarnings("unchecked") List<JMeterProperty> args = (List<JMeterProperty>) element.getProperty("args").getObjectValue();
    assertEquals("username is ${username}", args.get(0).getStringValue());
    assertEquals("${password}", args.get(1).getStringValue());
}
Also used : CollectionProperty(org.apache.jmeter.testelement.property.CollectionProperty) JMeterProperty(org.apache.jmeter.testelement.property.JMeterProperty) TestPlan(org.apache.jmeter.testelement.TestPlan) ArrayList(java.util.ArrayList) StringProperty(org.apache.jmeter.testelement.property.StringProperty) ArrayList(java.util.ArrayList) List(java.util.List) ConfigTestElement(org.apache.jmeter.config.ConfigTestElement) TestElement(org.apache.jmeter.testelement.TestElement) Test(org.junit.Test)

Example 10 with TestPlan

use of org.apache.jmeter.testelement.TestPlan in project jmeter by apache.

the class TestValueReplacer method setUp.

@Before
public void setUp() {
    variables = new TestPlan();
    variables.addParameter("server", "jakarta.apache.org");
    variables.addParameter("username", "jack");
    // The following used to be jacks_password, but the Arguments class uses
    // HashMap for which the order is not defined.
    variables.addParameter("password", "his_password");
    variables.addParameter("normal_regex", "Hello .*");
    variables.addParameter("bounded_regex", "(<.*>)");
    JMeterVariables vars = new JMeterVariables();
    vars.put("server", "jakarta.apache.org");
    JMeterContextService.getContext().setVariables(vars);
    JMeterContextService.getContext().setSamplingStarted(true);
}
Also used : JMeterVariables(org.apache.jmeter.threads.JMeterVariables) TestPlan(org.apache.jmeter.testelement.TestPlan) Before(org.junit.Before)

Aggregations

TestPlan (org.apache.jmeter.testelement.TestPlan)23 TestElement (org.apache.jmeter.testelement.TestElement)12 JMeterTreeNode (org.apache.jmeter.gui.tree.JMeterTreeNode)7 ConfigTestElement (org.apache.jmeter.config.ConfigTestElement)6 JMeterVariables (org.apache.jmeter.threads.JMeterVariables)6 ValueReplacer (org.apache.jmeter.engine.util.ValueReplacer)5 WorkBench (org.apache.jmeter.testelement.WorkBench)4 JMeterProperty (org.apache.jmeter.testelement.property.JMeterProperty)4 StringProperty (org.apache.jmeter.testelement.property.StringProperty)4 Test (org.junit.Test)4 Arguments (org.apache.jmeter.config.Arguments)3 IllegalUserActionException (org.apache.jmeter.exceptions.IllegalUserActionException)3 CollectionProperty (org.apache.jmeter.testelement.property.CollectionProperty)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Controller (org.apache.jmeter.control.Controller)2 InvalidVariableException (org.apache.jmeter.functions.InvalidVariableException)2 JMeterTreeModel (org.apache.jmeter.gui.tree.JMeterTreeModel)2 HTTPArgument (org.apache.jmeter.protocol.http.util.HTTPArgument)2 ResultCollector (org.apache.jmeter.reporters.ResultCollector)2