Bug 42088 - XPath Assertion component does not work for queries which result in boolean, numbers etc
Summary: XPath Assertion component does not work for queries which result in boolean, ...
Alias: None
Product: JMeter
Classification: Unclassified
Component: Main (show other bugs)
Version: 2.2
Hardware: All All
: P2 normal (vote)
Target Milestone: ---
Assignee: JMeter issues mailing list
Depends on:
Reported: 2007-04-11 07:47 UTC by Ali Ranalvi
Modified: 2007-04-15 15:15 UTC (History)
0 users


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.

  <error>Print Error</error>
  <error>Network Error</error>

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,

  <error>Print Error</error>
  <error>Network Error</error>

Query 1

Query 2

These would be unsuccessful:

Query 3

Query 4

(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