You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by fs...@apache.org on 2022/07/23 15:18:49 UTC

[jmeter] branch master updated (cbcf41fc84 -> 936e275e5a)

This is an automated email from the ASF dual-hosted git repository.

fschumacher pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git


    from cbcf41fc84 Restructure tests for XPathUtil
     new 3d49c6efb7 Update XPathUtilTest.java
     new 936e275e5a Update XPathUtilTest.java

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../java/org/apache/jmeter/util/XPathUtilTest.java | 23 ++++++++++++++++++++++
 1 file changed, 23 insertions(+)


[jmeter] 01/02: Update XPathUtilTest.java

Posted by fs...@apache.org.
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

commit 3d49c6efb781035ab23e14127502e765abdb2534
Author: PJ Fanning <pj...@users.noreply.github.com>
AuthorDate: Sat Jul 23 15:32:28 2022 +0100

    Update XPathUtilTest.java
---
 src/core/src/test/java/org/apache/jmeter/util/XPathUtilTest.java | 6 ++++++
 1 file changed, 6 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 c258cba5d3..89f1f4dc76 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
@@ -19,6 +19,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 java.io.ByteArrayInputStream;
 import java.io.IOException;
@@ -251,7 +252,12 @@ public class XPathUtilTest {
         assertEquals("<page>two</page>", matchs.get(1));
         matchs=new ArrayList<>();
         XPathUtil.putValuesForXPathInList(testDoc, xpathquery, matchs, false);
+        assertEquals(2, matchs.size());
         assertEquals("one", matchs.get(0));
         assertEquals("two", matchs.get(1));
+        matchs=new ArrayList<>();
+        XPathUtil.putValuesForXPathInList(testDoc, "/book/a", matchs, false);
+        assertEquals(1, matchs.size());
+        assertNull(matchs.get(0));
     }
 }


[jmeter] 02/02: Update XPathUtilTest.java

Posted by fs...@apache.org.
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

commit 936e275e5a7689284bb8ec63b719221090a6163c
Author: PJ Fanning <pj...@users.noreply.github.com>
AuthorDate: Sat Jul 23 16:13:11 2022 +0100

    Update XPathUtilTest.java
---
 .../test/java/org/apache/jmeter/util/XPathUtilTest.java | 17 +++++++++++++++++
 1 file changed, 17 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 89f1f4dc76..dd02987a6f 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
@@ -45,6 +45,8 @@ import org.junit.jupiter.params.provider.Arguments;
 import org.junit.jupiter.params.provider.CsvSource;
 import org.junit.jupiter.params.provider.MethodSource;
 import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
 import org.xml.sax.SAXException;
 
 import net.sf.saxon.s9api.Processor;
@@ -260,4 +262,19 @@ public class XPathUtilTest {
         assertEquals(1, matchs.size());
         assertNull(matchs.get(0));
     }
+
+    @Test
+    public void testSelectNodeList() throws ParserConfigurationException, SAXException, IOException, TidyException, TransformerException {
+        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 = "/book/page";
+        NodeList nodeList = XPathUtil.selectNodeList(testDoc, xpathquery);
+        assertEquals(2, nodeList.getLength());
+        Element e0 = (Element) nodeList.item(0);
+        Element e1 = (Element) nodeList.item(1);
+        assertEquals("one", e0.getTextContent());
+        assertEquals("two", e1.getTextContent());
+    }
 }