This is an automated email from the ASF dual-hosted git repository.
fschumacher pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git
The following commit(s) were added to refs/heads/master by this push:
new b73f69074f Add test for broken xpath in XPathUtil#selectNodeList
b73f69074f is described below
commit b73f69074f8b3b5d71767ab0fedb52f16a1e55d6
Author: Felix Schumacher <[email protected]>
AuthorDate: Sat Jul 23 17:21:10 2022 +0200
Add test for broken xpath in XPathUtil#selectNodeList
---
.../src/test/java/org/apache/jmeter/util/XPathUtilTest.java | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/src/core/src/test/java/org/apache/jmeter/util/XPathUtilTest.java
b/src/core/src/test/java/org/apache/jmeter/util/XPathUtilTest.java
index dd02987a6f..d916487f10 100644
--- a/src/core/src/test/java/org/apache/jmeter/util/XPathUtilTest.java
+++ b/src/core/src/test/java/org/apache/jmeter/util/XPathUtilTest.java
@@ -20,6 +20,7 @@ package org.apache.jmeter.util;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -277,4 +278,14 @@ public class XPathUtilTest {
assertEquals("one", e0.getTextContent());
assertEquals("two", e1.getTextContent());
}
+
+ @Test()
+ public void testSelectNodeListWithInvalidXPath() throws Exception {
+ String responseData =
"<book><page>one</page><page>two</page><empty></empty><a><b></b></a></book>";
+ Document testDoc = XPathUtil.makeDocument(
+ new
ByteArrayInputStream(responseData.getBytes(StandardCharsets.UTF_8)), false,
false, false, false,
+ false, false, false, false, false);
+ String xpathquery = "<";
+ assertThrows(TransformerException.class, () ->
XPathUtil.selectNodeList(testDoc, xpathquery));
+ }
}