use of org.apache.jmeter.testelement.TestPlan in project jmeter by apache.
the class TestPlanGui method configure.
/**
* A newly created component can be initialized with the contents of a Test
* Element object by calling this method. The component is responsible for
* querying the Test Element object for the relevant information to display
* in its GUI.
*
* @param el
* the TestElement to configure
*/
@Override
public void configure(TestElement el) {
super.configure(el);
if (el instanceof TestPlan) {
TestPlan tp = (TestPlan) el;
functionalMode.setSelected(tp.isFunctionalMode());
serializedMode.setSelected(tp.isSerialized());
tearDownOnShutdown.setSelected(tp.isTearDownOnShutdown());
final JMeterProperty udv = tp.getUserDefinedVariablesAsProperty();
if (udv != null) {
argsPanel.configure((Arguments) udv.getObjectValue());
}
browseJar.setFiles(tp.getTestPlanClasspathArray());
}
}
use of org.apache.jmeter.testelement.TestPlan in project jmeter by apache.
the class TestValueReplacer method replaceWord.
private String replaceWord(String matchRegex, String testData) throws Exception {
TestPlan plan = new TestPlan();
plan.addParameter("domainMatcher", matchRegex);
ValueReplacer replacer = new ValueReplacer(plan);
TestElement element = new TestPlan();
element.setProperty(new StringProperty("mail", testData));
replacer.reverseReplace(element, true);
return element.getPropertyAsString("mail");
}
use of org.apache.jmeter.testelement.TestPlan in project jmeter by apache.
the class TestValueReplacer method testOverlappingMatches.
@Test
public void testOverlappingMatches() throws Exception {
TestPlan plan = new TestPlan();
plan.addParameter("longMatch", "servername");
plan.addParameter("shortMatch", ".*");
ValueReplacer replacer = new ValueReplacer(plan);
TestElement element = new TestPlan();
element.setProperty(new StringProperty("domain", "servername.domain"));
replacer.reverseReplace(element, true);
String replacedDomain = element.getPropertyAsString("domain");
assertEquals("${${shortMatch}", replacedDomain);
}
use of org.apache.jmeter.testelement.TestPlan 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.TestPlan in project jmeter by apache.
the class TestValueReplacer method setUp.
@Before
public void setUp() {
variables = new TestPlan();
variables.addParameter("server", "jakarta.apache.org");
variables.addParameter("username", "jack");
// The following used to be jacks_password, but the Arguments class uses
// HashMap for which the order is not defined.
variables.addParameter("password", "his_password");
variables.addParameter("normal_regex", "Hello .*");
variables.addParameter("bounded_regex", "(<.*>)");
JMeterVariables vars = new JMeterVariables();
vars.put("server", "jakarta.apache.org");
JMeterContextService.getContext().setVariables(vars);
JMeterContextService.getContext().setSamplingStarted(true);
}
Aggregations