You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by Sonam Chauhan <so...@ce.com.au> on 2003/12/24 01:09:40 UTC
How can I add a JMeter property in code
Hello JMeter developers - I am trying to create a JMeter config element that
automatically initialize "JMeter variables" (not sure if this is the correct
term) from Java properties.
E.g.: If the properties were passed into JMeter at runtime:
ce.debug=...
ce.cxml.user1=...
ce.cxml.pass1=...
ce.oci.user1=...
...the new 'LoadPropertiesElement' element could take the string "ce" as
it's input, then automatically initializes JMeter variables based on the ce*
properties:
${ce.debug}
${ce.cxml.user1}
${ce.cxml.pass1}
${ce.oci.user1}
These variables can then be used in the test plan.
I created a new LoadPropertiesElement (extends AbstractTestElement) and
LoadPropertiesElementGui (extends AbstractConfigGui) and got it running.
However, I have run into problems setting the 'JMeter variables' in
LoadPropertiesElementGui.modifyTestElement(). Here is some debug code:
---------------------------------------------------------------
public void modifyTestElement(TestElement el)
{
super.configureTestElement(el);
Properties p = System.getProperties();
Enumeration e = p.propertyNames();
while (e.hasMoreElements()) {
String propName = (String) e.nextElement();
if (propName.startsWith("java")) {
System.out.println(propName);
System.out.println("---------------------");
// >>>Does not work!? <<<
el.setProperty(propName, .getProperty(propName));
}
}
}
---------------------------------------------------------------
Is what I am doing above the correct way to set 'JMeter variables'? When the
code runs, the 'java.home' property name is printed to stdout, but
${java.home} stays unsubstituted.
With regards,
Sonam Chauhan
--
Corporate Express Australia Ltd.
Phone: +61-2-9335-0725, Fax: 9335-0753, Email: sonamc@ce.com.au
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org