Search in sources :

Example 21 with CompoundVariable

use of org.apache.jmeter.engine.util.CompoundVariable in project jmeter by apache.

the class CSVReadFunctionTest method setCSVReadParams.

// Create the CSVRead function and set its parameters.
private static CSVRead setCSVReadParams(String p1, String p2) throws Exception {
    CSVRead cr = new CSVRead();
    Collection<CompoundVariable> parms = new LinkedList<>();
    if (p1 != null) {
        parms.add(new CompoundVariable(p1));
    }
    if (p2 != null) {
        parms.add(new CompoundVariable(p2));
    }
    cr.setParameters(parms);
    return cr;
}
Also used : CompoundVariable(org.apache.jmeter.engine.util.CompoundVariable) LinkedList(java.util.LinkedList)

Example 22 with CompoundVariable

use of org.apache.jmeter.engine.util.CompoundVariable in project jmeter by apache.

the class PackageTest method setCSVReadParams.

// Create the CSVRead function and set its parameters.
private static CSVRead setCSVReadParams(String p1, String p2) throws Exception {
    CSVRead cr = new CSVRead();
    Collection<CompoundVariable> parms = new LinkedList<>();
    if (p1 != null) {
        parms.add(new CompoundVariable(p1));
    }
    if (p2 != null) {
        parms.add(new CompoundVariable(p2));
    }
    cr.setParameters(parms);
    return cr;
}
Also used : CompoundVariable(org.apache.jmeter.engine.util.CompoundVariable) LinkedList(java.util.LinkedList)

Example 23 with CompoundVariable

use of org.apache.jmeter.engine.util.CompoundVariable in project jmeter by apache.

the class StringFromFileFunctionTest method SFFParams.

// Create the StringFromFile function and set its parameters.
private static StringFromFile SFFParams(String p1, String p2, String p3, String p4) throws Exception {
    StringFromFile sff = new StringFromFile();
    Collection<CompoundVariable> parms = new LinkedList<>();
    if (p1 != null) {
        parms.add(new CompoundVariable(p1));
    }
    if (p2 != null) {
        parms.add(new CompoundVariable(p2));
    }
    if (p3 != null) {
        parms.add(new CompoundVariable(p3));
    }
    if (p4 != null) {
        parms.add(new CompoundVariable(p4));
    }
    sff.setParameters(parms);
    return sff;
}
Also used : CompoundVariable(org.apache.jmeter.engine.util.CompoundVariable) LinkedList(java.util.LinkedList)

Example 24 with CompoundVariable

use of org.apache.jmeter.engine.util.CompoundVariable in project jmeter by apache.

the class SumFunctionTest method checkSum.

// Perform a sum and check the results
private void checkSum(AbstractFunction func, String value, String[] addends) throws Exception {
    Collection<CompoundVariable> parms = new LinkedList<>();
    for (String addend : addends) {
        parms.add(new CompoundVariable(addend));
    }
    parms.add(new CompoundVariable("Result"));
    func.setParameters(parms);
    assertEquals(value, func.execute(null, null));
    assertEquals(value, vars.getObject("Result"));
}
Also used : CompoundVariable(org.apache.jmeter.engine.util.CompoundVariable) LinkedList(java.util.LinkedList)

Example 25 with CompoundVariable

use of org.apache.jmeter.engine.util.CompoundVariable in project jmeter by apache.

the class TestGroovyFunction method testReplace2.

@Test
public void testReplace2() throws Exception {
    vars.put("URL", "/query.cgi?s1=1&amp;s2=2&amp;s3=3");
    params.add(new CompoundVariable("vars.get('URL').replaceAll('&amp;','&')"));
    params.add(new CompoundVariable("URL"));
    function.setParameters(params);
    String ret = function.execute(result, null);
    assertEquals("/query.cgi?s1=1&s2=2&s3=3", ret);
    assertEquals(ret, vars.getObject("URL"));
}
Also used : CompoundVariable(org.apache.jmeter.engine.util.CompoundVariable) Test(org.junit.Test)

Aggregations

CompoundVariable (org.apache.jmeter.engine.util.CompoundVariable)103 Test (org.junit.Test)77 JMeterVariables (org.apache.jmeter.threads.JMeterVariables)16 LinkedList (java.util.LinkedList)9 JMeterContext (org.apache.jmeter.threads.JMeterContext)7 File (java.io.File)4 IOException (java.io.IOException)3 LocalDateTime (java.time.LocalDateTime)3 HashMap (java.util.HashMap)2 ReplaceStringWithFunctions (org.apache.jmeter.engine.util.ReplaceStringWithFunctions)2 InvalidVariableException (org.apache.jmeter.functions.InvalidVariableException)2 TestSampler (org.apache.jmeter.junit.stubs.TestSampler)2 JMeterProperty (org.apache.jmeter.testelement.property.JMeterProperty)2 StringProperty (org.apache.jmeter.testelement.property.StringProperty)2 JMeterStopThreadException (org.apache.jorphan.util.JMeterStopThreadException)2 BufferedReader (java.io.BufferedReader)1 FileReader (java.io.FileReader)1 DecimalFormat (java.text.DecimalFormat)1 LocalDate (java.time.LocalDate)1 ArrayList (java.util.ArrayList)1