use of org.apache.jmeter.engine.util.CompoundVariable in project jmeter by apache.
the class TestRegexFunction method testVariableExtractionFromVariable7.
@Test
public void testVariableExtractionFromVariable7() throws Exception {
params = new LinkedList<>();
params.add(new CompoundVariable("(\\d+)\\s+(\\w+)"));
// template
params.add(new CompoundVariable("pre$1$mid$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("pre123midtimespost", match);
assertEquals("pre123midtimespost", vars.getObject("OUTVAR"));
assertEquals("123 times", vars.getObject("OUTVAR_g0"));
assertEquals("123", vars.getObject("OUTVAR_g1"));
assertEquals("times", vars.getObject("OUTVAR_g2"));
}
use of org.apache.jmeter.engine.util.CompoundVariable in project jmeter by apache.
the class TestRegexFunction method testDefaultValue.
@Test
public void testDefaultValue() throws Exception {
params = new LinkedList<>();
params.add(new CompoundVariable("<value,, field=\"(pinposition\\d+)\">(\\d+)</value>"));
params.add(new CompoundVariable("$2$, "));
params.add(new CompoundVariable(".333"));
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);
}
use of org.apache.jmeter.engine.util.CompoundVariable in project jmeter by apache.
the class TestRegexFunction method testRandomExtraction.
@Test
public void testRandomExtraction() throws Exception {
params = new LinkedList<>();
params.add(new CompoundVariable("<company-xmlext-query-ret>(.+?)</company-xmlext-query-ret>"));
params.add(new CompoundVariable("$1$"));
params.add(new CompoundVariable("RAND"));
params.add(new CompoundVariable(""));
params.add(new CompoundVariable("No Value Found"));
variable.setParameters(params);
String match = variable.execute(result, null);
assertEquals("<row>" + "<value field=\"RetCode\">" + "LIS_OK</value><value" + " field=\"RetCodeExtension\"></value>" + "<value field=\"alias\"></value><value" + " field=\"positioncount\"></value>" + "<value field=\"invalidpincount\">0</value><value" + " field=\"pinposition1\">1</value><value" + " field=\"pinpositionvalue1\"></value><value" + " field=\"pinposition2\">5</value><value" + " field=\"pinpositionvalue2\"></value><value" + " field=\"pinposition3\">6</value><value" + " field=\"pinpositionvalue3\"></value>" + "</row>", match);
}
use of org.apache.jmeter.engine.util.CompoundVariable in project jmeter by apache.
the class TestRegexFunction method testVariableExtractionFromVariable4.
@Test
public void testVariableExtractionFromVariable4() throws Exception {
params = new LinkedList<>();
params.add(new CompoundVariable("(\\d+)\\s+(\\w+)"));
// template
params.add(new CompoundVariable("pre$2$"));
// 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("pretimes", match);
assertEquals("pretimes", vars.getObject("OUTVAR"));
assertEquals("123 times", vars.getObject("OUTVAR_g0"));
assertEquals("123", vars.getObject("OUTVAR_g1"));
assertEquals("times", vars.getObject("OUTVAR_g2"));
}
use of org.apache.jmeter.engine.util.CompoundVariable in project jmeter by apache.
the class TestRegexFunction method testVariableExtraction3.
@Test
public void testVariableExtraction3() throws Exception {
params = new LinkedList<>();
params.add(new CompoundVariable("<value field=\"(pinposition\\d+)\">(\\d+)</value>"));
params.add(new CompoundVariable("_$1$"));
params.add(new CompoundVariable("2"));
variable.setParameters(params);
String match = variable.execute(result, null);
assertEquals("_pinposition2", match);
}
Aggregations