Skip to content

Commit b73f690

Browse files
committed
Add test for broken xpath in XPathUtil#selectNodeList
1 parent 936e275 commit b73f690

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/core/src/test/java/org/apache/jmeter/util/XPathUtilTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import static org.hamcrest.MatcherAssert.assertThat;
2121
import static org.junit.Assert.assertEquals;
2222
import static org.junit.Assert.assertNull;
23+
import static org.junit.jupiter.api.Assertions.assertThrows;
2324

2425
import java.io.ByteArrayInputStream;
2526
import java.io.IOException;
@@ -277,4 +278,14 @@ public void testSelectNodeList() throws ParserConfigurationException, SAXExcepti
277278
assertEquals("one", e0.getTextContent());
278279
assertEquals("two", e1.getTextContent());
279280
}
281+
282+
@Test()
283+
public void testSelectNodeListWithInvalidXPath() throws Exception {
284+
String responseData = "<book><page>one</page><page>two</page><empty></empty><a><b></b></a></book>";
285+
Document testDoc = XPathUtil.makeDocument(
286+
new ByteArrayInputStream(responseData.getBytes(StandardCharsets.UTF_8)), false, false, false, false,
287+
false, false, false, false, false);
288+
String xpathquery = "<";
289+
assertThrows(TransformerException.class, () -> XPathUtil.selectNodeList(testDoc, xpathquery));
290+
}
280291
}

0 commit comments

Comments
 (0)