Author: sebb
Date: Fri Jul 18 12:03:14 2008
New Revision: 678001

URL: http://svn.apache.org/viewvc?rev=678001&view=rev
Log:
Add Body (unescaped) source option to Regular Expression Extractor.

Modified:
    jakarta/jmeter/trunk/docs/images/screenshots/regex_extractor.png
    
jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/RegexExtractor.java
    
jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/gui/RegexExtractorGui.java
    
jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
    jakarta/jmeter/trunk/xdocs/changes.xml
    jakarta/jmeter/trunk/xdocs/images/screenshots/regex_extractor.png
    jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml

Modified: jakarta/jmeter/trunk/docs/images/screenshots/regex_extractor.png
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/docs/images/screenshots/regex_extractor.png?rev=678001&r1=678000&r2=678001&view=diff
==============================================================================
Binary files - no diff available.

Modified: 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/RegexExtractor.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/RegexExtractor.java?rev=678001&r1=678000&r2=678001&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/RegexExtractor.java
 (original)
+++ 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/RegexExtractor.java
 Fri Jul 18 12:03:14 2008
@@ -24,6 +24,7 @@
 import java.util.LinkedList;
 import java.util.List;
 
+import org.apache.commons.lang.StringEscapeUtils;
 import org.apache.jmeter.processor.PostProcessor;
 import org.apache.jmeter.samplers.SampleResult;
 import org.apache.jmeter.testelement.AbstractTestElement;
@@ -62,6 +63,7 @@
     */
     public static final String USE_HDRS = "true"; // $NON-NLS-1$
     public static final String USE_BODY = "false"; // $NON-NLS-1$
+    public static final String USE_BODY_UNESCAPED = "unescaped"; // $NON-NLS-1$
     public static final String USE_URL = "URL"; // $NON-NLS-1$
     public static final String USE_CODE = "code"; // $NON-NLS-1$
     public static final String USE_MESSAGE = "message"; // $NON-NLS-1$
@@ -81,7 +83,6 @@
 
     private static final String UNDERSCORE = "_";  // $NON-NLS-1$
 
-
     private Object[] template = null;
 
     /**
@@ -115,6 +116,7 @@
             : useHeaders() ? previousResult.getResponseHeaders()
             : useCode() ? previousResult.getResponseCode() //Bug 43451
             : useMessage() ? previousResult.getResponseMessage() //Bug 43451
+            : useUnescapedBody() ? 
StringEscapeUtils.unescapeHtml(previousResult.getResponseDataAsString())
             : previousResult.getResponseDataAsString() // Bug 36898
             ;
            if (log.isDebugEnabled()) {
@@ -416,6 +418,11 @@
         return prop.length()==0 || USE_BODY.equalsIgnoreCase(prop);// 
$NON-NLS-1$
     }
 
+    public boolean useUnescapedBody() {
+        String prop = getPropertyAsString(MATCH_AGAINST);
+        return USE_BODY_UNESCAPED.equalsIgnoreCase(prop);// $NON-NLS-1$
+    }
+
     public boolean useUrl() {
         String prop = getPropertyAsString(MATCH_AGAINST);
         return USE_URL.equalsIgnoreCase(prop);

Modified: 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/gui/RegexExtractorGui.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/gui/RegexExtractorGui.java?rev=678001&r1=678000&r2=678001&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/gui/RegexExtractorGui.java
 (original)
+++ 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/gui/RegexExtractorGui.java
 Fri Jul 18 12:03:14 2008
@@ -52,6 +52,8 @@
 
     private JRadioButton useBody;
 
+    private JRadioButton useUnescapedBody;
+
     private JRadioButton useHeaders;
 
     private JRadioButton useURL;
@@ -77,6 +79,7 @@
             RegexExtractor re = (RegexExtractor) el;
             useHeaders.setSelected(re.useHeaders());
             useBody.setSelected(re.useBody());
+            useUnescapedBody.setSelected(re.useUnescapedBody());
             useURL.setSelected(re.useUrl());
             useCode.setSelected(re.useCode());
             useMessage.setSelected(re.useMessage());
@@ -146,6 +149,7 @@
         
panel.setBorder(BorderFactory.createTitledBorder(JMeterUtils.getResString("regex_source")));
 //$NON-NLS-1$
 
         useBody = new 
JRadioButton(JMeterUtils.getResString("regex_src_body")); //$NON-NLS-1$
+        useUnescapedBody = new 
JRadioButton(JMeterUtils.getResString("regex_src_body_unescaped")); 
//$NON-NLS-1$
         useHeaders = new 
JRadioButton(JMeterUtils.getResString("regex_src_hdrs")); //$NON-NLS-1$
         useURL = new JRadioButton(JMeterUtils.getResString("regex_src_url")); 
//$NON-NLS-1$
         useCode = new 
JRadioButton(JMeterUtils.getResString("assertion_code_resp")); //$NON-NLS-1$
@@ -153,12 +157,14 @@
 
         group = new ButtonGroup();
         group.add(useBody);
+        group.add(useUnescapedBody);
         group.add(useHeaders);
         group.add(useURL);
         group.add(useCode);
         group.add(useMessage);
 
         panel.add(useBody);
+        panel.add(useUnescapedBody);
         panel.add(useHeaders);
         panel.add(useURL);
         panel.add(useCode);
@@ -168,6 +174,7 @@
 
         // So we know which button is selected
         useBody.setActionCommand(RegexExtractor.USE_BODY);
+        useUnescapedBody.setActionCommand(RegexExtractor.USE_BODY_UNESCAPED);
         useHeaders.setActionCommand(RegexExtractor.USE_HDRS);
         useURL.setActionCommand(RegexExtractor.USE_URL);
         useCode.setActionCommand(RegexExtractor.USE_CODE);

Modified: 
jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties?rev=678001&r1=678000&r2=678001&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties 
(original)
+++ 
jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties 
Fri Jul 18 12:03:14 2008
@@ -587,6 +587,7 @@
 regex_field=Regular Expression\:
 regex_source=Response Field to check
 regex_src_body=Body
+regex_src_body_unescaped=Body (unescaped)
 regex_src_hdrs=Headers
 regex_src_url=URL
 regexfunc_param_1=Regular expression used to search previous sample - or 
variable.

Modified: jakarta/jmeter/trunk/xdocs/changes.xml
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/changes.xml?rev=678001&r1=678000&r2=678001&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/changes.xml (original)
+++ jakarta/jmeter/trunk/xdocs/changes.xml Fri Jul 18 12:03:14 2008
@@ -49,6 +49,9 @@
 <ul>
 Added __unescape() function: allows Java-escaped strings to be used.
 </ul>
+<ul>
+Add Body (unescaped) source option to Regular Expression Extractor.
+</ul>
 </p>
 
 <!--  ========================= End of summary 
===================================== -->

Modified: jakarta/jmeter/trunk/xdocs/images/screenshots/regex_extractor.png
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/images/screenshots/regex_extractor.png?rev=678001&r1=678000&r2=678001&view=diff
==============================================================================
Binary files - no diff available.

Modified: jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml?rev=678001&r1=678000&r2=678001&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
+++ jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml Fri Jul 18 
12:03:14 2008
@@ -2744,9 +2744,13 @@
 <properties>
         <property name="Name" required="">Descriptive name for this element 
that is shown in the tree.</property>
         <property name="Response Field to Test" required="Yes">Instructs 
JMeter which field of the Response to test.
-                This may be the Response Text from the server, the URL string 
that was sampled,
-                the Response Headers (JMeter version 2.3RC3 and earlier 
included the headers with the Text),
-                the Response Code (e.g. 404) or the Response Message (e.g. Not 
Found).
+        <ul>
+        <li>Text Response - the response text from the server, i.e. the body, 
excluing any HTTP headers.</li>
+        <li>URL sampled</li>
+        <li>Response Code - e.g. 200</li>
+        <li>Response Message - e.g. OK</li>
+        <li>Response Headers (JMeter version 2.3RC3 and earlier included the 
headers with the Text)</li>
+        </ul>
                 <p>
                 The overall success of the sample is determined by combining 
the result of the
                 assertion with the existing Response status.
@@ -3472,14 +3476,26 @@
        The array will be empty if there are none.
        </p>
        </description>
-<component name="Regular Expression Extractor" index="&sect-num;.8.1"  
width="494" height="257" screenshot="regex_extractor.png">
+<component name="Regular Expression Extractor" index="&sect-num;.8.1"  
width="618" height="256" screenshot="regex_extractor.png">
 <description><p>Allows the user to extract values from a server response using 
a Perl-type regular expression.  As a post-processor,
 this element will execute after each Sample request in its scope, applying the 
regular expression, extracting the requested values,
 generate the template string, and store the result into the given variable 
name.</p></description>
 <properties>
         <property name="Name" required="">Descriptive name for this element 
that is shown in the tree.</property>
-        <property name="Response Field to check" required="yes">Body, Headers, 
URL, Response Code, Response Message.
-        These refer to the Sampler Response. Headers can be useful for HTTP 
samples; it may not be present for other sample types.</property>
+        <property name="Response Field to check" required="yes">
+        The following response fields can be checked:
+        <ul>
+        <li>Body - the body of the response, e.g. the content of a web-page 
(excluding headers)</li>
+        <li>Body (unescaped) - the body of the response, with all Html escape 
codes replaced.
+        Note that Html escapes are processed without regard to context, so 
some incorrect substitutions
+        may be made.
+        </li>
+        <li>Headers - may not be present for non-HTTP samples</li>
+        <li>URL</li>
+        <li>Response Code - e.g. 200</li>
+        <li>Response Message - e.g. OK</li>
+        </ul>
+        Headers can be useful for HTTP samples; it may not be present for 
other sample types.</property>
         <property name="Reference Name" required="Yes">The name of the JMeter 
variable in which to store the result.  Also note that each group is stored as 
[refname]_g#, where [refname] is the string you entered as the reference name, 
and # is the group number, where group 0 is the entire match, group 1 is the 
match from the first set of parentheses, etc.</property>
         <property name="Regular Expression" required="Yes">The regular 
expression used to parse the response data. 
         This must contain at least one set of parentheses "()" to capture a 
portion of the string, unless using the group $0$.



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to