Author: sebb
Date: Sat Oct  4 11:06:35 2008
New Revision: 701680

URL: http://svn.apache.org/viewvc?rev=701680&view=rev
Log:
Bug 45904 - Allow 'Not' Response Assertion to succeed with null sample

Modified:
    
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/ResponseAssertion.java
    jakarta/jmeter/trunk/test/src/org/apache/jmeter/assertions/PackageTest.java
    jakarta/jmeter/trunk/xdocs/changes.xml

Modified: 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/ResponseAssertion.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/ResponseAssertion.java?rev=701680&r1=701679&r2=701680&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/ResponseAssertion.java
 (original)
+++ 
jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/ResponseAssertion.java
 Sat Oct  4 11:06:35 2008
@@ -19,6 +19,7 @@
 package org.apache.jmeter.assertions;
 
 import java.io.Serializable;
+import java.net.URL;
 import java.util.ArrayList;
 
 import org.apache.jmeter.samplers.SampleResult;
@@ -276,9 +277,9 @@
      *            an instance of SampleResult
      * @return an instance of AssertionResult
      */
-    AssertionResult evaluateResponse(SampleResult response) {
+    private AssertionResult evaluateResponse(SampleResult response) {
         boolean pass = true;
-        boolean not = (NOT & getTestType()) > 0;
+        boolean notTest = (NOT & getTestType()) > 0;
         AssertionResult result = new AssertionResult(getName());
         String toCheck = ""; // The string to check (Url or data)
 
@@ -296,26 +297,30 @@
         } else if (isTestFieldResponseHeaders()) {
             toCheck = response.getResponseHeaders();
         } else { // Assume it is the URL
-            toCheck = response.getSamplerData(); // TODO - is this where the 
URL is stored?
-            if (toCheck == null) {
-                toCheck = "";
+            toCheck = "";                
+            final URL url = response.getURL();
+            if (url != null){
+                toCheck = url.toString();                
             }
         }
 
+        result.setFailure(false);
+        result.setError(false);
+
         if (toCheck.length() == 0) {
+            if (notTest) {
+                return result;
+            }
             return result.setResultForNull();
         }
 
-        result.setFailure(false);
-        result.setError(false);
-
         boolean contains = isContainsType(); // do it once outside loop
         boolean equals = isEqualsType();
         boolean substring = isSubstringType();
         boolean matches = isMatchType();
         boolean debugEnabled = log.isDebugEnabled();
         if (debugEnabled){
-            log.debug("Type:" + (contains?"Contains":"Match") + (not? "(not)": 
""));
+            log.debug("Type:" + (contains?"Contains":"Match") + (notTest? 
"(not)": ""));
         }
         
         try {
@@ -338,7 +343,7 @@
                 } else {
                     found = localMatcher.matches(toCheck, pattern);
                 }
-                pass = not ? !found : found;
+                pass = notTest ? !found : found;
                 if (!pass) {
                     if (debugEnabled){log.debug("Failed: "+stringPattern);}
                     result.setFailure(true);

Modified: 
jakarta/jmeter/trunk/test/src/org/apache/jmeter/assertions/PackageTest.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/assertions/PackageTest.java?rev=701680&r1=701679&r2=701680&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/assertions/PackageTest.java 
(original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/assertions/PackageTest.java 
Sat Oct  4 11:06:35 2008
@@ -18,6 +18,9 @@
 
 package org.apache.jmeter.assertions;
 
+import java.net.MalformedURLException;
+import java.net.URL;
+
 import junit.framework.TestCase;
 
 import org.apache.jmeter.junit.JMeterTestCase;
@@ -41,9 +44,9 @@
                assertEquals("D41D8CD98F00B204E9800998ECF8427E", 
MD5HexAssertion.baMD5Hex(new byte[] {}).toUpperCase(java.util.Locale.ENGLISH));
        }
 
-       int threadsRunning;
+       volatile int threadsRunning;
 
-       int failed;
+       volatile int failed;
 
        public void testThreadSafety() throws Exception {
                Thread[] threads = new Thread[100];
@@ -259,7 +262,7 @@
                private JMeterVariables vars;
                private AssertionResult result;
                
-               public void setUp() {
+               public void setUp() throws MalformedURLException {
                        jmctx = JMeterContextService.getContext();
                        assertion = new ResponseAssertion();
                        assertion.setThreadContext(jmctx);
@@ -272,7 +275,7 @@
                                        "response Data\n" +
                                        "line 2\n\nEOF"
                                        ).getBytes());
-                       sample.setSamplerData("Sampler Label");// This is where 
RA checks the URL!
+                       sample.setURL(new 
URL("http://localhost/Sampler/Data/";));
                        sample.setResponseCode("401");
                        sample.setResponseHeaders("X-Header: abcd");
                }

Modified: jakarta/jmeter/trunk/xdocs/changes.xml
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/changes.xml?rev=701680&r1=701679&r2=701680&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/changes.xml (original)
+++ jakarta/jmeter/trunk/xdocs/changes.xml Sat Oct  4 11:06:35 2008
@@ -110,6 +110,7 @@
 <li>Bug 45831 - WS Sampler reports incorrect throughput if SOAP packet 
creation fails</li>
 <li>Bug 45887 - TCPSampler: timeout property incorrectly set</li>
 <li>Bug 45928 - AJP/1.3 Sampler doesn't retrieve his label from 
messages.properties</li>
+<li>Bug 45904 - Allow 'Not' Response Assertion to succeed with null sample</li>
 </ul>
 
 <h3>Improvements</h3>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to