arashja / hamcrest

Automatically exported from code.google.com/p/hamcrest
0 stars 0 forks source link

HasXPath broken with Matcher-less matches #90

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago

I am using org.apache.xpath.jaxp.XPath (looks like from Xerces).

my code:
assertThat( document, hasXPath("/root/a1"))

assuming that I have a document element of root and a child of that a1, I
expect that to work.

The problem is that you use String as the return type and (at least for me)
it returns "" if it hasn't any content(which happens after you
"appendNode()").  For the String return type, it returns "" if the path is
there, but the content is empty AND if the path doesn't exist.

A boolean return type returns true, that the path indeed exists.  This is
the behavior that I would expect when not giving a value for it to match.

As a side note, before looking at the code, I expected to make value
comparisons like so: "/root/a1[text()='blah']"

Thanks.

Original issue reported on code.google.com by cavedog...@gmail.com on 16 Jun 2009 at 7:43

GoogleCodeExporter commented 8 years ago
I apologize for submitting this.  It has been addressed in 1.2.  I actually 
looked at
the code, but I missed the NODE return type change on the factory.

hasXPath now works as expected.

Original comment by cavedog...@gmail.com on 17 Jun 2009 at 2:31

GoogleCodeExporter commented 8 years ago
No problem.

Original comment by smgfree...@gmail.com on 17 Jun 2009 at 2:35