use of org.apache.jmeter.testelement.property.JMeterProperty in project jmeter by apache.
the class TestValueReplacer method testReverseReplacement.
@Test
public void testReverseReplacement() throws Exception {
ValueReplacer replacer = new ValueReplacer(variables);
assertTrue(variables.getUserDefinedVariables().containsKey("server"));
assertTrue(replacer.containsKey("server"));
TestElement element = new TestPlan();
element.setProperty(new StringProperty("domain", "jakarta.apache.org"));
List<Object> argsin = new ArrayList<>();
argsin.add("username is jack");
argsin.add("his_password");
element.setProperty(new CollectionProperty("args", argsin));
replacer.reverseReplace(element);
assertEquals("${server}", element.getPropertyAsString("domain"));
@SuppressWarnings("unchecked") List<JMeterProperty> args = (List<JMeterProperty>) element.getProperty("args").getObjectValue();
assertEquals("username is ${username}", args.get(0).getStringValue());
assertEquals("${password}", args.get(1).getStringValue());
}
use of org.apache.jmeter.testelement.property.JMeterProperty in project jmeter by apache.
the class TestTreeCloner method testCloning.
@Test
public void testCloning() throws Exception {
ListedHashTree original = new ListedHashTree();
GenericController controller = new GenericController();
controller.setName("controller");
Arguments args = new Arguments();
args.setName("args");
TestPlan plan = new TestPlan();
plan.addParameter("server", "jakarta");
original.add(controller, args);
original.add(plan);
ResultCollector listener = new ResultCollector();
listener.setName("Collector");
original.add(controller, listener);
TreeCloner cloner = new TreeCloner();
original.traverse(cloner);
ListedHashTree newTree = cloner.getClonedTree();
assertTrue(original != newTree);
assertEquals(original.size(), newTree.size());
assertEquals(original.getTree(original.getArray()[0]).size(), newTree.getTree(newTree.getArray()[0]).size());
assertTrue(original.getArray()[0] != newTree.getArray()[0]);
assertEquals(((GenericController) original.getArray()[0]).getName(), ((GenericController) newTree.getArray()[0]).getName());
assertSame(original.getTree(original.getArray()[0]).getArray()[1], newTree.getTree(newTree.getArray()[0]).getArray()[1]);
TestPlan clonedTestPlan = (TestPlan) newTree.getArray()[1];
clonedTestPlan.setRunningVersion(true);
clonedTestPlan.recoverRunningVersion();
assertTrue(!plan.getUserDefinedVariablesAsProperty().isRunningVersion());
assertTrue(clonedTestPlan.getUserDefinedVariablesAsProperty().isRunningVersion());
Arguments vars = (Arguments) plan.getUserDefinedVariablesAsProperty().getObjectValue();
PropertyIterator iter = ((CollectionProperty) vars.getProperty(Arguments.ARGUMENTS)).iterator();
while (iter.hasNext()) {
JMeterProperty argProp = iter.next();
assertTrue(!argProp.isRunningVersion());
assertTrue(argProp.getObjectValue() instanceof Argument);
Argument arg = (Argument) argProp.getObjectValue();
arg.setValue("yahoo");
assertEquals("yahoo", arg.getValue());
}
vars = (Arguments) clonedTestPlan.getUserDefinedVariablesAsProperty().getObjectValue();
iter = vars.propertyIterator();
while (iter.hasNext()) {
assertTrue(iter.next().isRunningVersion());
}
}
use of org.apache.jmeter.testelement.property.JMeterProperty in project jmeter by apache.
the class PackageTest method testParseExample7.
@Test
public void testParseExample7() throws Exception {
StringProperty prop = new StringProperty("html", "${__regexFunction(\\<([a-z]*)\\>,$1$)}");
JMeterProperty newProp = transformer.transformValue(prop);
newProp.setRunningVersion(true);
assertEquals("org.apache.jmeter.testelement.property.FunctionProperty", newProp.getClass().getName());
assertEquals("html", newProp.getStringValue());
}
use of org.apache.jmeter.testelement.property.JMeterProperty in project jmeter by apache.
the class PackageTest method testParseExample1.
@Test
public void testParseExample1() throws Exception {
StringProperty prop = new StringProperty("html", "${__regexFunction(<html>(.*)</html>,$1$)}");
JMeterProperty newProp = transformer.transformValue(prop);
newProp.setRunningVersion(true);
assertEquals("org.apache.jmeter.testelement.property.FunctionProperty", newProp.getClass().getName());
assertEquals("hello world", newProp.getStringValue());
}
use of org.apache.jmeter.testelement.property.JMeterProperty in project jmeter by apache.
the class PackageTest method testParseExample6.
@Test
public void testParseExample6() throws Exception {
StringProperty prop = new StringProperty("html", "${server}");
JMeterProperty newProp = transformer.transformValue(prop);
newProp.setRunningVersion(true);
assertEquals("org.apache.jmeter.testelement.property.FunctionProperty", newProp.getClass().getName());
assertEquals("jakarta.apache.org", newProp.getStringValue());
}
Aggregations