----- Original Message ----- 
From: "Sonam Chauhan" <[EMAIL PROTECTED]>
To: "'JMeter Developers List'" <[EMAIL PROTECTED]>
Sent: Monday, December 29, 2003 2:29 AM
Subject: RE: Problem initializing JMeter variables - Was "How can I add a JMeter 
property in code"


> Thanks Jordi - I downloaded the latest CVS and my code is now working
> for system properties. I ended up not subclassing ArgumentsPanel (just
> using the code you sent). This is because my GUI component is more
> primitive (single JTextField instead of table). 
> 
> Currently, the modifyTestElement method looks like this:
> ---------------------------------------------------------
> public void modifyTestElement(TestElement args)
> {
> ...
> Properties p = System.getProperties();

Could replace this with

p = JMeterUtils.getJMeterProperties();

> ...
> if ( propName.startsWith(propsPrefix.getText()) ) 
> {
> Argument arg = new Argument(propName.toString(),
> p.getProperty(propName), "=") ;
> ---------------------------------------------------------
> 
> I can now enter "java" in the Config element's JTextField and then use
> ${java.vendor},  ${java.classpath}, etc., directly in my tests. Very
> nice! 

You could also have used ${__P(java.vendor)} and used the existing property function.
Not quite as neat, but the __P() function also supports defaults.

> 
> However, my code can only read System properties and properties
> specified on the command line with the '-D' param. If I run JMeter with
> the '-n <propfile>' param, my code can't access the properties specified
> in '<propfile>' - maybe because they are "JMeter properties". How can my
> code access "JMeter properties"? 

See above. Or use :
JMeterUtils.getPropDefault(propertyName, propertyDefault);

However, there is no need to write any code.

${__P(property.name)} should work in any test element.

> 
> Once that is sorted out, I'll post the patch to Jmeter-dev if that's all
> right. 
> 

Better to post patches as attachments to a Bugzilla report.

S.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to