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 2017/10/27 09:50:07 UTC
svn commit: r1813495 - in /jmeter/trunk:
src/core/org/apache/jmeter/control/gui/
src/core/org/apache/jmeter/resources/ xdocs/ xdocs/images/screenshots/
xdocs/usermanual/
Author: pmouawad
Date: Fri Oct 27 09:50:06 2017
New Revision: 1813495
URL: http://svn.apache.org/viewvc?rev=1813495&view=rev
Log:
Bug 61675 - If Controller : Use expression by default and add a warning when the other mode is used
Bugzilla Id: 61675
Added:
jmeter/trunk/xdocs/images/screenshots/if_controller_expression.png (with props)
jmeter/trunk/xdocs/images/screenshots/if_controller_javascript.png (with props)
jmeter/trunk/xdocs/images/screenshots/if_controller_variable.png (with props)
Removed:
jmeter/trunk/xdocs/images/screenshots/ifcontroller.png
Modified:
jmeter/trunk/src/core/org/apache/jmeter/control/gui/IfControllerPanel.java
jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties
jmeter/trunk/xdocs/changes.xml
jmeter/trunk/xdocs/usermanual/component_reference.xml
Modified: jmeter/trunk/src/core/org/apache/jmeter/control/gui/IfControllerPanel.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/control/gui/IfControllerPanel.java?rev=1813495&r1=1813494&r2=1813495&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/control/gui/IfControllerPanel.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/control/gui/IfControllerPanel.java Fri Oct 27 09:50:06 2017
@@ -19,11 +19,16 @@
package org.apache.jmeter.control.gui;
import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Font;
-import javax.swing.Box;
+import javax.swing.ImageIcon;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
+import javax.swing.SwingConstants;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
import org.apache.jmeter.control.IfController;
import org.apache.jmeter.gui.util.JSyntaxTextArea;
@@ -38,11 +43,17 @@ import org.apache.jmeter.util.JMeterUtil
*
*/
-public class IfControllerPanel extends AbstractControllerGui {
+public class IfControllerPanel extends AbstractControllerGui implements ChangeListener {
private static final long serialVersionUID = 240L;
/**
+ * Used to warn about performance penalty
+ */
+ private JLabel warningLabel;
+
+ private JLabel conditionLabel;
+ /**
* A field allowing the user to specify the number of times the controller
* should loop.
*/
@@ -132,6 +143,7 @@ public class IfControllerPanel extends A
@Override
public void clearGui() {
super.clearGui();
+ useExpression.setSelected(true);
theCondition.setText(""); // $NON-NLS-1$
evaluateAll.setSelected(false);
}
@@ -171,22 +183,27 @@ public class IfControllerPanel extends A
JPanel conditionPanel = new JPanel(new BorderLayout(5, 0));
// Condition LABEL
- JLabel conditionLabel = new JLabel(JMeterUtils.getResString("if_controller_label")); // $NON-NLS-1$
+ conditionLabel = new JLabel(JMeterUtils.getResString("if_controller_label")); // $NON-NLS-1$
conditionPanel.add(conditionLabel, BorderLayout.WEST);
+ ImageIcon image = JMeterUtils.getImage("warning.png");
+ warningLabel = new JLabel(JMeterUtils.getResString("if_controller_warning"), image, SwingConstants.CENTER); // $NON-NLS-1$
+ warningLabel.setForeground(Color.RED);
+ Font font = warningLabel.getFont();
+ warningLabel.setFont(new Font(font.getFontName(), Font.BOLD, (int)(font.getSize()*1.1)));
// Condition
theCondition = JSyntaxTextArea.getInstance(5, 50); // $NON-NLS-1$
- theCondition.setToolTipText(JMeterUtils.getResString("if_controller_performance")); // $NON-NLS-1$
conditionLabel.setLabelFor(theCondition);
conditionPanel.add(JTextScrollPane.getInstance(theCondition), BorderLayout.CENTER);
- conditionPanel.add(Box.createHorizontalGlue(), BorderLayout.NORTH);
+ conditionPanel.add(warningLabel, BorderLayout.NORTH);
+
JPanel optionPanel = new JPanel();
// Use expression instead of Javascript
useExpression = new JCheckBox(JMeterUtils.getResString("if_controller_expression")); // $NON-NLS-1$
- useExpression.setToolTipText(JMeterUtils.getResString("if_controller_performance")); // $NON-NLS-1$
+ useExpression.addChangeListener(this);
optionPanel.add(useExpression);
// Evaluate All checkbox
@@ -196,4 +213,17 @@ public class IfControllerPanel extends A
conditionPanel.add(optionPanel,BorderLayout.SOUTH);
return conditionPanel;
}
+
+ @Override
+ public void stateChanged(ChangeEvent e) {
+ if(e.getSource() == useExpression) {
+ if(useExpression.isSelected()) {
+ warningLabel.setForeground(Color.BLACK);
+ conditionLabel.setText(JMeterUtils.getResString("if_controller_expression_label"));
+ } else {
+ warningLabel.setForeground(Color.RED);
+ conditionLabel.setText(JMeterUtils.getResString("if_controller_label"));
+ }
+ }
+ }
}
Modified: jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties?rev=1813495&r1=1813494&r2=1813495&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties Fri Oct 27 09:50:06 2017
@@ -435,9 +435,10 @@ id_prefix=ID Prefix
id_suffix=ID Suffix
if_controller_evaluate_all=Evaluate for all children?
if_controller_expression=Interpret Condition as Variable Expression?
-if_controller_label=Condition (default Javascript)
-if_controller_performance=<html>TIP 1\: For performance it is advised to use JMeter functions\: <ul><li>__jexl3</li><li>or __groovy</li></ul> for example\:<br/><b>${__jexl3("${VAR}" == "23")}</b><br/> and check "Interpret Condition as Variable Expression".<br/>TIP 2\: To test success of last Sampler you can use <b>${JMeterThread.last_sample_ok}</b></html>
+if_controller_expression_label=Expression (must evaluate to true or false)
+if_controller_label=Condition (evaluated with javascript)
if_controller_title=If Controller
+if_controller_warning=<html>For performance it is advised to check "Interpret Condition as Variable Expression"<br> and use __jexl3 or __groovy evaluating to true or false or a variable that contains true or false.<br> ${JMeterThread.last_sample_ok} can be used to test if last sampler was successful<br></html>
ignore_subcontrollers=Ignore sub-controller blocks
include_controller=Include Controller
include_equals=Include Equals?
Modified: jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties?rev=1813495&r1=1813494&r2=1813495&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties Fri Oct 27 09:50:06 2017
@@ -430,9 +430,10 @@ id_prefix=Pr\u00E9fixe d'ID
id_suffix=Suffixe d'ID
if_controller_evaluate_all=Evaluer pour tous les fils ?
if_controller_expression=Interpr\u00E9ter la condition comme une expression
-if_controller_label=Condition (d\u00E9faut Javascript) \:
-if_controller_performance=<html>Astuce 1 \: Pour la performance, il est conseill\u00E9 d''utiliser les fonctions JMeter\: <ul><li> __ jexl3</li><li>ou __groovy</li></ul> par exemple\: <br/><b> $ {__ jexl3("${VAR}" == "23")}</b><br/>et cocher la case "Interpr\u00E9ter la condition en tant qu'expression variable". <br/>Astuce 2 \: Pour tester le succ\u00E8s du dernier Sampler, vous pouvez utiliser <b> $ { JMeterThread.last_sample_ok} </b></html>
+if_controller_expression_label=Expression (doit contenir true ou false)
+if_controller_label=Condition (\u00E9valu\u00E9 en Javascript) \:
if_controller_title=Contr\u00F4leur Si (If)
+if_controller_warning=<html>Pour les performances il est conseill\u00E9 de cocher "Interpr\u00E9ter la condition comme une expression"<br> et d'' utiliser __jexl3 ou __groovy ou une variable contenant true ou false.<br> ${JMeterThread.last_sample_ok} peut ĂȘtre utilis\u00E9 pour tester si le dernier sampler a r\u00E9ussi<br></html>
ignore_subcontrollers=Ignorer les sous-blocs de contr\u00F4leurs
include_controller=Contr\u00F4leur Inclusion
include_equals=Inclure \u00E9gal ?
Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1813495&r1=1813494&r2=1813495&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
+++ jmeter/trunk/xdocs/changes.xml [utf-8] Fri Oct 27 09:50:06 2017
@@ -97,6 +97,7 @@ Summary
<h3>Controllers</h3>
<ul>
+ <li><bug>61675</bug>If Controller : Use expression by default and add a warning when the other mode is used. Contributed by Ubik Load Pack (support at ubikloadpack.com)</li>
</ul>
<h3>Listeners</h3>
Added: jmeter/trunk/xdocs/images/screenshots/if_controller_expression.png
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/images/screenshots/if_controller_expression.png?rev=1813495&view=auto
==============================================================================
Binary file - no diff available.
Propchange: jmeter/trunk/xdocs/images/screenshots/if_controller_expression.png
------------------------------------------------------------------------------
svn:mime-type = image/png
Added: jmeter/trunk/xdocs/images/screenshots/if_controller_javascript.png
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/images/screenshots/if_controller_javascript.png?rev=1813495&view=auto
==============================================================================
Binary file - no diff available.
Propchange: jmeter/trunk/xdocs/images/screenshots/if_controller_javascript.png
------------------------------------------------------------------------------
svn:mime-type = image/png
Added: jmeter/trunk/xdocs/images/screenshots/if_controller_variable.png
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/images/screenshots/if_controller_variable.png?rev=1813495&view=auto
==============================================================================
Binary file - no diff available.
Propchange: jmeter/trunk/xdocs/images/screenshots/if_controller_variable.png
------------------------------------------------------------------------------
svn:mime-type = image/png
Modified: jmeter/trunk/xdocs/usermanual/component_reference.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/component_reference.xml?rev=1813495&r1=1813494&r2=1813495&view=diff
==============================================================================
--- jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
+++ jmeter/trunk/xdocs/usermanual/component_reference.xml Fri Oct 27 09:50:06 2017
@@ -2236,28 +2236,33 @@ Please refer to the <complink name="Cons
</properties>
</component>
-<component name="If Controller" index="§-num;.2.9" width="497" height="131" screenshot="ifcontroller.png">
+<component name="If Controller" index="§-num;.2.9" width="814" height="262" screenshot="if_controller_expression.png">
<description>
<p>The If Controller allows the user to control whether the test elements below it (its children) are run or not.</p>
<p>
By default, the condition is evaluated only once on initial entry, but you have the option to have it evaluated for every runnable element contained in the controller.
</p>
<p>
- The script can be processed as a variable expression, rather than requiring JavaScript.
- It was always possible to use functions and variables in the JavaScript condition, so long as they evaluated to "<code>true</code>" or "<code>false</code>";
- now this can be done without the overhead of using JavaScript as well. For example, previously one could use the condition:
+ If Controller will internally use javascript to evaluate the condition but this can have a performance penalty.
+ <figure width="819" height="265" image="if_controller_javascript.png">If Controller using javascript</figure>
+ A better option (default one) is to check <code>Interpret Condition as Variable Expression?</code>, then in the condition field you have 2 options:
+ <ul>
+ <li>Option 1 : Use a variable that contains <code>true</code> or <code>false</code>
+ <note>If you want to test if last sample was successful, you can use <code>${JMeterThread.last_sample_ok}</code>
+ <figure width="815" height="260" image="if_controller_variable.png">If Controller using Variable</figure>
+ </note>
+ </li>
+ <li>Option 2 : Use a function (<code>${__jexl3()}</code> is advised) to evaluate an expression that must return <code>true</code> or <code>false</code>
+ <figure width="815" height="260" image="if_controller_expression.png">If Controller using expression</figure>
+ </li>
+ </ul>
+
+ For example, previously one could use the condition:
<code>${__jexl3(${VAR} == 23)}</code> and this would be evaluated as <code>true</code>/<code>false</code>, the result would then be passed to JavaScript
which would then return <code>true</code>/<code>false</code>. If the Variable Expression option is selected, then the expression is evaluated
and compared with "<code>true</code>", without needing to use JavaScript.
- Also, variable expressions can return any value, whereas the
- JavaScript condition must return "<code>true</code>"/"<code>false</code>" or an error is logged.
</p>
<note>
- No variables are made available to the script when the condition is interpreted as JavaScript.
- If you need access to such variables, then select "<code>Interpret Condition as Variable Expression?</code>" and use
- a <code><funclink name="__jexl3"/></code>, <code><funclink name="__groovy"/></code> or <code><funclink name="__javaScript()"/></code> (discouraged for performance) function call. You can then use the objects "<code>vars</code>", "<code>log</code>", "<code>ctx</code>" etc. in the script.
- </note>
- <note>
To test if a variable is undefined (or null) do the following, suppose var is named <code>myVar</code>, expression will be:
<source>"${myVar}" == "\${myVar}"</source>
Or use: