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 se...@apache.org on 2005/10/17 19:31:22 UTC

svn commit: r325939 - in /jakarta/jmeter/branches/rel-2-1: src/core/org/apache/jmeter/resources/messages.properties src/functions/org/apache/jmeter/functions/SetProperty.java xdocs/usermanual/functions.xml

Author: sebb
Date: Mon Oct 17 10:31:05 2005
New Revision: 325939

URL: http://svn.apache.org/viewcvs?rev=325939&view=rev
Log:
Bug 37117 - setProperty() function should return ""; added optional return of original setting

Modified:
    jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/resources/messages.properties
    jakarta/jmeter/branches/rel-2-1/src/functions/org/apache/jmeter/functions/SetProperty.java
    jakarta/jmeter/branches/rel-2-1/xdocs/usermanual/functions.xml

Modified: jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/resources/messages.properties
URL: http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/resources/messages.properties?rev=325939&r1=325938&r2=325939&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/resources/messages.properties (original)
+++ jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/resources/messages.properties Mon Oct 17 10:31:05 2005
@@ -469,6 +469,7 @@
 property_editor.value_is_invalid_title=Invalid input
 property_name_param=Name of property
 property_value_param=Value of property
+property_returnvalue_param=Return Original Value of property (default false) ?
 property_tool_tip={0}\: {1}
 property_undefined=Undefined
 protocol=Protocol\:

Modified: jakarta/jmeter/branches/rel-2-1/src/functions/org/apache/jmeter/functions/SetProperty.java
URL: http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/src/functions/org/apache/jmeter/functions/SetProperty.java?rev=325939&r1=325938&r2=325939&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/src/functions/org/apache/jmeter/functions/SetProperty.java (original)
+++ jakarta/jmeter/branches/rel-2-1/src/functions/org/apache/jmeter/functions/SetProperty.java Mon Oct 17 10:31:05 2005
@@ -51,10 +51,11 @@
 	// Number of parameters expected - used to reject invalid calls
 	private static final int MIN_PARAMETER_COUNT = 2;
 
-	private static final int MAX_PARAMETER_COUNT = 2;
+	private static final int MAX_PARAMETER_COUNT = 3;
 	static {
 		desc.add(JMeterUtils.getResString("property_name_param"));
 		desc.add(JMeterUtils.getResString("property_value_param"));
+		desc.add(JMeterUtils.getResString("property_returnvalue_param"));
 	}
 
 	private Object[] values;
@@ -71,11 +72,18 @@
 		String propertyName = ((CompoundVariable) values[0]).execute();
 
 		String propertyValue = ((CompoundVariable) values[1]).execute();
-
-		JMeterUtils.setProperty(propertyName, propertyValue);
-
-		return propertyValue;
-
+		
+		boolean returnValue = false;// should we return original value?
+		if (values.length > 2) {
+			returnValue = ((CompoundVariable) values[2]).execute().equalsIgnoreCase("true");
+		}
+
+		if (returnValue) { // Only obtain and cast the return if needed 
+			return (String) JMeterUtils.setProperty(propertyName, propertyValue);
+		} else {
+			JMeterUtils.setProperty(propertyName, propertyValue);
+			return "";
+		}
 	}
 
 	public void setParameters(Collection parameters) throws InvalidVariableException {

Modified: jakarta/jmeter/branches/rel-2-1/xdocs/usermanual/functions.xml
URL: http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/xdocs/usermanual/functions.xml?rev=325939&r1=325938&r2=325939&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/xdocs/usermanual/functions.xml (original)
+++ jakarta/jmeter/branches/rel-2-1/xdocs/usermanual/functions.xml Mon Oct 17 10:31:05 2005
@@ -578,8 +578,9 @@
 <component index="19.5.16" name="__setProperty">
 <description>
 	<p>The setProperty function sets the value of a JMeter property. 
-		The return value from the function is the empty string,
+		The default return value from the function is the empty string,
 		so the function call can be used anywhere functions are valid.</p>
+        <p>The original value can be returned by setting the optional 3rd parameter to "true".</p>
 	<p>Properties are global to JMeter,
 		so can be used to communicate between threads and thread groups</p>
 	</description>
@@ -587,6 +588,7 @@
 <properties>
         <property name="Property Name" required="Yes">The property name to be set.</property>
         <property name="Property Value" required="Yes">The value for the property.</property>
+        <property name="Property Value" required="No">Should the original value be returned?</property>
 </properties>
 </component>
 



---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org