jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1427477 - in /jmeter/trunk: src/core/org/apache/jmeter/resources/ src/protocol/http/org/apache/jmeter/protocol/http/modifier/ src/protocol/http/org/apache/jmeter/protocol/http/modifier/gui/ xdocs/ xdocs/demos/ xdocs/images/screenshots/ xdo...
Date Tue, 01 Jan 2013 17:18:46 GMT
Author: pmouawad
Date: Tue Jan  1 17:18:46 2013
New Revision: 1427477

URL: http://svn.apache.org/viewvc?rev=1427477&view=rev
Log:
Bug 45772 - RgEx User Parameters Post Processor 
Bugzilla Id: 45772

Added:
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/modifier/RegExUserParameters.java
  (with props)
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/modifier/gui/RegExUserParametersGui.java
  (with props)
    jmeter/trunk/xdocs/demos/RegEx-User-Parameters.jmx
    jmeter/trunk/xdocs/images/screenshots/regex_user_params.png   (with props)
Modified:
    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/resources/messages.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties?rev=1427477&r1=1427476&r2=1427477&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties Tue Jan  1 17:18:46
2013
@@ -370,7 +370,7 @@ help_node=What's this node?
 html_assertion_file=Write JTidy report to file
 html_assertion_label=HTML Assertion
 html_assertion_title=HTML Assertion
-html_extractor_type=CSS/JQuery extractor Implementation
+html_extractor_type=CSS/JQuery Extractor Implementation
 html_extractor_title=CSS/JQuery Extractor
 html_parameter_mask=HTML Parameter Mask
 http_implementation=Implementation:
@@ -733,6 +733,10 @@ record_controller_title=Recording Contro
 ref_name_field=Reference Name\:
 regex_extractor_title=Regular Expression Extractor
 regex_field=Regular Expression\:
+regex_params_names_field=Parameter names regexp group number
+regex_params_values_field=Parameter values regex group number
+regex_params_ref_name_field=Regular Expression Reference Name
+regex_params_title=RegEx User Parameters
 regex_source=Response Field to check
 regex_src_body=Body
 regex_src_body_as_document=Body as a Document

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=1427477&r1=1427476&r2=1427477&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 Tue Jan  1 17:18:46
2013
@@ -727,6 +727,10 @@ record_controller_title=Contr\u00F4leur 
 ref_name_field=Nom de r\u00E9f\u00E9rence \:
 regex_extractor_title=Extracteur Expression r\u00E9guli\u00E8re
 regex_field=Expression r\u00E9guli\u00E8re \:
+regex_params_names_field=Num\u221a\u00a9ro du groupe de la Regex pour les noms des param\u221a\u00aetres
+regex_params_values_field=Num\u221a\u00a9ro du groupe de la Regex pour les valeurs des param\u221a\u00aetres
+regex_params_ref_name_field=Nom de la r\u221a\u00a9f\u221a\u00a9rence de la Regex
+regex_params_title=Param\u221a\u00aetres utilisateurs bas\u221a\u00a9s sur RegEx
 regex_source=Port\u00E9e
 regex_src_body=Corps
 regex_src_body_as_document=Corps en tant que Document

Added: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/modifier/RegExUserParameters.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/modifier/RegExUserParameters.java?rev=1427477&view=auto
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/modifier/RegExUserParameters.java
(added)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/modifier/RegExUserParameters.java
Tue Jan  1 17:18:46 2013
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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.protocol.http.modifier;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.jmeter.config.Argument;
+import org.apache.jmeter.processor.PreProcessor;
+import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
+import org.apache.jmeter.samplers.Sampler;
+import org.apache.jmeter.testelement.AbstractTestElement;
+import org.apache.jmeter.testelement.property.PropertyIterator;
+import org.apache.jmeter.threads.JMeterVariables;
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.log.Logger;
+
+/**
+ * This component allows you to specify reference name of a regular expression that extracts
names and values of HTTP request parameters. 
+ * Regular expression group numbers must be specified for parameter's name and also for parameter's
value.
+ * Replacement will only occur for parameters in the Sampler that uses this RegEx User Parameters
which name matches
+ */
+public class RegExUserParameters extends AbstractTestElement implements Serializable, PreProcessor
{
+	private static final String REGEX_GROUP_SUFFIX = "_g";
+
+    private static final String MATCH_NR = "matchNr";
+
+    /**
+     * 
+     */
+    private static final long serialVersionUID = 5486502839185386122L;
+
+    private static final Logger log = LoggingManager.getLoggerForClass();
+
+	public static final String REG_EX_REF_NAME = "RegExUserParameters.regex_ref_name";// $NON-NLS-1$
+
+	public static final String REG_EX_PARAM_NAMES_GR_NR = "RegExUserParameters.param_names_gr_nr";//
$NON-NLS-1$
+
+	public static final String REG_EX_PARAM_VALUES_GR_NR = "RegExUserParameters.param_values_gr_nr";//
$NON-NLS-1$
+
+    @Override
+	public void process() {
+        if (log.isDebugEnabled()) {
+            log.debug(Thread.currentThread().getName() + " Running up named: " + getName());//$NON-NLS-1$
+        }
+        Sampler entry = getThreadContext().getCurrentSampler();
+        if (!(entry instanceof HTTPSamplerBase)) {
+            return;
+        }
+
+        Map<String, String> paramMap = buildParamsMap();
+        if(paramMap == null || paramMap.isEmpty()){
+            log.info("RegExUserParameters element:"+getName()+" => Referenced RegExp was
not found, no parameter will be changed");
+            return;
+        }
+
+        HTTPSamplerBase sampler = (HTTPSamplerBase) entry;
+        PropertyIterator iter = sampler.getArguments().iterator();
+        while (iter.hasNext()) {
+            Argument arg = (Argument) iter.next().getObjectValue();
+            String oldValue = arg.getValue();
+            // if parameter name exists in http request
+            // then change its value with value obtained with regular expression
+            String val = paramMap.get(arg.getName());
+            if (val != null) {
+                arg.setValue(val);
+            }
+            if (log.isDebugEnabled()){
+                log.debug("RegExUserParameters element:"+getName()+" => changed parameter:
"+arg.getName() +" = "+ arg.getValue()+", was:"+oldValue);
+            }
+        }
+    }
+	
+	private Map<String, String> buildParamsMap(){		
+		String regExRefName = getRegExRefName()+"_";
+		String grNames = getRegParamNamesGrNr();
+		String grValues = getRegExParamValuesGrNr();
+		JMeterVariables jmvars = getThreadContext().getVariables();	
+		// verify if regex groups exists
+		if(jmvars.get(regExRefName + MATCH_NR) == null
+				|| jmvars.get(regExRefName + 1 + REGEX_GROUP_SUFFIX + grNames) == null 
+				|| jmvars.get(regExRefName + 1 + REGEX_GROUP_SUFFIX + grValues) == null){
+			return null;
+		}
+		int n = Integer.parseInt(jmvars.get(regExRefName + MATCH_NR));	
+		Map<String, String> map = new HashMap<String, String>(n);
+		for(int i=1; i<=n; i++){
+			map.put(jmvars.get(regExRefName + i + REGEX_GROUP_SUFFIX + grNames), 
+					jmvars.get(regExRefName + i + REGEX_GROUP_SUFFIX + grValues));
+		}
+		return map;
+	}
+
+	/**
+	 * A new instance is created for each thread group, and the
+	 * clone() method is then called to create copies for each thread in a
+	 * thread group.
+	 * 
+	 * @see java.lang.Object#clone()
+	 */
+	@Override
+	public Object clone() {
+		RegExUserParameters up = (RegExUserParameters) super.clone();
+		return up;
+	}
+	
+    public void setRegExRefName(String str) {
+        setProperty(REG_EX_REF_NAME, str);
+    }
+
+    public String getRegExRefName() {
+        return getPropertyAsString(REG_EX_REF_NAME);
+    }
+
+    public void setRegExParamNamesGrNr(String str) {
+        setProperty(REG_EX_PARAM_NAMES_GR_NR, str);
+    }
+
+    public String getRegParamNamesGrNr() {
+        return getPropertyAsString(REG_EX_PARAM_NAMES_GR_NR);
+    }
+
+    public void setRegExParamValuesGrNr(String str) {
+        setProperty(REG_EX_PARAM_VALUES_GR_NR, str);
+    }
+
+    public String getRegExParamValuesGrNr() {
+        return getPropertyAsString(REG_EX_PARAM_VALUES_GR_NR);
+    }
+}
\ No newline at end of file

Propchange: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/modifier/RegExUserParameters.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/modifier/gui/RegExUserParametersGui.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/modifier/gui/RegExUserParametersGui.java?rev=1427477&view=auto
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/modifier/gui/RegExUserParametersGui.java
(added)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/modifier/gui/RegExUserParametersGui.java
Tue Jan  1 17:18:46 2013
@@ -0,0 +1,165 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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.protocol.http.modifier.gui;
+
+import java.awt.BorderLayout;
+import java.awt.Component;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.util.List;
+
+import javax.swing.Box;
+import javax.swing.JPanel;
+
+import org.apache.jmeter.processor.gui.AbstractPreProcessorGui;
+import org.apache.jmeter.protocol.http.modifier.RegExUserParameters;
+import org.apache.jmeter.testelement.TestElement;
+import org.apache.jmeter.util.JMeterUtils;
+import org.apache.jorphan.gui.JLabeledTextField;
+
+/**
+ * GUI for {@link RegExUserParameters}
+ */
+public class RegExUserParametersGui extends AbstractPreProcessorGui {
+	
+	/**
+     * 
+     */
+    private static final long serialVersionUID = 3080808672311046276L;
+
+	private JLabeledTextField refRegExRefNameField;
+	
+	private JLabeledTextField paramNamesGrNrField;
+
+	private JLabeledTextField paramValuesGrNrField;
+
+	public RegExUserParametersGui() {
+		super();
+		init();
+	}
+
+	@Override
+	public String getLabelResource() {
+		return "regex_params_title"; //$NON-NLS-1$
+	}
+
+    @Override
+	public void configure(TestElement el) {
+		super.configure(el);
+		if (el instanceof RegExUserParameters){
+			RegExUserParameters re = (RegExUserParameters) el;
+			paramNamesGrNrField.setText(re.getRegParamNamesGrNr());
+			paramValuesGrNrField.setText(re.getRegExParamValuesGrNr());
+			refRegExRefNameField.setText(re.getRegExRefName());
+		}
+	}
+
+	/**
+	 * @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
+	 */
+    @Override
+	public TestElement createTestElement() {
+		RegExUserParameters regExUserParams = new RegExUserParameters();
+		modifyTestElement(regExUserParams);
+		return regExUserParams;
+	}
+
+	/**
+	 * Modifies a given TestElement to mirror the data in the gui components.
+	 * 
+	 * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
+	 */
+    @Override
+	public void modifyTestElement(TestElement extractor) {
+		super.configureTestElement(extractor);
+		if (extractor instanceof RegExUserParameters) {
+			RegExUserParameters regExUserParams = (RegExUserParameters) extractor;		
+			regExUserParams.setRegExRefName(refRegExRefNameField.getText());
+			regExUserParams.setRegExParamNamesGrNr(paramNamesGrNrField.getText());
+			regExUserParams.setRegExParamValuesGrNr(paramValuesGrNrField.getText());
+		}
+	}
+    
+    /**
+     * Implements JMeterGUIComponent.clearGui
+     */
+    @Override
+    public void clearGui() {
+        super.clearGui();
+        
+        paramNamesGrNrField.setText(""); //$NON-NLS-1$
+        paramValuesGrNrField.setText(""); //$NON-NLS-1$
+        refRegExRefNameField.setText(""); //$NON-NLS-1$
+    }    
+
+	private void init() {
+		setLayout(new BorderLayout());
+		setBorder(makeBorder());
+
+		Box box = Box.createVerticalBox();
+		box.add(makeTitlePanel());
+		add(box, BorderLayout.NORTH);
+		add(makeParameterPanel(), BorderLayout.CENTER);
+	}
+
+	private JPanel makeParameterPanel() {
+		refRegExRefNameField = new JLabeledTextField(JMeterUtils.getResString("regex_params_ref_name_field"));
//$NON-NLS-1$
+		paramNamesGrNrField = new JLabeledTextField(JMeterUtils.getResString("regex_params_names_field"));
//$NON-NLS-1$
+		paramValuesGrNrField = new JLabeledTextField(JMeterUtils.getResString("regex_params_values_field"));
//$NON-NLS-1$
+
+		JPanel panel = new JPanel(new GridBagLayout());
+		GridBagConstraints gbc = new GridBagConstraints();
+		initConstraints(gbc);
+		addField(panel, refRegExRefNameField, gbc);
+		resetContraints(gbc);
+		addField(panel, paramNamesGrNrField, gbc);
+		resetContraints(gbc);
+		gbc.weighty = 1;
+		addField(panel, paramValuesGrNrField, gbc);
+		return panel;
+	}
+
+	private void addField(JPanel panel, JLabeledTextField field, GridBagConstraints gbc) {
+		List item = field.getComponentList();
+		panel.add((Component) item.get(0), gbc.clone());
+		gbc.gridx++;
+		gbc.weightx = 1;
+		gbc.fill=GridBagConstraints.HORIZONTAL;
+		panel.add((Component) item.get(1), gbc.clone());
+	}
+
+	// Next line
+	private void resetContraints(GridBagConstraints gbc) {
+		gbc.gridx = 0;
+		gbc.gridy++;
+		gbc.weightx = 0;
+        gbc.fill=GridBagConstraints.NONE;
+	}
+
+	private void initConstraints(GridBagConstraints gbc) {
+		gbc.anchor = GridBagConstraints.NORTHWEST;
+		gbc.fill = GridBagConstraints.NONE;
+		gbc.gridheight = 1;
+		gbc.gridwidth = 1;
+		gbc.gridx = 0;
+		gbc.gridy = 0;
+		gbc.weightx = 0;
+		gbc.weighty = 0;
+	}
+}

Propchange: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/modifier/gui/RegExUserParametersGui.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1427477&r1=1427476&r2=1427477&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Tue Jan  1 17:18:46 2013
@@ -222,6 +222,7 @@ to the elements View Results Tree, Asser
 <h3>Timers, Assertions, Config, Pre- &amp; Post-Processors</h3>
 <ul>
 <li><bugzilla>54259</bugzilla> - Introduce a new Extractor that uses CSS
or jquery-like selector syntax</li>
+<li><bugzilla>45772</bugzilla> - RgEx User Parameters Post Processor</li>
 </ul>
 
 <h3>Functions</h3>

Added: jmeter/trunk/xdocs/demos/RegEx-User-Parameters.jmx
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/demos/RegEx-User-Parameters.jmx?rev=1427477&view=auto
==============================================================================
--- jmeter/trunk/xdocs/demos/RegEx-User-Parameters.jmx (added)
+++ jmeter/trunk/xdocs/demos/RegEx-User-Parameters.jmx Tue Jan  1 17:18:46 2013
@@ -0,0 +1,183 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jmeterTestPlan version="1.2" properties="2.4" jmeter="2.9-SNAPSHOT.20130101">
+  <hashTree>
+    <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan" enabled="true">
+      <stringProp name="TestPlan.comments">Start HTTP Mirror Server for demo</stringProp>
+      <boolProp name="TestPlan.functional_mode">false</boolProp>
+      <boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
+      <elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel"
testclass="Arguments" testname="User Defined Variables" enabled="true">
+        <collectionProp name="Arguments.arguments"/>
+      </elementProp>
+      <stringProp name="TestPlan.user_define_classpath"></stringProp>
+    </TestPlan>
+    <hashTree>
+      <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread
Group" enabled="true">
+        <stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
+        <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel"
testclass="LoopController" testname="Loop Controller" enabled="true">
+          <boolProp name="LoopController.continue_forever">false</boolProp>
+          <stringProp name="LoopController.loops">1</stringProp>
+        </elementProp>
+        <stringProp name="ThreadGroup.num_threads">1</stringProp>
+        <stringProp name="ThreadGroup.ramp_time">1</stringProp>
+        <longProp name="ThreadGroup.start_time">1357057761000</longProp>
+        <longProp name="ThreadGroup.end_time">1357057761000</longProp>
+        <boolProp name="ThreadGroup.scheduler">false</boolProp>
+        <stringProp name="ThreadGroup.duration"></stringProp>
+        <stringProp name="ThreadGroup.delay"></stringProp>
+      </ThreadGroup>
+      <hashTree>
+        <JavaSampler guiclass="JavaTestSamplerGui" testclass="JavaSampler" testname="Java
Request" enabled="true">
+          <elementProp name="arguments" elementType="Arguments" guiclass="ArgumentsPanel"
testclass="Arguments" enabled="true">
+            <collectionProp name="Arguments.arguments">
+              <elementProp name="Sleep_Time" elementType="Argument">
+                <stringProp name="Argument.name">Sleep_Time</stringProp>
+                <stringProp name="Argument.value">100</stringProp>
+                <stringProp name="Argument.metadata">=</stringProp>
+              </elementProp>
+              <elementProp name="Sleep_Mask" elementType="Argument">
+                <stringProp name="Argument.name">Sleep_Mask</stringProp>
+                <stringProp name="Argument.value">0xFF</stringProp>
+                <stringProp name="Argument.metadata">=</stringProp>
+              </elementProp>
+              <elementProp name="Label" elementType="Argument">
+                <stringProp name="Argument.name">Label</stringProp>
+                <stringProp name="Argument.value">Request returning some form</stringProp>
+                <stringProp name="Argument.metadata">=</stringProp>
+              </elementProp>
+              <elementProp name="ResponseCode" elementType="Argument">
+                <stringProp name="Argument.name">ResponseCode</stringProp>
+                <stringProp name="Argument.value">200</stringProp>
+                <stringProp name="Argument.metadata">=</stringProp>
+              </elementProp>
+              <elementProp name="ResponseMessage" elementType="Argument">
+                <stringProp name="Argument.name">ResponseMessage</stringProp>
+                <stringProp name="Argument.value">OK</stringProp>
+                <stringProp name="Argument.metadata">=</stringProp>
+              </elementProp>
+              <elementProp name="Status" elementType="Argument">
+                <stringProp name="Argument.name">Status</stringProp>
+                <stringProp name="Argument.value">OK</stringProp>
+                <stringProp name="Argument.metadata">=</stringProp>
+              </elementProp>
+              <elementProp name="SamplerData" elementType="Argument">
+                <stringProp name="Argument.name">SamplerData</stringProp>
+                <stringProp name="Argument.value"></stringProp>
+                <stringProp name="Argument.metadata">=</stringProp>
+              </elementProp>
+              <elementProp name="ResultData" elementType="Argument">
+                <stringProp name="Argument.name">ResultData</stringProp>
+                <stringProp name="Argument.value">&lt;html&gt;  &lt;body&gt;
 &lt;form name=&quot;test&quot;&gt;  &lt;input name=&quot;toto&quot;
value=&quot;vtoto&quot; /&gt;  &lt;input name=&quot;tutu&quot; value=&quot;vtutu&quot;
/&gt;  &lt;input name=&quot;titi&quot; value=&quot;vtiti /&gt;  &lt;/form&gt;
 &lt;/body&gt; &lt;/html&gt;</stringProp>
+                <stringProp name="Argument.metadata">=</stringProp>
+              </elementProp>
+            </collectionProp>
+          </elementProp>
+          <stringProp name="classname">org.apache.jmeter.protocol.java.test.JavaTest</stringProp>
+        </JavaSampler>
+        <hashTree>
+          <RegexExtractor guiclass="RegexExtractorGui" testclass="RegexExtractor" testname="listParamsExtractor"
enabled="true">
+            <stringProp name="RegexExtractor.useHeaders">false</stringProp>
+            <stringProp name="RegexExtractor.refname">listParams</stringProp>
+            <stringProp name="RegexExtractor.regex">input name=&quot;([^&quot;]+?)&quot;
value=&quot;([^&quot;]+?)&quot;</stringProp>
+            <stringProp name="RegexExtractor.template">$1$</stringProp>
+            <stringProp name="RegexExtractor.default">NV</stringProp>
+            <stringProp name="RegexExtractor.match_number">-1</stringProp>
+          </RegexExtractor>
+          <hashTree/>
+        </hashTree>
+        <DebugSampler guiclass="TestBeanGUI" testclass="DebugSampler" testname="Debug
Sampler" enabled="true">
+          <boolProp name="displayJMeterProperties">false</boolProp>
+          <boolProp name="displayJMeterVariables">true</boolProp>
+          <boolProp name="displaySystemProperties">false</boolProp>
+        </DebugSampler>
+        <hashTree/>
+        <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="HTTP
Request" enabled="true">
+          <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel"
testclass="Arguments" testname="User Defined Variables" enabled="true">
+            <collectionProp name="Arguments.arguments">
+              <elementProp name="toto" elementType="HTTPArgument">
+                <boolProp name="HTTPArgument.always_encode">false</boolProp>
+                <stringProp name="Argument.value"></stringProp>
+                <stringProp name="Argument.metadata">=</stringProp>
+                <boolProp name="HTTPArgument.use_equals">true</boolProp>
+                <stringProp name="Argument.name">toto</stringProp>
+              </elementProp>
+              <elementProp name="tutu" elementType="HTTPArgument">
+                <boolProp name="HTTPArgument.always_encode">false</boolProp>
+                <stringProp name="Argument.value"></stringProp>
+                <stringProp name="Argument.metadata">=</stringProp>
+                <boolProp name="HTTPArgument.use_equals">true</boolProp>
+                <stringProp name="Argument.name">tutu</stringProp>
+              </elementProp>
+            </collectionProp>
+          </elementProp>
+          <stringProp name="HTTPSampler.domain">localhost</stringProp>
+          <stringProp name="HTTPSampler.port">8081</stringProp>
+          <stringProp name="HTTPSampler.connect_timeout"></stringProp>
+          <stringProp name="HTTPSampler.response_timeout"></stringProp>
+          <stringProp name="HTTPSampler.protocol"></stringProp>
+          <stringProp name="HTTPSampler.contentEncoding"></stringProp>
+          <stringProp name="HTTPSampler.path">/test</stringProp>
+          <stringProp name="HTTPSampler.method">POST</stringProp>
+          <boolProp name="HTTPSampler.follow_redirects">true</boolProp>
+          <boolProp name="HTTPSampler.auto_redirects">false</boolProp>
+          <boolProp name="HTTPSampler.use_keepalive">true</boolProp>
+          <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
+          <boolProp name="HTTPSampler.monitor">false</boolProp>
+          <stringProp name="HTTPSampler.embedded_url_re"></stringProp>
+        </HTTPSamplerProxy>
+        <hashTree>
+          <RegExUserParameters guiclass="RegExUserParametersGui" testclass="RegExUserParameters"
testname="RegEx User Parameters" enabled="true">
+            <stringProp name="RegExUserParameters.regex_ref_name">listParams</stringProp>
+            <stringProp name="RegExUserParameters.param_names_gr_nr">1</stringProp>
+            <stringProp name="RegExUserParameters.param_values_gr_nr">2</stringProp>
+          </RegExUserParameters>
+          <hashTree/>
+        </hashTree>
+      </hashTree>
+      <ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector"
testname="View Results Tree" enabled="true">
+        <boolProp name="ResultCollector.error_logging">false</boolProp>
+        <objProp>
+          <name>saveConfig</name>
+          <value class="SampleSaveConfiguration">
+            <time>true</time>
+            <latency>true</latency>
+            <timestamp>true</timestamp>
+            <success>true</success>
+            <label>true</label>
+            <code>true</code>
+            <message>false</message>
+            <threadName>true</threadName>
+            <dataType>false</dataType>
+            <encoding>false</encoding>
+            <assertions>false</assertions>
+            <subresults>false</subresults>
+            <responseData>false</responseData>
+            <samplerData>false</samplerData>
+            <xml>false</xml>
+            <fieldNames>true</fieldNames>
+            <responseHeaders>false</responseHeaders>
+            <requestHeaders>false</requestHeaders>
+            <responseDataOnError>false</responseDataOnError>
+            <saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMessage>
+            <assertionsResultsToSave>0</assertionsResultsToSave>
+            <bytes>true</bytes>
+            <hostname>true</hostname>
+            <threadCounts>true</threadCounts>
+            <sampleCount>true</sampleCount>
+          </value>
+        </objProp>
+        <stringProp name="TestPlan.comments">ONLY FOR SCRIPTIN</stringProp>
+        <stringProp name="filename"></stringProp>
+      </ResultCollector>
+      <hashTree/>
+      <TestFragmentController guiclass="TestFragmentControllerGui" testclass="TestFragmentController"
testname="Test Fragment" enabled="true"/>
+      <hashTree>
+        <HttpMirrorControl guiclass="HttpMirrorControlGui" testclass="HttpMirrorControl"
testname="HTTP Mirror Server" enabled="true">
+          <stringProp name="HttpMirrorControlGui.port">8081</stringProp>
+          <stringProp name="HttpMirrorControlGui.maxPoolSize">0</stringProp>
+          <stringProp name="HttpMirrorControlGui.maxQueueSize">25</stringProp>
+        </HttpMirrorControl>
+        <hashTree/>
+      </hashTree>
+    </hashTree>
+  </hashTree>
+</jmeterTestPlan>

Added: jmeter/trunk/xdocs/images/screenshots/regex_user_params.png
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/images/screenshots/regex_user_params.png?rev=1427477&view=auto
==============================================================================
Binary file - no diff available.

Propchange: jmeter/trunk/xdocs/images/screenshots/regex_user_params.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: jmeter/trunk/xdocs/usermanual/component_reference.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/component_reference.xml?rev=1427477&r1=1427476&r2=1427477&view=diff
==============================================================================
--- jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
+++ jmeter/trunk/xdocs/usermanual/component_reference.xml Tue Jan  1 17:18:46 2013
@@ -4820,6 +4820,46 @@ this one will be used by "Calculate Pric
 </description>
 </component>
 
+<component name="RegEx User Parameters" index="&sect-num;.7.10"  width="727" height="138"
screenshot="regex_user_params.png">
+    <description><p>Allows to specify dynamic values for HTTP parameters extracted
from another HTTP Request using regular expressions.
+            RegEx User Parameters are specific to individual threads.</p>
+        <p>This component allows you to specify reference name of a regular expression
that extracts names and values of HTTP request parameters. 
+            Regular expression group numbers must be specified for parameter's name and also
for parameter's value.
+            Replacement will only occur for parameters in the Sampler that uses this RegEx
User Parameters which name matches </p>
+    </description>
+    
+    <properties>
+        <property name="Name" required="">Descriptive name for this element that is
shown in the tree.</property>
+        <property name="Regular Expression Reference Name" required="Yes">Name of a
reference to a regular expression</property>
+        <property name="Parameter names regexp group number" required="Yes">Group number
of regular expression used to extract parameter names</property>
+        <property name="Parameter values regex group number" required="Yes">Group number
of regular expression used to extract parameter values</property>
+    </properties>
+    
+    <p>Example:</p>
+    <p>Suppose we have a request which returns a form with 3 input parameters and we
want to extract the value of 2 of them to inject them in next request</p>
+    <p>1. - Create Post Processor Regular Expression for first HTTP Request</p>
+    <ul>
+        <li>refName - set name of a regular expression Ex. (listParams)</li>
+        <li>regular expression - expression that will extract input names and input
values attributes
+            <br/>
+            Ex: input name="([^"]+?)" value="([^"]+?)"</li>
+        <li>template would be empty</li>
+        <li>match nr - -1 (in order to iterate through all the possible matches)</li>
+    </ul>
+    
+    <p>2. - Create Pre Processor RegEx User Parameters for second HTTP Request</p>
+    <ul>
+        <li>refName - set the same reference name of a regular expression, would be
listParams in our example</li>
+        <li>parameter names group number - group number of regular expression for parameter
names, would be 1 in our example</li>
+        <li>parameter values group number - group number of regular expression for
parameter values, would be 2 in our example</li>
+    </ul>
+    
+    <p>See also the <complink name="Regular Expression Extractor"/> element,
which is used to extract parametes names and values</p>
+</component>
+<links>
+        <link href="../demos/RegEx-User-Parameters.jmx">Test Plan showing how to use
RegEx User Parameters</link>
+</links>
+
 <a href="#">^</a>
 
 </section>



Mime
View raw message