Author: sebb Date: Thu Oct 4 04:45:55 2007 New Revision: 581862 URL: http://svn.apache.org/viewvc?rev=581862&view=rev Log: Bug 43451 - Allow Regex Extractor to operate on Response Code/Message
Modified: jakarta/jmeter/trunk/docs/changes.html jakarta/jmeter/trunk/docs/images/screenshots/regex_extractor.png jakarta/jmeter/trunk/docs/usermanual/component_reference.html 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/test/src/org/apache/jmeter/extractor/TestRegexExtractor.java 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/changes.html URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/docs/changes.html?rev=581862&r1=581861&r2=581862&view=diff ============================================================================== --- jakarta/jmeter/trunk/docs/changes.html (original) +++ jakarta/jmeter/trunk/docs/changes.html Thu Oct 4 04:45:55 2007 @@ -196,6 +196,16 @@ </li> + <li > + Property Display to show the value of System and JMeter properties and allow them to be changed + </li> + + + <li > + Bug 43451 - Allow Regex Extractor to operate on Response Code/Message + </li> + + </ul> <h4 > Non-functional Improvements @@ -2913,7 +2923,6 @@ <li > Extra Proxy Server options: Create all samplers with keep-alive disabled - Add Separator markers between sets of samples Add Response Assertion to first sampler in each set </li> 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=581862&r1=581861&r2=581862&view=diff ============================================================================== Binary files - no diff available. Modified: jakarta/jmeter/trunk/docs/usermanual/component_reference.html URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/docs/usermanual/component_reference.html?rev=581862&r1=581861&r2=581862&view=diff ============================================================================== --- jakarta/jmeter/trunk/docs/usermanual/component_reference.html (original) +++ jakarta/jmeter/trunk/docs/usermanual/component_reference.html Thu Oct 4 04:45:55 2007 @@ -10295,13 +10295,11 @@ <tr><td> <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 - <a href="build-test-plan.html#scoping_rules">scope</a> - , applying the regular expression, extracting the requested values, +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> <p><b>Control Panel</b></p> - <div align="center"><img width='395' height='241' src="../images/screenshots/regex_extractor.png"></div> + <div align="center"><img width='494' height='257' src="../images/screenshots/regex_extractor.png"></div> <p> <b>Parameters</b> <table border="1" cellspacing="0" cellpadding="2"> @@ -10316,7 +10314,8 @@ </tr> <tr> <td>Response Field to check</td> - <td> Body or Headers. These refer to the Sampler Response. Headers can be useful for HTTP samples; it may not be present for other sample types. + <td> 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. </td> <td> yes 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=581862&r1=581861&r2=581862&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 Thu Oct 4 04:45:55 2007 @@ -63,6 +63,9 @@ 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_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$ + private static final String REGEX = "RegexExtractor.regex"; // $NON-NLS-1$ @@ -108,9 +111,10 @@ Perl5Matcher matcher = JMeterUtils.getMatcher(); String inputString = - useUrl() ? previousResult.getUrlAsString() // Bug 39707 - : - useHeaders() ? previousResult.getResponseHeaders() + useUrl() ? previousResult.getUrlAsString() // Bug 39707 + : useHeaders() ? previousResult.getResponseHeaders() + : useCode() ? previousResult.getResponseCode() //Bug 43451 + : useMessage() ? previousResult.getResponseMessage() //Bug 43451 : previousResult.getResponseDataAsString() // Bug 36898 ; if (log.isDebugEnabled()) { @@ -360,14 +364,25 @@ // Allow for property not yet being set (probably only applies to Test cases) public boolean useBody() { - String body = getPropertyAsString(MATCH_AGAINST); - return body.length()==0 || USE_BODY.equalsIgnoreCase(body);// $NON-NLS-1$ + String prop = getPropertyAsString(MATCH_AGAINST); + return prop.length()==0 || USE_BODY.equalsIgnoreCase(prop);// $NON-NLS-1$ } public boolean useUrl() { - String body = getPropertyAsString(MATCH_AGAINST); - return USE_URL.equalsIgnoreCase(body); + String prop = getPropertyAsString(MATCH_AGAINST); + return USE_URL.equalsIgnoreCase(prop); } + + public boolean useCode() { + String prop = getPropertyAsString(MATCH_AGAINST); + return USE_CODE.equalsIgnoreCase(prop); + } + + public boolean useMessage() { + String prop = getPropertyAsString(MATCH_AGAINST); + return USE_MESSAGE.equalsIgnoreCase(prop); + } + public void setUseField(String actionCommand) { setProperty(MATCH_AGAINST,actionCommand); } 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=581862&r1=581861&r2=581862&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 Thu Oct 4 04:45:55 2007 @@ -56,6 +56,10 @@ private JRadioButton useURL; + private JRadioButton useCode; + + private JRadioButton useMessage; + private ButtonGroup group; public RegexExtractorGui() { @@ -74,6 +78,8 @@ useHeaders.setSelected(re.useHeaders()); useBody.setSelected(re.useBody()); useURL.setSelected(re.useUrl()); + useCode.setSelected(re.useCode()); + useMessage.setSelected(re.useMessage()); regexField.setText(re.getRegex()); templateField.setText(re.getTemplate()); defaultField.setText(re.getDefaultValue()); @@ -116,8 +122,6 @@ super.clearGui(); useBody.setSelected(true); - useHeaders.setSelected(false); - useURL.setSelected(false); regexField.setText(""); //$NON-NLS-1$ templateField.setText(""); //$NON-NLS-1$ @@ -144,15 +148,21 @@ useBody = new JRadioButton(JMeterUtils.getResString("regex_src_body")); //$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$ + useMessage = new JRadioButton(JMeterUtils.getResString("assertion_message_resp")); //$NON-NLS-1$ group = new ButtonGroup(); group.add(useBody); group.add(useHeaders); group.add(useURL); + group.add(useCode); + group.add(useMessage); panel.add(useBody); panel.add(useHeaders); panel.add(useURL); + panel.add(useCode); + panel.add(useMessage); useBody.setSelected(true); @@ -160,6 +170,8 @@ useBody.setActionCommand(RegexExtractor.USE_BODY); useHeaders.setActionCommand(RegexExtractor.USE_HDRS); useURL.setActionCommand(RegexExtractor.USE_URL); + useCode.setActionCommand(RegexExtractor.USE_CODE); + useMessage.setActionCommand(RegexExtractor.USE_MESSAGE); return panel; } Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/extractor/TestRegexExtractor.java URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/extractor/TestRegexExtractor.java?rev=581862&r1=581861&r2=581862&view=diff ============================================================================== --- jakarta/jmeter/trunk/test/src/org/apache/jmeter/extractor/TestRegexExtractor.java (original) +++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/extractor/TestRegexExtractor.java Thu Oct 4 04:45:55 2007 @@ -60,6 +60,8 @@ + "</row>" + "</company-xmlext-query-ret>"; result.setResponseData(data.getBytes()); result.setResponseHeaders("Header1: Value1\nHeader2: Value2"); + result.setResponseCode("abcd"); + result.setResponseMessage("The quick brown fox"); vars = new JMeterVariables(); jmctx.setVariables(vars); jmctx.setPreviousResult(result); @@ -211,6 +213,29 @@ result.setURL(new URL("http://jakarta.apache.org/index.html?abcd")); extractor.process(); assertEquals("index",vars.get("regVal")); + } + + public void testVariableExtraction9() throws Exception { + extractor.setRegex("(\\w+)"); + extractor.setTemplate("$1$"); + extractor.setMatchNumber(1); + extractor.setUseField(RegexExtractor.USE_CODE); + assertFalse("useHdrs should be false", extractor.useHeaders()); + assertFalse("useBody should be false", extractor.useBody()); + assertFalse("useURL should be false", extractor.useUrl()); + assertFalse("useMessage should be false", extractor.useMessage()); + assertTrue("useCode should be true", extractor.useCode()); + extractor.process(); + assertEquals("abcd",vars.get("regVal")); + extractor.setUseField(RegexExtractor.USE_MESSAGE); + assertFalse("useHdrs should be false", extractor.useHeaders()); + assertFalse("useBody should be false", extractor.useBody()); + assertFalse("useURL should be false", extractor.useUrl()); + assertTrue("useMessage should be true", extractor.useMessage()); + assertFalse("useCode should be falsee", extractor.useCode()); + extractor.setMatchNumber(3); + extractor.process(); + assertEquals("brown",vars.get("regVal")); } public void testNoDefault() throws Exception { Modified: jakarta/jmeter/trunk/xdocs/changes.xml URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/changes.xml?rev=581862&r1=581861&r2=581862&view=diff ============================================================================== --- jakarta/jmeter/trunk/xdocs/changes.xml (original) +++ jakarta/jmeter/trunk/xdocs/changes.xml Thu Oct 4 04:45:55 2007 @@ -46,6 +46,7 @@ <li>Menu items now appear in execution order</li> <li>Test Plan items can now only be dropped/pasted into parts of the tree where they are allowed</li> <li>Property Display to show the value of System and JMeter properties and allow them to be changed</li> +<li>Bug 43451 - Allow Regex Extractor to operate on Response Code/Message</li> </ul> <h4>Non-functional Improvements</h4> 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=581862&r1=581861&r2=581862&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=581862&r1=581861&r2=581862&view=diff ============================================================================== --- jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml (original) +++ jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml Thu Oct 4 04:45:55 2007 @@ -3229,13 +3229,14 @@ is applied only to a particular sampler, add it as a child of the sampler. <br></br> </description> -<component name="Regular Expression Extractor" index="§-num;.8.1" width="395" height="241" screenshot="regex_extractor.png"> +<component name="Regular Expression Extractor" index="§-num;.8.1" width="494" height="257" 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, +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 or Headers. 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">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="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]