You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by pm...@apache.org on 2012/01/08 23:08:02 UTC

svn commit: r1228972 - in /jmeter/trunk: bin/jmeter.properties src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java xdocs/changes.xml

Author: pmouawad
Date: Sun Jan  8 22:08:01 2012
New Revision: 1228972

URL: http://svn.apache.org/viewvc?rev=1228972&view=rev
Log:
Bug 44301 - Enable "ignore failed" for embedded resources

Modified:
    jmeter/trunk/bin/jmeter.properties
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
    jmeter/trunk/xdocs/changes.xml

Modified: jmeter/trunk/bin/jmeter.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/bin/jmeter.properties?rev=1228972&r1=1228971&r2=1228972&view=diff
==============================================================================
--- jmeter/trunk/bin/jmeter.properties (original)
+++ jmeter/trunk/bin/jmeter.properties Sun Jan  8 22:08:01 2012
@@ -739,6 +739,9 @@ beanshell.server.file=../extras/startup.
 # Revert to BUG 51939 behaviour (no separate container for embedded resources) by setting the following false:
 #httpsampler.separate.container=true
 
+# If embedded resources download fails due to missing resources or other reasons, if this property is true
+# Parent sample will not be marked as failed 
+#httpsampler.ignore_failed_embedded_resources=false
 
 # The encoding to be used if none is provided (default ISO-8859-1)
 #sampleresult.default.encoding=ISO-8859-1

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java?rev=1228972&r1=1228971&r2=1228972&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java (original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java Sun Jan  8 22:08:01 2012
@@ -166,6 +166,9 @@ public abstract class HTTPSamplerBase ex
     private static final long AWAIT_TERMINATION_TIMEOUT = 
         JMeterUtils.getPropDefault("httpsampler.await_termination_timeout", 60); // $NON-NLS-1$ // default value: 60 secs 
     
+    private static final boolean IGNORE_FAILED_EMBEDDED_RESOURCES = 
+            JMeterUtils.getPropDefault("httpsampler.ignore_failed_embedded_resources", false); // $NON-NLS-1$ // default value: false
+
     public static final int CONCURRENT_POOL_SIZE = 4; // Default concurrent pool size for download embedded resources
     
     
@@ -1109,7 +1112,7 @@ public abstract class HTTPSamplerBase ex
         } catch (HTMLParseException e) {
             // Don't break the world just because this failed:
             res.addSubResult(errorResult(e, new HTTPSampleResult(res)));
-            res.setSuccessful(false);
+            setParentSampleSuccess(res, false);
         }
 
         // Iterate through the URLs and download each image:
@@ -1153,7 +1156,7 @@ public abstract class HTTPSamplerBase ex
                                 url = new URL(urlStrEnc);
                             } catch (MalformedURLException e) {
                                 res.addSubResult(errorResult(new Exception(urlStrEnc + " is not a correct URI"), new HTTPSampleResult(res)));
-                                res.setSuccessful(false);
+                                setParentSampleSuccess(res, false);
                                 continue;
                             }
                         }
@@ -1169,13 +1172,13 @@ public abstract class HTTPSamplerBase ex
                             // default: serial download embedded resources
                             HTTPSampleResult binRes = sample(url, GET, false, frameDepth + 1);
                             res.addSubResult(binRes);
-                            res.setSuccessful(res.isSuccessful() && binRes.isSuccessful());
+                            setParentSampleSuccess(res, res.isSuccessful() && binRes.isSuccessful());
                         }
 
                     }
                 } catch (ClassCastException e) { // TODO can this happen?
                     res.addSubResult(errorResult(new Exception(binURL + " is not a correct URI"), new HTTPSampleResult(res)));
-                    res.setSuccessful(false);
+                    setParentSampleSuccess(res, false);
                     continue;
                 }
             }
@@ -1231,7 +1234,7 @@ public abstract class HTTPSamplerBase ex
                                 }
                             }
                             res.addSubResult(binRes.getResult());
-                            res.setSuccessful(res.isSuccessful() && binRes.getResult().isSuccessful());
+                            setParentSampleSuccess(res, res.isSuccessful() && binRes.getResult().isSuccessful());
                         } catch (TimeoutException e) {
                             errorResult(e, res);
                         }
@@ -1251,7 +1254,18 @@ public abstract class HTTPSamplerBase ex
         return res;
     }
     
-    /*
+    /**
+     * Set parent successful attribute based on IGNORE_FAILED_EMBEDDED_RESOURCES parameter
+     * @param res {@link HTTPSampleResult}
+     * @param initialValue boolean
+     */
+    private void setParentSampleSuccess(HTTPSampleResult res, boolean initialValue) {
+		if(!IGNORE_FAILED_EMBEDDED_RESOURCES) {
+			res.setSuccessful(initialValue);
+		}
+	}
+
+	/*
      * @param res HTTPSampleResult to check
      * @return parser class name (may be "") or null if entry does not exist
      */

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1228972&r1=1228971&r2=1228972&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Sun Jan  8 22:08:01 2012
@@ -175,6 +175,7 @@ fix code which assumes that a new instan
 <li>Bug 51981 - Better support for file: protocol in HTTP sampler</li>
 <li>Bug 52033 - Allowing multiple certificates (JKS)</li>
 <li>Bug 52352 - Proxy : Support IPv6 URLs capture</li>
+<li>Bug 44301 - Enable "ignore failed" for embedded resources</li>
 </ul>
 
 <h3>Other samplers</h3>