You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by pm...@apache.org on 2014/02/09 12:26:51 UTC
svn commit: r1566275 - in /jmeter/trunk:
src/core/org/apache/jmeter/engine/util/ValueReplacer.java xdocs/changes.xml
Author: pmouawad
Date: Sun Feb 9 11:26:51 2014
New Revision: 1566275
URL: http://svn.apache.org/r1566275
Log:
Bug 55998 - HTTP recording – Replacing port value by user defined variable does not work
Bugzilla Id: 55998
Modified:
jmeter/trunk/src/core/org/apache/jmeter/engine/util/ValueReplacer.java
jmeter/trunk/xdocs/changes.xml
Modified: jmeter/trunk/src/core/org/apache/jmeter/engine/util/ValueReplacer.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/engine/util/ValueReplacer.java?rev=1566275&r1=1566274&r2=1566275&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/engine/util/ValueReplacer.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/engine/util/ValueReplacer.java Sun Feb 9 11:26:51 2014
@@ -29,6 +29,7 @@ import org.apache.jmeter.testelement.Tes
import org.apache.jmeter.testelement.TestPlan;
import org.apache.jmeter.testelement.property.JMeterProperty;
import org.apache.jmeter.testelement.property.MultiProperty;
+import org.apache.jmeter.testelement.property.NumberProperty;
import org.apache.jmeter.testelement.property.PropertyIterator;
import org.apache.jmeter.testelement.property.StringProperty;
import org.apache.jorphan.logging.LoggingManager;
@@ -59,6 +60,13 @@ public class ValueReplacer {
this.variables = variables;
}
+ /**
+ * Replaces TestElement StringProperties containing functions with their Function properties equivalent, example:
+ * ${__time()}_${__threadNum()}_${__machineName()} will become a FunctionProperty of
+ * a CompoundVariable containing 3 functions
+ * @param el
+ * @throws InvalidVariableException
+ */
public void replaceValues(TestElement el) throws InvalidVariableException {
Collection<JMeterProperty> newProps = replaceValues(el.propertyIterator(), new ReplaceStringWithFunctions(masterFunction,
variables));
@@ -72,18 +80,34 @@ public class ValueReplacer {
}
}
+ /**
+ * Transforms strings into variable references
+ * @param el
+ * @throws InvalidVariableException
+ */
public void reverseReplace(TestElement el) throws InvalidVariableException {
Collection<JMeterProperty> newProps = replaceValues(el.propertyIterator(), new ReplaceFunctionsWithStrings(masterFunction,
variables));
setProperties(el, newProps);
}
+ /**
+ * Transforms strings into variable references using regexp matching if regexMatch is true
+ * @param el
+ * @param regexMatch
+ * @throws InvalidVariableException
+ */
public void reverseReplace(TestElement el, boolean regexMatch) throws InvalidVariableException {
Collection<JMeterProperty> newProps = replaceValues(el.propertyIterator(), new ReplaceFunctionsWithStrings(masterFunction,
variables, regexMatch));
setProperties(el, newProps);
}
+ /**
+ * Replaces ${key} by value extracted from variables if any
+ * @param el
+ * @throws InvalidVariableException
+ */
public void undoReverseReplace(TestElement el) throws InvalidVariableException {
Collection<JMeterProperty> newProps = replaceValues(el.propertyIterator(), new UndoVariableReplacement(masterFunction,
variables));
@@ -104,6 +128,15 @@ public class ValueReplacer {
variables.putAll(vars);
}
+ /**
+ * Replaces a StringProperty containing functions with their Function properties equivalent, example:
+ * ${__time()}_${__threadNum()}_${__machineName()} will become a FunctionProperty of
+ * a CompoundVariable containing 3 functions
+ * @param iter {@link PropertyIterator}
+ * @param transform {@link ValueTransformer}
+ * @return Collection<JMeterProperty>
+ * @throws InvalidVariableException
+ */
private Collection<JMeterProperty> replaceValues(PropertyIterator iter, ValueTransformer transform) throws InvalidVariableException {
List<JMeterProperty> props = new LinkedList<JMeterProperty>();
while (iter.hasNext()) {
@@ -120,6 +153,11 @@ public class ValueReplacer {
log.debug("Replacement result: " + val);
}
}
+ } else if (val instanceof NumberProperty) {
+ val = transform.transformValue(val);
+ if (log.isDebugEnabled()) {
+ log.debug("Replacement result: " + val);
+ }
} else if (val instanceof MultiProperty) {
MultiProperty multiVal = (MultiProperty) val;
Collection<JMeterProperty> newValues = replaceValues(multiVal.iterator(), transform);
Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1566275&r1=1566274&r2=1566275&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Sun Feb 9 11:26:51 2014
@@ -122,6 +122,7 @@ A workaround is to use a Java 7 update 4
<h3>HTTP Samplers and Test Script Recorder</h3>
<ul>
+<li><bugzilla>55998</bugzilla> - HTTP recording â Replacing port value by user defined variable does not work</li>
</ul>
<h3>Other Samplers</h3>