Search in sources :

Example 26 with CompoundVariable

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

the class TestJavascriptFunction method testReplace1.

@Test
public void testReplace1() throws Exception {
    params.add(new CompoundVariable("sampleResult.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 27 with CompoundVariable

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

the class TestJavascriptFunction method testReplace2.

@Test
public void testReplace2() throws Exception {
    vars.put("URL", "/query.cgi?s1=1&s2=2&s3=3");
    params.add(new CompoundVariable("vars.get('URL').replaceAll('&','&')"));
    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)

Example 28 with CompoundVariable

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

the class TestJexl2Function method testReplace1.

@Test
public void testReplace1() throws Exception {
    params.add(new CompoundVariable("sampleResult.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 29 with CompoundVariable

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

the class TestSetProperty method testSetPropertyNoReturn.

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

Example 30 with CompoundVariable

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

the class TestMachineIPName method testMachineNameWithVar.

@Test
public void testMachineNameWithVar() throws Exception {
    function = new MachineName();
    params.add(new CompoundVariable("HOST_NAME"));
    function.setParameters(params);
    String ret = function.execute(result, null);
    assertEquals(JMeterUtils.getLocalHostName(), ret);
    assertEquals(JMeterUtils.getLocalHostName(), vars.get("HOST_NAME"));
}
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