jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1860511 - in /jmeter/trunk: src/components/org/apache/jmeter/assertions/gui/ src/core/org/apache/jmeter/resources/ src/core/org/apache/jmeter/util/ test/src/org/apache/jmeter/assertions/ xdocs/ xdocs/usermanual/
Date Sun, 02 Jun 2019 10:37:36 GMT
Author: pmouawad
Date: Sun Jun  2 10:37:36 2019
New Revision: 1860511

URL: http://svn.apache.org/viewvc?rev=1860511&view=rev
Log:
Bug 63455 - XPath Assertion: "True if nothing matches" does not work if XPath expression returns
a boolean

Contributed by UbikLoadPack (https://ubikloadpack.com)

This closes #460
Bugzilla Id: 63455

Modified:
    jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XPathPanel.java
    jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
    jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties
    jmeter/trunk/src/core/org/apache/jmeter/util/XPathUtil.java
    jmeter/trunk/test/src/org/apache/jmeter/assertions/XPathAssertionTest.java
    jmeter/trunk/xdocs/changes.xml
    jmeter/trunk/xdocs/usermanual/component_reference.xml

Modified: jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XPathPanel.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XPathPanel.java?rev=1860511&r1=1860510&r2=1860511&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XPathPanel.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XPathPanel.java Sun Jun 
2 10:37:36 2019
@@ -72,7 +72,7 @@ public class XPathPanel extends JPanel {
         hbox.add(Box.createHorizontalGlue());
 
         add(JTextScrollPane.getInstance(getXPathField()), BorderLayout.CENTER);
-        add(hbox, BorderLayout.SOUTH);
+        add(hbox, BorderLayout.NORTH);
 
         setDefaultValues();
     }

Modified: jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties?rev=1860511&r1=1860510&r2=1860511&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties Sun Jun  2 10:37:36
2019
@@ -1452,12 +1452,12 @@ xml_validate_button=Validate XML
 xml_whitespace_button=Ignore Whitespace
 xmlschema_assertion_label=File Name:
 xmlschema_assertion_title=XML Schema Assertion
-xpath_assertion_button=Validate
+xpath_assertion_button=Validate xpath expression
 xpath_assertion_check=Check XPath Expression
 xpath_assertion_error=Error with XPath
 xpath_assertion_failed=Invalid XPath Expression
 xpath_assertion_label=XPath
-xpath_assertion_negate=True if nothing matches
+xpath_assertion_negate=Invert assertion(will fail if above conditions met)
 xpath_assertion_option=XML Parsing Options
 xpath_assertion_test=XPath Assertion 
 xpath_assertion_tidy=Try and tidy up the input

Modified: jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties?rev=1860511&r1=1860510&r2=1860511&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties Sun Jun  2 10:37:36
2019
@@ -1441,12 +1441,12 @@ xml_validate_button=Validation XML
 xml_whitespace_button=Ignorer les espaces
 xmlschema_assertion_label=Nom de fichier \: 
 xmlschema_assertion_title=Assertion Schéma XML
-xpath_assertion_button=Valider
+xpath_assertion_button=Valider l'expression xpath
 xpath_assertion_check=Vérifier l'expression XPath
 xpath_assertion_error=Erreur avec XPath
 xpath_assertion_failed=Expression XPath invalide
 xpath_assertion_label=XPath
-xpath_assertion_negate=Vrai si aucune correspondance trouvée
+xpath_assertion_negate=Inverser l'assertion (échouera si les conditions ci-dessus sont
remplies)s
 xpath_assertion_option=Options d'analyse XML
 xpath_assertion_test=Vérificateur XPath
 xpath_assertion_tidy=Essayer et nettoyer l'entrée

Modified: jmeter/trunk/src/core/org/apache/jmeter/util/XPathUtil.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/util/XPathUtil.java?rev=1860511&r1=1860510&r2=1860511&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/util/XPathUtil.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/util/XPathUtil.java Sun Jun  2 10:37:36 2019
@@ -625,10 +625,11 @@ public class XPathUtil {
                 }
                 return;
             case XObject.CLASS_BOOLEAN:
-                if (!xObject.bool()){
-                    result.setFailure(!isNegated);
-                    result.setFailureMessage("No Nodes Matched " + xPathExpression);
-                }
+                boolean resultOfEval = xObject.bool();
+                result.setFailure(isNegated ? resultOfEval : !resultOfEval);
+                result.setFailureMessage(isNegated ?
+                        "Nodes Matched for " + xPathExpression
+                        : "No Nodes Matched for " + xPathExpression);
                 return;
             default:
                 result.setFailure(true);

Modified: jmeter/trunk/test/src/org/apache/jmeter/assertions/XPathAssertionTest.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/assertions/XPathAssertionTest.java?rev=1860511&r1=1860510&r2=1860511&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/assertions/XPathAssertionTest.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/assertions/XPathAssertionTest.java Sun Jun  2
10:37:36 2019
@@ -116,17 +116,39 @@ public class XPathAssertionTest extends
         testLog.debug("failure message: {}", res.getFailureMessage());
         assertFalse("Should not be an error", res.isError());
         assertFalse("Should not be a failure",res.isFailure());
-    }
+    }   
+    @Test
+    public void testAssertionPath1Negated() {
+        assertion.setXPathString("//*[code=1]");
+        assertion.setNegated(true);
+        AssertionResult res = assertion.getResult(result);
+        testLog.debug("isError() {} isFailure() {}", res.isError(), res.isFailure());
+        testLog.debug("failure message: {}", res.getFailureMessage());
+        assertFalse("Should not be an error", res.isError());
+        assertTrue("Should be a failure",res.isFailure());
+    } 
 
     @Test
     public void testAssertionPath2() throws Exception {
         assertion.setXPathString("//*[code=2]"); // Not present
+        assertion.setNegated(true);
         AssertionResult res = assertion.getResult(result);
         testLog.debug("isError() {} isFailure() {}", res.isError(), res.isFailure());
         testLog.debug("failure message: {}", res.getFailureMessage());
         assertFalse("Should not be an error", res.isError());
-        assertTrue("Should be a failure",res.isFailure());
+        assertFalse("Should not be a failure",res.isFailure());
     }
+    
+    @Test
+    public void testAssertionPath2Negated() {
+        assertion.setXPathString("//*[code=1]");
+        assertion.setNegated(true);
+        AssertionResult res = assertion.getResult(result);
+        testLog.debug("isError() {} isFailure() {}", res.isError(), res.isFailure());
+        testLog.debug("failure message: {}", res.getFailureMessage());
+        assertFalse("Should not be an error", res.isError());
+        assertTrue("Should not be a failure",res.isFailure());
+    } 
 
     @Test
     public void testAssertionBool1() throws Exception {
@@ -137,7 +159,20 @@ public class XPathAssertionTest extends
         assertFalse("Should not be an error", res.isError());
         assertFalse("Should not be a failure",res.isFailure());
     }
-
+    
+    @Test
+    public void testAssertionBool1Negated() {
+        assertion.setXPathString("count(//error)=2");
+        assertion.setNegated(true);
+        AssertionResult res = assertion.getResult(result);
+        testLog.debug("isError() {} isFailure() {}", res.isError(), res.isFailure());
+        testLog.debug("failure message: {}", res.getFailureMessage());
+        assertFalse("Should not be an error", res.isError());
+        assertTrue("Should not be a failure",res.isFailure());
+        assertEquals("when isNegated is true, when xpath matches, result should fail", 
+                "Nodes Matched for count(//error)=2" , res.getFailureMessage());
+    }
+    
     @Test
     public void testAssertionBool2() throws Exception {
         assertion.setXPathString("count(//*[code=1])=1");
@@ -147,7 +182,20 @@ public class XPathAssertionTest extends
         assertFalse("Should not be an error", res.isError());
         assertFalse("Should not be a failure",res.isFailure());
     }
-
+    
+    @Test
+    public void testAssertionBool2Negated() {
+        assertion.setXPathString("count(//*[code=1])=1");
+        assertion.setNegated(true);
+        AssertionResult res = assertion.getResult(result);
+        testLog.debug("isError() {} isFailure() {}", res.isError(), res.isFailure());
+        testLog.debug("failure message: {}", res.getFailureMessage());
+        assertFalse("Should not be an error", res.isError());
+        assertTrue("Should be a failure",res.isFailure());
+        assertEquals("Nodes Matched for count(//*[code=1])=1" , res.getFailureMessage());
+        
+    }
+    
     @Test
     public void testAssertionBool3() throws Exception {
         assertion.setXPathString("count(//error)=1"); // wrong
@@ -156,6 +204,17 @@ public class XPathAssertionTest extends
         testLog.debug("failure message: {}", res.getFailureMessage());
         assertFalse("Should not be an error", res.isError());
         assertTrue("Should be a failure", res.isFailure());
+        assertEquals("No Nodes Matched for count(//error)=1" , res.getFailureMessage());
+    }
+    @Test
+    public void testAssertionBool3Negated() {
+        assertion.setXPathString("count(//error)=1"); // wrong
+        assertion.setNegated(true);
+        AssertionResult res = assertion.getResult(result);
+        testLog.debug("isError() {} isFailure() {}", res.isError(), res.isFailure());
+        testLog.debug("failure message: {}", res.getFailureMessage());
+        assertFalse("Should not be an error", res.isError());
+        assertFalse("Should not be a failure", res.isFailure());
     }
 
     @Test
@@ -167,7 +226,18 @@ public class XPathAssertionTest extends
         assertFalse("Should not be an error", res.isError());
         assertTrue("Should be a failure",res.isFailure());
     }
-
+    
+    @Test
+    public void testAssertionBool4Negated() throws Exception {
+        assertion.setXPathString("count(//*[code=2])=1"); //Wrong
+        AssertionResult res = assertion.getResult(result);
+        assertion.setNegated(true);
+        testLog.debug("isError() {} isFailure() {}", res.isError(), res.isFailure());
+        testLog.debug("failure message: {}", res.getFailureMessage());
+        assertFalse("Should not be an error", res.isError());
+        assertTrue("Should be a failure",res.isFailure());
+        assertEquals("No Nodes Matched for count(//*[code=2])=1" , res.getFailureMessage());
+    }
     @Test
     public void testAssertionNumber() throws Exception {
         assertion.setXPathString("count(//error)");// not yet handled
@@ -338,5 +408,6 @@ public class XPathAssertionTest extends
         assertFalse(res.isFailure());
         assertFalse(res.isError());
     }
+    
 
 }

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1860511&r1=1860510&r2=1860511&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
+++ jmeter/trunk/xdocs/changes.xml [utf-8] Sun Jun  2 10:37:36 2019
@@ -76,6 +76,7 @@ to view the last major behaviors with th
 <ch_section>Incompatible changes</ch_section>
 <ul>
     <li>HTTP(S) Test Script Recorder now appends number at end of names, while previously
it added it at beginning. See <bugzilla>63450</bugzilla></li>
+    <li>When using XPath Assertion with an xpath expression returning a boolean, <code>True
if nothing matches</code> had no effect and always returned true, see <bugzilla>63455</bugzilla></li>
 </ul>
 <!-- =================== Improvements =================== -->
 
@@ -161,6 +162,7 @@ to view the last major behaviors with th
 
 <h3>Timers, Assertions, Config, Pre- &amp; Post-Processors</h3>
 <ul>
+    <li><bug>63455</bug>XPath Assertion: <code>True if nothing matches</code>
does not work if XPath expression returns a boolean. Contributed by Ubik Load Pack (support
at ubikloadpack.com)</li>
 </ul>
 
 <h3>Functions</h3>

Modified: jmeter/trunk/xdocs/usermanual/component_reference.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/component_reference.xml?rev=1860511&r1=1860510&r2=1860511&view=diff
==============================================================================
--- jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
+++ jmeter/trunk/xdocs/usermanual/component_reference.xml Sun Jun  2 10:37:36 2019
@@ -4701,7 +4701,7 @@ Some sample expressions:
 <property name="Ignore Whitespace"  required="If Tidy is not selected">Ignore Element
Whitespace.</property>
 <property name="Fetch External DTDs"  required="If Tidy is not selected">If selected,
external DTDs are fetched.</property>
 <property name="XPath Assertion"    required="Yes">XPath to match in the document.</property>
-<property name="True if nothing matches"    required="No">True if a XPath expression
is not matched</property>
+<property name="Invert assertion(will fail if above conditions met)"    required="No">True
if a XPath expression is not matched or returns false</property>
 </properties>
 <note>
 The non-tolerant parser can be quite slow, as it may need to download the DTD etc.



Mime
View raw message