Search in sources :

Example 81 with CompoundVariable

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

the class TestTimeFunction method testDivisorNoMatch.

@Test
public void testDivisorNoMatch() throws Exception {
    // trailing space
    params.add(new CompoundVariable("/1000 "));
    variable.setParameters(params);
    value = variable.execute(result, null);
    assertEquals("/1000 ", value);
}
Also used : CompoundVariable(org.apache.jmeter.engine.util.CompoundVariable) Test(org.junit.Test)

Example 82 with CompoundVariable

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

the class TestTimeFunction method testYMDHMS.

@Test
public void testYMDHMS() throws Exception {
    params.add(new CompoundVariable("YMDHMS"));
    variable.setParameters(params);
    value = variable.execute(result, null);
    assertEquals(15, value.length());
}
Also used : CompoundVariable(org.apache.jmeter.engine.util.CompoundVariable) Test(org.junit.Test)

Example 83 with CompoundVariable

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

the class TestRegexFunction method testVariableExtractionFromVariable5.

@Test
public void testVariableExtractionFromVariable5() throws Exception {
    params = new LinkedList<>();
    params.add(new CompoundVariable("(\\d+)\\s+(\\w+)"));
    // template
    params.add(new CompoundVariable("$2$post"));
    // match number
    params.add(new CompoundVariable("1"));
    // ALL separator
    params.add(new CompoundVariable("-"));
    params.add(new CompoundVariable("default"));
    params.add(new CompoundVariable("OUTVAR"));
    params.add(new CompoundVariable(INPUT_VARIABLE_NAME));
    variable.setParameters(params);
    String match = variable.execute(result, null);
    assertEquals("1", vars.getObject("OUTVAR_matchNr"));
    assertEquals("timespost", match);
    assertEquals("timespost", vars.getObject("OUTVAR"));
    assertEquals("123 times", vars.getObject("OUTVAR_g0"));
    assertEquals("123", vars.getObject("OUTVAR_g1"));
    assertEquals("times", vars.getObject("OUTVAR_g2"));
}
Also used : CompoundVariable(org.apache.jmeter.engine.util.CompoundVariable) Test(org.junit.Test)

Example 84 with CompoundVariable

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

the class TestRegexFunction method testVariableExtraction.

@Test
public void testVariableExtraction() throws Exception {
    params = new LinkedList<>();
    params.add(new CompoundVariable("<value field=\"(pinposition\\d+)\">(\\d+)</value>"));
    params.add(new CompoundVariable("$2$"));
    params.add(new CompoundVariable("2"));
    variable.setParameters(params);
    String match = variable.execute(result, null);
    assertEquals("5", match);
}
Also used : CompoundVariable(org.apache.jmeter.engine.util.CompoundVariable) Test(org.junit.Test)

Example 85 with CompoundVariable

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

the class TestRegexFunction method testExtractionIndexTooHigh.

@Test
public void testExtractionIndexTooHigh() throws Exception {
    params = new LinkedList<>();
    params.add(new CompoundVariable("<value field=\"(pinposition\\d+)\">(\\d+)</value>"));
    params.add(new CompoundVariable("_$1$"));
    params.add(new CompoundVariable("10"));
    params.add(new CompoundVariable(""));
    params.add(new CompoundVariable("No Value Found"));
    variable.setParameters(params);
    String match = variable.execute(result, null);
    assertEquals("No Value Found", match);
}
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