Search in sources :

Example 36 with JMeterProperty

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

the class PackageTest method testParseExample3.

@Test
public void testParseExample3() throws Exception {
    StringProperty prop = new StringProperty("html", "${__regexFunction(<html>(.*)</html>,$1$)}" + "${__regexFunction(<html>(.*o)(.*o)(.*)</html>," + "$1$$3$)}");
    JMeterProperty newProp = transformer.transformValue(prop);
    newProp.setRunningVersion(true);
    assertEquals("org.apache.jmeter.testelement.property.FunctionProperty", newProp.getClass().getName());
    assertEquals("hello worldhellorld", newProp.getStringValue());
}
Also used : JMeterProperty(org.apache.jmeter.testelement.property.JMeterProperty) StringProperty(org.apache.jmeter.testelement.property.StringProperty) Test(org.junit.Test)

Example 37 with JMeterProperty

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

the class PackageTest method testParseExample2.

@Test
public void testParseExample2() throws Exception {
    StringProperty prop = new StringProperty("html", "It should say:\\${${__regexFunction(<html>(.*)</html>,$1$)}}");
    JMeterProperty newProp = transformer.transformValue(prop);
    newProp.setRunningVersion(true);
    assertEquals("org.apache.jmeter.testelement.property.FunctionProperty", newProp.getClass().getName());
    assertEquals("It should say:${hello world}", newProp.getStringValue());
}
Also used : JMeterProperty(org.apache.jmeter.testelement.property.JMeterProperty) StringProperty(org.apache.jmeter.testelement.property.StringProperty) Test(org.junit.Test)

Example 38 with JMeterProperty

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

the class PackageTest method testFunctionParse1.

@Test
public void testFunctionParse1() throws Exception {
    StringProperty prop = new StringProperty("date", "${__javaScript((new Date().getDate() / 100).toString()." + "substr(${__javaScript(1+1,d\\,ay)}\\,2),heute)}");
    JMeterProperty newProp = transformer.transformValue(prop);
    newProp.setRunningVersion(true);
    assertEquals("org.apache.jmeter.testelement.property.FunctionProperty", newProp.getClass().getName());
    newProp.recoverRunningVersion(null);
    assertTrue(Integer.parseInt(newProp.getStringValue()) > -1);
    assertEquals("2", jmctx.getVariables().getObject("d,ay"));
}
Also used : JMeterProperty(org.apache.jmeter.testelement.property.JMeterProperty) StringProperty(org.apache.jmeter.testelement.property.StringProperty) Test(org.junit.Test)

Example 39 with JMeterProperty

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

the class PackageTest method testParseExample11.

// Escaped dollar commma and backslash with no variable reference
@Test
public void testParseExample11() throws Exception {
    StringProperty prop = new StringProperty("html", "\\$a \\, \\\\ \\x \\ jakarta.apache.org");
    JMeterProperty newProp = transformer.transformValue(prop);
    newProp.setRunningVersion(true);
    assertEquals("org.apache.jmeter.testelement.property.StringProperty", newProp.getClass().getName());
    assertEquals("\\$a \\, \\\\ \\x \\ jakarta.apache.org", newProp.getStringValue());
}
Also used : JMeterProperty(org.apache.jmeter.testelement.property.JMeterProperty) StringProperty(org.apache.jmeter.testelement.property.StringProperty) Test(org.junit.Test)

Example 40 with JMeterProperty

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

the class GuiPackage method getTestElementCheckSum.

/**
     * Compute checksum of TestElement to detect changes
     * the method calculates properties checksum to detect testelement
     * modifications
     * TODO would be better to override hashCode for TestElement, but I decided not to touch it
     *
     * @param el {@link TestElement}
     * @return int checksum
     */
private int getTestElementCheckSum(TestElement el) {
    int ret = el.getClass().hashCode();
    PropertyIterator it = el.propertyIterator();
    while (it.hasNext()) {
        JMeterProperty obj = it.next();
        if (obj instanceof TestElementProperty) {
            ret ^= getTestElementCheckSum(((TestElementProperty) obj).getElement());
        } else {
            ret ^= obj.getName().hashCode();
            String stringValue = obj.getStringValue();
            if (stringValue != null) {
                ret ^= stringValue.hashCode();
            } else {
                if (log.isDebugEnabled()) {
                    log.debug("obj.getStringValue() returned null for test element:" + el.getName() + " at property:" + obj.getName());
                }
            }
        }
    }
    return ret;
}
Also used : JMeterProperty(org.apache.jmeter.testelement.property.JMeterProperty) TestElementProperty(org.apache.jmeter.testelement.property.TestElementProperty) PropertyIterator(org.apache.jmeter.testelement.property.PropertyIterator)

Aggregations

JMeterProperty (org.apache.jmeter.testelement.property.JMeterProperty)87 StringProperty (org.apache.jmeter.testelement.property.StringProperty)23 Test (org.junit.Test)23 PropertyIterator (org.apache.jmeter.testelement.property.PropertyIterator)13 CollectionProperty (org.apache.jmeter.testelement.property.CollectionProperty)12 Argument (org.apache.jmeter.config.Argument)11 ArrayList (java.util.ArrayList)9 HTTPArgument (org.apache.jmeter.protocol.http.util.HTTPArgument)8 File (java.io.File)7 Arguments (org.apache.jmeter.config.Arguments)7 HTTPFileArg (org.apache.jmeter.protocol.http.util.HTTPFileArg)6 TestElement (org.apache.jmeter.testelement.TestElement)6 ConfigTestElement (org.apache.jmeter.config.ConfigTestElement)5 URL (java.net.URL)4 TestElementProperty (org.apache.jmeter.testelement.property.TestElementProperty)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 HashMap (java.util.HashMap)3 Sampler (org.apache.jmeter.samplers.Sampler)3 TestPlan (org.apache.jmeter.testelement.TestPlan)3 NullProperty (org.apache.jmeter.testelement.property.NullProperty)3