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 2008/07/07 01:42:14 UTC
svn commit: r674362 [6/6] - in
/jakarta/jmeter/trunk/src/core/org/apache/jmeter: ./ config/ config/gui/
control/ control/gui/ engine/ engine/event/ engine/util/ exceptions/
Modified: jakarta/jmeter/trunk/src/core/org/apache/jmeter/engine/util/ValueReplacer.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/engine/util/ValueReplacer.java?rev=674362&r1=674361&r2=674362&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/core/org/apache/jmeter/engine/util/ValueReplacer.java (original)
+++ jakarta/jmeter/trunk/src/core/org/apache/jmeter/engine/util/ValueReplacer.java Sun Jul 6 16:42:12 2008
@@ -13,7 +13,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
*/
package org.apache.jmeter.engine.util;
@@ -41,106 +41,106 @@
* @version $Revision$ updated on $Date$
*/
public class ValueReplacer {
- private static final Logger log = LoggingManager.getLoggerForClass();
+ private static final Logger log = LoggingManager.getLoggerForClass();
- private CompoundVariable masterFunction = new CompoundVariable();
+ private CompoundVariable masterFunction = new CompoundVariable();
- private Map variables = new HashMap();
+ private Map variables = new HashMap();
- public ValueReplacer() {
- }
+ public ValueReplacer() {
+ }
- public ValueReplacer(TestPlan tp) {
- setUserDefinedVariables(tp.getUserDefinedVariables());
- }
-
- boolean containsKey(String k){
- return variables.containsKey(k);
- }
- public void setUserDefinedVariables(Map variables) {
- this.variables = variables;
- }
-
- public void replaceValues(TestElement el) throws InvalidVariableException {
- Collection newProps = replaceValues(el.propertyIterator(), new ReplaceStringWithFunctions(masterFunction,
- variables));
- setProperties(el, newProps);
- }
-
- private void setProperties(TestElement el, Collection newProps) {
- Iterator iter = newProps.iterator();
- el.clear();
- while (iter.hasNext()) {
- el.setProperty((JMeterProperty) iter.next());
- }
- }
-
- public void reverseReplace(TestElement el) throws InvalidVariableException {
- Collection newProps = replaceValues(el.propertyIterator(), new ReplaceFunctionsWithStrings(masterFunction,
- variables));
- setProperties(el, newProps);
- }
-
- public void reverseReplace(TestElement el, boolean regexMatch) throws InvalidVariableException {
- Collection newProps = replaceValues(el.propertyIterator(), new ReplaceFunctionsWithStrings(masterFunction,
- variables, regexMatch));
- setProperties(el, newProps);
- }
-
- public void undoReverseReplace(TestElement el) throws InvalidVariableException {
- Collection newProps = replaceValues(el.propertyIterator(), new UndoVariableReplacement(masterFunction,
- variables));
- setProperties(el, newProps);
- }
-
- public void addVariable(String name, String value) {
- variables.put(name, value);
- }
-
- /**
- * Add all the given variables to this replacer's variables map.
- *
- * @param vars
- * A map of variable name-value pairs (String-to-String).
- */
- public void addVariables(Map vars) {
- variables.putAll(vars);
- }
-
- private Collection replaceValues(PropertyIterator iter, ValueTransformer transform) throws InvalidVariableException {
- List props = new LinkedList();
- while (iter.hasNext()) {
- JMeterProperty val = iter.next();
- if (log.isDebugEnabled()) {
- log.debug("About to replace in property of type: " + val.getClass() + ": " + val);
- }
- if (val instanceof StringProperty) {
- // Must not convert TestElement.gui_class etc
- if (!val.getName().equals(TestElement.GUI_CLASS) &&
+ public ValueReplacer(TestPlan tp) {
+ setUserDefinedVariables(tp.getUserDefinedVariables());
+ }
+
+ boolean containsKey(String k){
+ return variables.containsKey(k);
+ }
+ public void setUserDefinedVariables(Map variables) {
+ this.variables = variables;
+ }
+
+ public void replaceValues(TestElement el) throws InvalidVariableException {
+ Collection newProps = replaceValues(el.propertyIterator(), new ReplaceStringWithFunctions(masterFunction,
+ variables));
+ setProperties(el, newProps);
+ }
+
+ private void setProperties(TestElement el, Collection newProps) {
+ Iterator iter = newProps.iterator();
+ el.clear();
+ while (iter.hasNext()) {
+ el.setProperty((JMeterProperty) iter.next());
+ }
+ }
+
+ public void reverseReplace(TestElement el) throws InvalidVariableException {
+ Collection newProps = replaceValues(el.propertyIterator(), new ReplaceFunctionsWithStrings(masterFunction,
+ variables));
+ setProperties(el, newProps);
+ }
+
+ public void reverseReplace(TestElement el, boolean regexMatch) throws InvalidVariableException {
+ Collection newProps = replaceValues(el.propertyIterator(), new ReplaceFunctionsWithStrings(masterFunction,
+ variables, regexMatch));
+ setProperties(el, newProps);
+ }
+
+ public void undoReverseReplace(TestElement el) throws InvalidVariableException {
+ Collection newProps = replaceValues(el.propertyIterator(), new UndoVariableReplacement(masterFunction,
+ variables));
+ setProperties(el, newProps);
+ }
+
+ public void addVariable(String name, String value) {
+ variables.put(name, value);
+ }
+
+ /**
+ * Add all the given variables to this replacer's variables map.
+ *
+ * @param vars
+ * A map of variable name-value pairs (String-to-String).
+ */
+ public void addVariables(Map vars) {
+ variables.putAll(vars);
+ }
+
+ private Collection replaceValues(PropertyIterator iter, ValueTransformer transform) throws InvalidVariableException {
+ List props = new LinkedList();
+ while (iter.hasNext()) {
+ JMeterProperty val = iter.next();
+ if (log.isDebugEnabled()) {
+ log.debug("About to replace in property of type: " + val.getClass() + ": " + val);
+ }
+ if (val instanceof StringProperty) {
+ // Must not convert TestElement.gui_class etc
+ if (!val.getName().equals(TestElement.GUI_CLASS) &&
!val.getName().equals(TestElement.TEST_CLASS)) {
- val = transform.transformValue(val);
- if (log.isDebugEnabled()) {
- log.debug("Replacement result: " + val);
- }
- }
- } else if (val instanceof MultiProperty) {
- MultiProperty multiVal = (MultiProperty) val;
- Collection newValues = replaceValues(multiVal.iterator(), transform);
- multiVal.clear();
- Iterator propIter = newValues.iterator();
- while (propIter.hasNext()) {
- multiVal.addProperty((JMeterProperty) propIter.next());
- }
- if (log.isDebugEnabled()) {
- log.debug("Replacement result: " + multiVal);
- }
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Won't replace " + val);
- }
- }
- props.add(val);
- }
- return props;
- }
+ val = transform.transformValue(val);
+ if (log.isDebugEnabled()) {
+ log.debug("Replacement result: " + val);
+ }
+ }
+ } else if (val instanceof MultiProperty) {
+ MultiProperty multiVal = (MultiProperty) val;
+ Collection newValues = replaceValues(multiVal.iterator(), transform);
+ multiVal.clear();
+ Iterator propIter = newValues.iterator();
+ while (propIter.hasNext()) {
+ multiVal.addProperty((JMeterProperty) propIter.next());
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("Replacement result: " + multiVal);
+ }
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug("Won't replace " + val);
+ }
+ }
+ props.add(val);
+ }
+ return props;
+ }
}
Modified: jakarta/jmeter/trunk/src/core/org/apache/jmeter/engine/util/ValueTransformer.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/engine/util/ValueTransformer.java?rev=674362&r1=674361&r2=674362&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/core/org/apache/jmeter/engine/util/ValueTransformer.java (original)
+++ jakarta/jmeter/trunk/src/core/org/apache/jmeter/engine/util/ValueTransformer.java Sun Jul 6 16:42:12 2008
@@ -13,7 +13,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
*/
/*
@@ -27,27 +27,27 @@
import org.apache.jmeter.testelement.property.JMeterProperty;
interface ValueTransformer {
- /**
- * Transform the given property and return the new version.
- *
- * @param property
- * @return the transformed property
- */
- public JMeterProperty transformValue(JMeterProperty property) throws InvalidVariableException;
-
- /**
- * Set the master function for the value transformer. This handles
- * converting strings to functions.
- *
- * @param masterFunction
- */
- public void setMasterFunction(CompoundVariable masterFunction);
-
- /**
- * Set the variable names and values used to reverse replace functions with
- * strings, and undo functions to raw values.
- *
- * @param vars
- */
- public void setVariables(Map vars);
+ /**
+ * Transform the given property and return the new version.
+ *
+ * @param property
+ * @return the transformed property
+ */
+ public JMeterProperty transformValue(JMeterProperty property) throws InvalidVariableException;
+
+ /**
+ * Set the master function for the value transformer. This handles
+ * converting strings to functions.
+ *
+ * @param masterFunction
+ */
+ public void setMasterFunction(CompoundVariable masterFunction);
+
+ /**
+ * Set the variable names and values used to reverse replace functions with
+ * strings, and undo functions to raw values.
+ *
+ * @param vars
+ */
+ public void setVariables(Map vars);
}
Modified: jakarta/jmeter/trunk/src/core/org/apache/jmeter/exceptions/IllegalUserActionException.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/exceptions/IllegalUserActionException.java?rev=674362&r1=674361&r2=674362&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/core/org/apache/jmeter/exceptions/IllegalUserActionException.java (original)
+++ jakarta/jmeter/trunk/src/core/org/apache/jmeter/exceptions/IllegalUserActionException.java Sun Jul 6 16:42:12 2008
@@ -13,7 +13,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
*/
package org.apache.jmeter.exceptions;
@@ -21,14 +21,14 @@
/**
*/
public class IllegalUserActionException extends Exception {
- /**
- * @deprecated - use IllegalUserActionException(String)
- */
- public IllegalUserActionException() {
- super();
- }
+ /**
+ * @deprecated - use IllegalUserActionException(String)
+ */
+ public IllegalUserActionException() {
+ super();
+ }
- public IllegalUserActionException(String name) {
- super(name);
- }
+ public IllegalUserActionException(String name) {
+ super(name);
+ }
}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org