Search in sources :

Example 6 with StringProperty

use of org.apache.jmeter.testelement.property.StringProperty in project jmeter by apache.

the class LDAPSampler method getBasicAttributes.

/**
     * This will create the Basic Attributes for the In build TestCase for Add
     * Test.
     *
     * @return the BasicAttributes
     */
private BasicAttributes getBasicAttributes() {
    BasicAttributes basicattributes = new BasicAttributes();
    //$NON-NLS-1$
    BasicAttribute basicattribute = new BasicAttribute("objectclass");
    //$NON-NLS-1$
    basicattribute.add("top");
    //$NON-NLS-1$
    basicattribute.add("person");
    //$NON-NLS-1$
    basicattribute.add("organizationalPerson");
    //$NON-NLS-1$
    basicattribute.add("inetOrgPerson");
    basicattributes.put(basicattribute);
    //$NON-NLS-1$
    String s1 = "User";
    //$NON-NLS-1$
    String s3 = "Test";
    //$NON-NLS-1$
    String s5 = "user";
    //$NON-NLS-1$
    String s6 = "test";
    COUNTER.incrementAndGet();
    //$NON-NLS-1$
    basicattributes.put(new BasicAttribute("givenname", s1));
    //$NON-NLS-1$
    basicattributes.put(new BasicAttribute("sn", s3));
    //$NON-NLS-1$ //$NON-NLS-2$
    basicattributes.put(new BasicAttribute("cn", "TestUser" + COUNTER.get()));
    //$NON-NLS-1$
    basicattributes.put(new BasicAttribute("uid", s5));
    //$NON-NLS-1$
    basicattributes.put(new BasicAttribute("userpassword", s6));
    //$NON-NLS-1$
    setProperty(new StringProperty(ADD, "cn=TestUser" + COUNTER.get()));
    return basicattributes;
}
Also used : BasicAttribute(javax.naming.directory.BasicAttribute) BasicAttributes(javax.naming.directory.BasicAttributes) StringProperty(org.apache.jmeter.testelement.property.StringProperty)

Example 7 with StringProperty

use of org.apache.jmeter.testelement.property.StringProperty 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 8 with StringProperty

use of org.apache.jmeter.testelement.property.StringProperty 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 9 with StringProperty

use of org.apache.jmeter.testelement.property.StringProperty 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 10 with StringProperty

use of org.apache.jmeter.testelement.property.StringProperty 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

StringProperty (org.apache.jmeter.testelement.property.StringProperty)47 Test (org.junit.Test)26 JMeterProperty (org.apache.jmeter.testelement.property.JMeterProperty)23 ConfigTestElement (org.apache.jmeter.config.ConfigTestElement)9 TestElement (org.apache.jmeter.testelement.TestElement)7 TestPlan (org.apache.jmeter.testelement.TestPlan)4 TestElementProperty (org.apache.jmeter.testelement.property.TestElementProperty)3 BeanInfo (java.beans.BeanInfo)2 IntrospectionException (java.beans.IntrospectionException)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 ResourceBundle (java.util.ResourceBundle)2 CompoundVariable (org.apache.jmeter.engine.util.CompoundVariable)2 ReplaceStringWithFunctions (org.apache.jmeter.engine.util.ReplaceStringWithFunctions)2 TestSampler (org.apache.jmeter.junit.stubs.TestSampler)2 BooleanProperty (org.apache.jmeter.testelement.property.BooleanProperty)2 CollectionProperty (org.apache.jmeter.testelement.property.CollectionProperty)2 NullProperty (org.apache.jmeter.testelement.property.NullProperty)2 JMeterContext (org.apache.jmeter.threads.JMeterContext)2