sebb 2005/03/16 19:03:39
Modified: src/core/org/apache/jmeter/resources Tag: rel-2_0
messages.properties
src/components/org/apache/jmeter/control/gui Tag: rel-2_0
ForeachControlPanel.java
src/components/org/apache/jmeter/control Tag: rel-2_0
ForeachController.java
xdocs/usermanual Tag: rel-2_0 component_reference.xml
Log:
ForEach controller now allows looping through all groups in all matches
Revision Changes Path
No revision
No revision
1.106.2.19 +1 -0
jakarta-jmeter/src/core/org/apache/jmeter/resources/messages.properties
Index: messages.properties
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/resources/messages.properties,v
retrieving revision 1.106.2.18
retrieving revision 1.106.2.19
diff -u -r1.106.2.18 -r1.106.2.19
--- messages.properties 13 Mar 2005 15:20:20 -0000 1.106.2.18
+++ messages.properties 17 Mar 2005 03:03:39 -0000 1.106.2.19
@@ -138,6 +138,7 @@
foreach_controller_title=ForEach Controller
foreach_input=Input variable prefix
foreach_output=Output variable name
+foreach_use_separator=Add "_" before number ?
ftp_sample_title=FTP Request Defaults
ftp_testing_title=FTP Request
fr=French
No revision
No revision
1.4.2.1 +13 -3
jakarta-jmeter/src/components/org/apache/jmeter/control/gui/ForeachControlPanel.java
Index: ForeachControlPanel.java
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src/components/org/apache/jmeter/control/gui/ForeachControlPanel.java,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -u -r1.4 -r1.4.2.1
--- ForeachControlPanel.java 5 Mar 2004 01:32:37 -0000 1.4
+++ ForeachControlPanel.java 17 Mar 2005 03:03:39 -0000 1.4.2.1
@@ -19,6 +19,8 @@
package org.apache.jmeter.control.gui;
import java.awt.BorderLayout;
+
+import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
@@ -53,7 +55,9 @@
*/
private JTextField returnVal;
-
+ // Should we add the "_" separator?
+ private JCheckBox useSeparator;
+
/**
* Boolean indicating whether or not this component should display its
* name. If true, this is a standalone component. If false, this
component
@@ -103,6 +107,7 @@
super.configure(element);
inputVal.setText(((ForeachController) element).getInputValString());
returnVal.setText(((ForeachController)
element).getReturnValString());
+ useSeparator.setSelected(((ForeachController)
element).getUseSeparator());
}
/* Implements JMeterGUIComponent.createTestElement() */
@@ -135,6 +140,7 @@
{
((ForeachController) lc).setReturnVal("");
}
+ ((ForeachController)
lc).setUseSeparator(useSeparator.isSelected());
}
}
@@ -207,8 +213,12 @@
returnValSubPanel.add(returnValLabel, BorderLayout.WEST);
returnValSubPanel.add(returnVal, BorderLayout.CENTER);
+ // Checkbox
+ useSeparator = new
JCheckBox(JMeterUtils.getResString("foreach_use_separator"),true);
+
loopPanel.add(inputValSubPanel);
loopPanel.add(returnValSubPanel);
+ loopPanel.add(useSeparator);
return loopPanel;
}
No revision
No revision
1.3.2.3 +36 -7
jakarta-jmeter/src/components/org/apache/jmeter/control/ForeachController.java
Index: ForeachController.java
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src/components/org/apache/jmeter/control/ForeachController.java,v
retrieving revision 1.3.2.2
retrieving revision 1.3.2.3
diff -u -r1.3.2.2 -r1.3.2.3
--- ForeachController.java 13 Oct 2004 00:32:22 -0000 1.3.2.2
+++ ForeachController.java 17 Mar 2005 03:03:39 -0000 1.3.2.3
@@ -22,6 +22,7 @@
import org.apache.jmeter.samplers.Sampler;
import org.apache.jmeter.threads.JMeterContext;
+import org.apache.jmeter.testelement.property.BooleanProperty;
import org.apache.jmeter.testelement.property.StringProperty;
import org.apache.jorphan.logging.LoggingManager;
import org.apache.log.Logger;
@@ -38,8 +39,11 @@
private final static String INPUTVAL = "ForeachController.inputVal";
private final static String RETURNVAL ="ForeachController.returnVal";
+ private final static String USE_SEPARATOR
="ForeachController.useSeparator";
private int loopCount = 0;
+ private static final String DEFAULT_SEPARATOR = "_";
+
public ForeachController()
{
}
@@ -55,6 +59,11 @@
setProperty(new StringProperty(INPUTVAL, inputValue));
}
+ private String getInputVal()
+ {
+ getProperty(INPUTVAL).recoverRunningVersion(null);
+ return getInputValString();
+ }
public String getInputValString()
{
return getPropertyAsString(INPUTVAL);
@@ -65,22 +74,42 @@
setProperty(new StringProperty(RETURNVAL, inputValue));
}
+ private String getReturnVal()
+ {
+ getProperty(RETURNVAL).recoverRunningVersion(null);
+ return getReturnValString();
+ }
public String getReturnValString()
{
return getPropertyAsString(RETURNVAL);
}
+ private String getSeparator()
+ {
+ return getUseSeparator() ? DEFAULT_SEPARATOR : "";
+ }
+
+ public void setUseSeparator(boolean b)
+ {
+ setProperty(new BooleanProperty(USE_SEPARATOR, b));
+ }
+
+ public boolean getUseSeparator()
+ {
+ return getPropertyAsBoolean(USE_SEPARATOR,true);
+ }
+
/* (non-Javadoc)
* @see org.apache.jmeter.control.Controller#isDone()
*/
public boolean isDone()
{
JMeterContext context = getThreadContext();
- String inputVariable=getInputValString()+"_"+(loopCount+1);
+ String inputVariable=getInputVal()+getSeparator()+(loopCount+1);
if (context.getVariables().get(inputVariable) != null)
{
- context.getVariables().put(getReturnValString(),
context.getVariables().get(inputVariable));
- log.debug("ForEach resultstring
isDone="+context.getVariables().get(getReturnValString()));
+ context.getVariables().put(getReturnVal(),
context.getVariables().get(inputVariable));
+ log.debug("ForEach resultstring
isDone="+context.getVariables().get(getReturnVal()));
return false;
}
return super.isDone();
@@ -89,7 +118,7 @@
private boolean endOfArguments()
{
JMeterContext context = getThreadContext();
- String inputVariable=getInputValString()+"_"+(loopCount+1);
+ String inputVariable=getInputVal()+getSeparator()+(loopCount+1);
if (context.getVariables().get(inputVariable) != null)
{
log.debug("ForEach resultstring eofArgs= false");
@@ -118,7 +147,7 @@
*/
private boolean emptyList() {
JMeterContext context = getThreadContext();
- String inputVariable=getInputValString()+"_1";
+ String inputVariable=getInputVal()+getSeparator()+"1";
if (context.getVariables().get(inputVariable) != null)
{
return false;
No revision
No revision
1.87.2.28 +8 -3 jakarta-jmeter/xdocs/usermanual/component_reference.xml
Index: component_reference.xml
===================================================================
RCS file: /home/cvs/jakarta-jmeter/xdocs/usermanual/component_reference.xml,v
retrieving revision 1.87.2.27
retrieving revision 1.87.2.28
diff -u -r1.87.2.27 -r1.87.2.28
--- component_reference.xml 14 Mar 2005 00:10:51 -0000 1.87.2.27
+++ component_reference.xml 17 Mar 2005 03:03:39 -0000 1.87.2.28
@@ -764,12 +764,16 @@
<li>inputVar_3 = peter</li>
<li>inputVar_4 = john</li>
</ul>
+ <p>Note: the "_" separator is now optional.</p>
When the return variable is given as "returnVar", the collection of samplers
and controllers under the ForEach controller will be executed 4 consecutive
times,
with the return variable having the respective above values, which can then
be used in the samplers.
</p>
<p>
It is especially suited for running with the regular expression
post-processor.
This can "create" the necessary input variables out of the result data of a
previous request.
+By omitting the "_" separator, the ForEach Controller can be used to loop
through the groups by using
+the input variable refName_g, and can also loop through all the groups in
all the matches
+by using an input variable of the form refName_${C}_g, where C is a counter
variable.
</p>
<note>The ForEach Controller does not run any samples if inputVar_1 is null.
This would be the case if the Regular Expression returned no matches.</note>
@@ -780,6 +784,7 @@
<property name="Input variable prefix" required="Yes">Prefix for the
variable names to be used as input.</property>
<property name="Output variable" required="Yes">
The name of the variable which can be used in the loop for
replacement in the samplers</property>
+ <property required="Yes" name="Use Separator">If not checked,
the "_" separator is omitted.</property>
</properties>
<example title="ForEach Example" anchor="foreach_example">
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]