Search in sources :

Example 56 with CompoundVariable

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

the class TestSetProperty method testSetPropertyWithReturn.

@Test
public void testSetPropertyWithReturn() throws Exception {
    params.add(new CompoundVariable("prop1"));
    params.add(new CompoundVariable("value1"));
    params.add(new CompoundVariable("true"));
    function.setParameters(params);
    String returnValue = function.execute(result, null);
    assertEquals("value1", JMeterUtils.getProperty("prop1"));
    Assert.assertNull(returnValue);
    params.clear();
    params.add(new CompoundVariable("prop1"));
    params.add(new CompoundVariable("value2"));
    params.add(new CompoundVariable("true"));
    function.setParameters(params);
    returnValue = function.execute(result, null);
    assertEquals("value2", JMeterUtils.getProperty("prop1"));
    assertEquals("value1", returnValue);
}
Also used : CompoundVariable(org.apache.jmeter.engine.util.CompoundVariable) Test(org.junit.Test)

Example 57 with CompoundVariable

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

the class TestSimpleFunctions method testEscapeXml.

@Test
public void testEscapeXml() throws Exception {
    AbstractFunction function = new EscapeXml();
    params.add(new CompoundVariable("\"bread\" & <'butter'>"));
    function.setParameters(params);
    String ret = function.execute(result, null);
    assertEquals("&quot;bread&quot; &amp; &lt;&apos;butter&apos;&gt;", ret);
}
Also used : CompoundVariable(org.apache.jmeter.engine.util.CompoundVariable) Test(org.junit.Test)

Example 58 with CompoundVariable

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

the class TestGroovyFunction method testFileLoading.

@Test
public void testFileLoading() throws Exception {
    JMeterUtils.setProperty("groovy.utilities", "bin/utility.groovy");
    params.add(new CompoundVariable("factorial(10)"));
    function.setParameters(params);
    String ret = function.execute(result, null);
    assertEquals("3628800", ret);
}
Also used : CompoundVariable(org.apache.jmeter.engine.util.CompoundVariable) Test(org.junit.Test)

Example 59 with CompoundVariable

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

the class TestGroovyFunction method testReplace1.

@Test
public void testReplace1() throws Exception {
    params.add(new CompoundVariable("prev.getResponseDataAsString().replaceAll('T','t')"));
    function.setParameters(params);
    String ret = function.execute(result, null);
    assertEquals("the quick brown fox", ret);
}
Also used : CompoundVariable(org.apache.jmeter.engine.util.CompoundVariable) Test(org.junit.Test)

Example 60 with CompoundVariable

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

the class TestGroovyFunction method testSumVar.

@Test
public void testSumVar() throws Exception {
    params.add(new CompoundVariable("1+2+3"));
    params.add(new CompoundVariable("TOTAL"));
    function.setParameters(params);
    String ret = function.execute(result, null);
    assertEquals("6", ret);
    assertEquals("6", vars.get("TOTAL"));
}
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