ASF Bugzilla – Attachment 27586 Details for
Bug 51885
Allow a JMeter Variable as input to XPathExtractor
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Fix to issue Part 2
ISSUE_51885_Part2.patch (text/plain), 3.45 KB, created by
Philippe Mouawad
on 2011-09-26 07:34:31 UTC
(
hide
)
Description:
Fix to issue Part 2
Filename:
MIME Type:
Creator:
Philippe Mouawad
Created:
2011-09-26 07:34:31 UTC
Size:
3.45 KB
patch
obsolete
>Index: src/components/org/apache/jmeter/extractor/XPathExtractor.java >=================================================================== >--- src/components/org/apache/jmeter/extractor/XPathExtractor.java (revision 1173017) >+++ src/components/org/apache/jmeter/extractor/XPathExtractor.java (working copy) >@@ -20,13 +20,18 @@ > import java.io.ByteArrayInputStream; > import java.io.IOException; > import java.io.Serializable; >-import java.io.UnsupportedEncodingException; > import java.io.StringWriter; >+import java.io.UnsupportedEncodingException; > import java.util.ArrayList; > import java.util.List; > > import javax.xml.parsers.ParserConfigurationException; >+import javax.xml.transform.OutputKeys; >+import javax.xml.transform.Transformer; > import javax.xml.transform.TransformerException; >+import javax.xml.transform.TransformerFactory; >+import javax.xml.transform.dom.DOMSource; >+import javax.xml.transform.stream.StreamResult; > > import org.apache.jmeter.assertions.AssertionResult; > import org.apache.jmeter.processor.PostProcessor; >@@ -49,12 +54,6 @@ > import org.w3c.dom.NodeList; > import org.xml.sax.SAXException; > >-import javax.xml.transform.OutputKeys; >-import javax.xml.transform.Transformer; >-import javax.xml.transform.TransformerFactory; >-import javax.xml.transform.dom.DOMSource; >-import javax.xml.transform.stream.StreamResult; >- > //@see org.apache.jmeter.extractor.TestXPathExtractor for unit tests > > /** >@@ -135,12 +134,18 @@ > vars.put(matchNR, "0"); // In case parse fails // $NON-NLS-1$ > vars.remove(concat(refName,"1")); // In case parse fails // $NON-NLS-1$ > >- List<SampleResult> samples = getSampleList(previousResult); >+ List<String> matches = new ArrayList<String>(); > try{ >- List<String> matches = new ArrayList<String>(); >- for (SampleResult res : samples) { >- Document d = parseResponse(res); >+ if (isScopeVariable()){ >+ String inputString=vars.get(getVariableName()); >+ Document d = parseResponse(inputString); > getValuesForXPath(d,getXPathQuery(),matches); >+ } else { >+ List<SampleResult> samples = getSampleList(previousResult); >+ for (SampleResult res : samples) { >+ Document d = parseResponse(res.getResponseDataAsString()); >+ getValuesForXPath(d,getXPathQuery(),matches); >+ } > } > final int matchCount = matches.size(); > vars.put(matchNR, String.valueOf(matchCount)); >@@ -280,11 +285,11 @@ > /** > * Converts (X)HTML response to DOM object Tree. > * This version cares of charset of response. >- * @param result >+ * @param unicodeData > * @return > * > */ >- private Document parseResponse(SampleResult result) >+ private Document parseResponse(String unicodeData) > throws UnsupportedEncodingException, IOException, ParserConfigurationException,SAXException,TidyException > { > //TODO: validate contentType for reasonable types? >@@ -292,7 +297,6 @@ > // NOTE: responseData encoding is server specific > // Therefore we do byte -> unicode -> byte conversion > // to ensure UTF-8 encoding as required by XPathUtil >- String unicodeData = result.getResponseDataAsString(); > // convert unicode String -> UTF-8 bytes > byte[] utf8data = unicodeData.getBytes("UTF-8"); // $NON-NLS-1$ > ByteArrayInputStream in = new ByteArrayInputStream(utf8data);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 51885
:
27580
| 27586