Skip to content

Commit

Permalink
Added one more testcase to multiple element xml matcher
Browse files Browse the repository at this point in the history
  • Loading branch information
HaoWang420 committed Apr 25, 2021
1 parent a5a5760 commit ad50d1d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions hamcrest/src/test/java/org/hamcrest/xml/HasXPathTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,21 @@ public Iterator<String> getPrefixes(String namespaceURI) {
assertMatches(hasXPath("/books/book/isbn", equalTo("A-ISBN")), multipleBookXml);
}

/*
Test whether the single element case still works or not
*/
@Test public void
appliesMatcherToPathInDocumentWithSingleElement() {
Document multipleBookXml = parse("<books>\n"
+ "<book>\n"
+ "<isbn>A-ISBN</isbn>\n"
+ "</book>\n"
+ "</books>\n"
);

assertMatches(hasXPath("/books/book/isbn", equalTo("A-ISBN")), multipleBookXml);
}

@Test public void
matchesEmptyElement() {
assertMatches(hasXPath("//emptySomething"), xml);
Expand Down

0 comments on commit ad50d1d

Please sign in to comment.