Bug 42088 - XPath Assertion component does not work for queries which result in boolean, numbers etc
XPath Assertion component does not work for queries which result in boolean, ...
Status: RESOLVED FIXED
Product: JMeter
Classification: Unclassified
Component: Main
2.2
All All
: P2 normal (vote)
: ---
Assigned To: JMeter issues mailing list
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2007-04-11 07:47 UTC by Ali Ranalvi
Modified: 2007-04-15 15:15 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ali Ranalvi 2007-04-11 07:47:22 UTC
The JMeter XPath Assertion (classname: 
org.jmeter.components.assertions.XpathAssertion) component does not work for a 
subset of XPath queries.

Current behaviour: The XpathAssertion *only* works for XPath queries which 
return a NodeList. For any other queries that return a non-NodeList result, 
XpathAssertion fails with a TransformerException.

Eg:
<response>
  <code>1</code>
  <error>Print Error</error>
  <error>Network Error</error>
</response>

XpathAssertion works for //*[code=1]

XpathAssertion does not work for count(//*error)=2   {this is valid XPath}
It returns a TransformerException.

Proposed Solution:
We need additional meat in XpathAssertion#getResult(SampleResult):
1. Use generic XPathAPI.eval, instead of XPathAPI.selectNodeList 
2. Make decision based on the return value of point 1.
   a. If NodeList, do as earlier.
   b. If boolean, then fail if false, else pass.
   c. So on for other types.


After the fix, the following assertions must be successful,

<response>
  <code>1</code>
  <error>Print Error</error>
  <error>Network Error</error>
</response>

Query 1
count(//*error)=2

Query 2
count(//*[code=1])=1

These would be unsuccessful:

Query 3
count(//*error)=1

Query 4
count(//*[code=2])=1

(Further tests can be added, depending on what return values from XPath 
queries are being supported - boolean, number etc)
Comment 1 Sebb 2007-04-15 15:15:14 UTC
Added to SVN in r529081