sebb 2004/10/05 18:58:00
Modified: src/core/org/apache/jmeter/control Tag: rel-2_0
IfController.java
Log:
Allow package access to JavaScript evaluator
Revision Changes Path
No revision
No revision
1.3.2.2 +11 -21
jakarta-jmeter/src/core/org/apache/jmeter/control/IfController.java
Index: IfController.java
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/control/IfController.java,v
retrieving revision 1.3.2.1
retrieving revision 1.3.2.2
diff -u -r1.3.2.1 -r1.3.2.2
--- IfController.java 5 Oct 2004 20:32:24 -0000 1.3.2.1
+++ IfController.java 6 Oct 2004 01:58:00 -0000 1.3.2.2
@@ -89,14 +89,10 @@
/**
* evaluate the condition clause
- * Throw Exception If bad condition -
+ * log error if bad condition
*/
- private boolean evaluateCondition() throws Exception {
-
- // condition string is going to be of the form : ${counter}<10
- // the following replaces the ${xxx} with actual valuess
-
- logger.debug(" getCondition() : [" + getCondition() + "]");
+ static boolean evaluateCondition(String cond) {
+ logger.debug(" getCondition() : [" + cond + "]");
String resultStr = "";
boolean result = false;
@@ -106,7 +102,7 @@
try {
Scriptable scope = cx.initStandardObjects(null);
Object cxResultObject =
- cx.evaluateString(scope, getCondition()
+ cx.evaluateString(scope, cond
/*** conditionString ***/
, "<cmd>", 1, null);
resultStr = Context.toString(cxResultObject);
@@ -116,16 +112,17 @@
} else if (resultStr.equals("true")) {
result = true;
} else {
- throw new Exception(" BAD CONDITION ::
" + getCondition());
+ throw new Exception(" BAD CONDITION ::
" + cond);
}
logger.debug(
" >> evaluate Condition - [ "
- + getCondition()
+ + cond
+ "] results is ["
+ result
+ "]");
-
+ } catch (Exception e) {
+ logger.error(e.getMessage(),e);
} finally {
Context.exit();
}
@@ -164,14 +161,7 @@
*/
public Sampler next()
{
- boolean result = false;
- try {
- result = evaluateCondition();
- }
- catch (Exception e)
- {
- logger.error(e.getMessage(),e);
- }
+ boolean result = evaluateCondition(getCondition());
if (result)
return super.next();
else try
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]