diff --git a/hamcrest/src/test/java/org/hamcrest/xml/HasXPathTest.java b/hamcrest/src/test/java/org/hamcrest/xml/HasXPathTest.java index e024177c..46a20268 100644 --- a/hamcrest/src/test/java/org/hamcrest/xml/HasXPathTest.java +++ b/hamcrest/src/test/java/org/hamcrest/xml/HasXPathTest.java @@ -92,6 +92,21 @@ public Iterator 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("\n" + + "\n" + + "A-ISBN\n" + + "\n" + + "\n" + ); + + assertMatches(hasXPath("/books/book/isbn", equalTo("A-ISBN")), multipleBookXml); + } + @Test public void matchesEmptyElement() { assertMatches(hasXPath("//emptySomething"), xml);