From ad50d1da954e3a7bf3510330cf42c15818c193c9 Mon Sep 17 00:00:00 2001 From: night-gale Date: Sun, 25 Apr 2021 08:14:52 +0800 Subject: [PATCH] Added one more testcase to multiple element xml matcher --- .../test/java/org/hamcrest/xml/HasXPathTest.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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);