use of org.apache.jmeter.engine.util.CompoundVariable in project jmeter by apache.
the class TestRegexFunction method testVariableExtraction1b.
// Test with empty output variable name
@Test
public void testVariableExtraction1b() throws Exception {
params = new LinkedList<>();
params.add(new CompoundVariable("<value field=\"(pinposition\\d+)\">(\\d+)</value>"));
// template
params.add(new CompoundVariable("$2$"));
// match number
params.add(new CompoundVariable("2"));
// ALL separator
params.add(new CompoundVariable("-"));
params.add(new CompoundVariable("default"));
params.add(new CompoundVariable(""));
variable.setParameters(params);
String match = variable.execute(result, null);
assertEquals("5", match);
assertNull(vars.getObject("OUTVAR"));
}
use of org.apache.jmeter.engine.util.CompoundVariable in project jmeter by apache.
the class TestRegexFunction method testVariableExtractionFromVariable2.
@Test
public void testVariableExtractionFromVariable2() throws Exception {
params = new LinkedList<>();
params.add(new CompoundVariable("(\\d+)\\s+(\\w+)"));
// template
params.add(new CompoundVariable("$1$$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("123times", match);
assertEquals("123times", 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 TestEscapeOroRegexpChars method testEscape2.
@Test
public void testEscape2() throws Exception {
params.add(new CompoundVariable("[^\"].+?"));
function.setParameters(params);
String ret = function.execute(result, null);
assertEquals("\\[\\^\\\"\\]\\.\\+\\?", ret);
}
use of org.apache.jmeter.engine.util.CompoundVariable in project jmeter by apache.
the class TestFileToString method testReadWithEncodingAndVar.
@Test
public void testReadWithEncodingAndVar() throws Exception {
File file = new File(JMeterUtils.getJMeterBinDir(), "jmeter.properties");
params.add(new CompoundVariable(file.getAbsolutePath()));
params.add(new CompoundVariable("UTF-8"));
params.add(new CompoundVariable("MY_FILE_AS_TEXT"));
function.setParameters(params);
String returnValue = function.execute(result, null);
Assert.assertTrue(returnValue.indexOf("language=") > 0);
Assert.assertTrue(vars.get("MY_FILE_AS_TEXT").indexOf("language=") > 0);
}
use of org.apache.jmeter.engine.util.CompoundVariable in project jmeter by apache.
the class TestFileToString method testRead.
@Test
public void testRead() throws Exception {
File file = new File(JMeterUtils.getJMeterBinDir(), "jmeter.properties");
params.add(new CompoundVariable(file.getAbsolutePath()));
function.setParameters(params);
String returnValue = function.execute(result, null);
Assert.assertTrue(returnValue.indexOf("language=") > 0);
}
Aggregations