Search in sources :

Example 16 with TestElement

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

the class AuthPanel method createTestElement.

@Override
public TestElement createTestElement() {
    AuthManager authMan = tableModel.manager;
    configureTestElement(authMan);
    authMan.setClearEachIteration(clearEachIteration.isSelected());
    return (TestElement) authMan.clone();
}
Also used : AuthManager(org.apache.jmeter.protocol.http.control.AuthManager) TestElement(org.apache.jmeter.testelement.TestElement)

Example 17 with TestElement

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

the class TestValueReplacer method testReplace.

@Test
public void testReplace() throws Exception {
    ValueReplacer replacer = new ValueReplacer();
    replacer.setUserDefinedVariables(variables.getUserDefinedVariables());
    TestElement element = new ConfigTestElement();
    element.setProperty(new StringProperty("domain", "${server}"));
    replacer.replaceValues(element);
    element.setRunningVersion(true);
    assertEquals("jakarta.apache.org", element.getPropertyAsString("domain"));
}
Also used : StringProperty(org.apache.jmeter.testelement.property.StringProperty) ConfigTestElement(org.apache.jmeter.config.ConfigTestElement) TestElement(org.apache.jmeter.testelement.TestElement) ConfigTestElement(org.apache.jmeter.config.ConfigTestElement) Test(org.junit.Test)

Example 18 with TestElement

use of org.apache.jmeter.testelement.TestElement 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 19 with TestElement

use of org.apache.jmeter.testelement.TestElement 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 20 with TestElement

use of org.apache.jmeter.testelement.TestElement 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)

Aggregations

TestElement (org.apache.jmeter.testelement.TestElement)83 Test (org.junit.Test)27 ConfigTestElement (org.apache.jmeter.config.ConfigTestElement)26 TestSampler (org.apache.jmeter.junit.stubs.TestSampler)21 JMeterTreeNode (org.apache.jmeter.gui.tree.JMeterTreeNode)18 TestPlan (org.apache.jmeter.testelement.TestPlan)12 ArrayList (java.util.ArrayList)9 IllegalUserActionException (org.apache.jmeter.exceptions.IllegalUserActionException)9 StringProperty (org.apache.jmeter.testelement.property.StringProperty)7 Controller (org.apache.jmeter.control.Controller)6 JMeterTreeModel (org.apache.jmeter.gui.tree.JMeterTreeModel)6 JMeterProperty (org.apache.jmeter.testelement.property.JMeterProperty)6 TreePath (javax.swing.tree.TreePath)5 GuiPackage (org.apache.jmeter.gui.GuiPackage)5 ActionEvent (java.awt.event.ActionEvent)4 IOException (java.io.IOException)4 LinkedList (java.util.LinkedList)4 Arguments (org.apache.jmeter.config.Arguments)4 WorkBench (org.apache.jmeter.testelement.WorkBench)4 TestElementProperty (org.apache.jmeter.testelement.property.TestElementProperty)4