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/12/07 15:51:50 UTC

svn commit: r1418340 - in /jmeter/trunk: src/protocol/http/org/apache/jmeter/protocol/http/proxy/ xdocs/

Author: pmouawad
Date: Fri Dec  7 14:51:45 2012
New Revision: 1418340

URL: http://svn.apache.org/viewvc?rev=1418340&view=rev
Log:
Bug 54257 - Enhance SamplerCreator interface to meet new requirements
Bugzilla Id: 54257

Modified:
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/AbstractSamplerCreator.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Proxy.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/SamplerCreator.java
    jmeter/trunk/xdocs/changes.xml

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/AbstractSamplerCreator.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/AbstractSamplerCreator.java?rev=1418340&r1=1418339&r2=1418340&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/AbstractSamplerCreator.java (original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/AbstractSamplerCreator.java Fri Dec  7 14:51:45 2012
@@ -19,9 +19,12 @@
 package org.apache.jmeter.protocol.http.proxy;
 
 import java.util.HashSet;
+import java.util.Map;
 import java.util.Set;
 import java.util.StringTokenizer;
 
+import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
+import org.apache.jmeter.samplers.SampleResult;
 import org.apache.jmeter.util.JMeterUtils;
 
 /**
@@ -120,4 +123,23 @@ public abstract class AbstractSamplerCre
     protected String getBinaryDirectory() {
         return binaryDirectory;
     }
+
+    /**
+     * @see org.apache.jmeter.protocol.http.proxy.SamplerCreator#postProcessSampler(org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase, org.apache.jmeter.samplers.SampleResult)
+     */
+    @Override
+    public void postProcessSampler(HTTPSamplerBase sampler, SampleResult result) {
+        // NOOP
+    }
+
+    /**
+     * @see org.apache.jmeter.protocol.http.proxy.SamplerCreator#createAndPopulateSampler(org.apache.jmeter.protocol.http.proxy.HttpRequestHdr, java.util.Map, java.util.Map)
+     */
+    @Override
+    public HTTPSamplerBase createAndPopulateSampler(HttpRequestHdr request,
+            Map<String, String> pageEncodings, Map<String, String> formEncodings) throws Exception {
+        HTTPSamplerBase sampler = createSampler(request, pageEncodings, formEncodings);
+        populateSampler(sampler, request, pageEncodings, formEncodings);
+        return sampler;
+    }
 }
\ No newline at end of file

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Proxy.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Proxy.java?rev=1418340&r1=1418339&r2=1418340&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Proxy.java (original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Proxy.java Fri Dec  7 14:51:45 2012
@@ -198,8 +198,7 @@ public class Proxy extends Thread {
             }
 
             SamplerCreator samplerCreator = factory.getSamplerCreator(request, pageEncodings, formEncodings);
-            sampler = samplerCreator.createSampler(request, pageEncodings, formEncodings);
-            samplerCreator.populateSampler(sampler, request, pageEncodings, formEncodings);
+            sampler = samplerCreator.createAndPopulateSampler(request, pageEncodings, formEncodings);
 
             /*
              * Create a Header Manager to ensure that the browsers headers are
@@ -217,6 +216,7 @@ public class Proxy extends Thread {
             addFormEncodings(result, pageEncoding);
 
             writeToClient(result, new BufferedOutputStream(clientSocket.getOutputStream()));
+            samplerCreator.postProcessSampler(sampler, result);
         } catch (UnknownHostException uhe) {
             log.warn("Server Not Found.", uhe);
             writeErrorToClient(HttpReplyHdr.formServerNotFound());

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/SamplerCreator.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/SamplerCreator.java?rev=1418340&r1=1418339&r2=1418340&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/SamplerCreator.java (original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/SamplerCreator.java Fri Dec  7 14:51:45 2012
@@ -21,6 +21,7 @@ package org.apache.jmeter.protocol.http.
 import java.util.Map;
 
 import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
+import org.apache.jmeter.samplers.SampleResult;
 
 /**
  * Factory of sampler
@@ -54,4 +55,29 @@ public interface SamplerCreator {
             HttpRequestHdr request, Map<String, String> pageEncodings,
             Map<String, String> formEncodings)
                     throws Exception;
+
+    /**
+     * Post process sampler 
+     * Called after sampling 
+     * @param sampler HTTPSamplerBase
+     * @param result SampleResult
+     * @since 2.9
+     */
+    void postProcessSampler(HTTPSamplerBase sampler, SampleResult result);
+
+    /**
+     * Default implementation calls:
+     * <ol>
+     *  <li>{@link SamplerCreator}{@link #createSampler(HttpRequestHdr, Map, Map)}</li>
+     *  <li>{@link SamplerCreator}{@link #populateSampler(HTTPSamplerBase, HttpRequestHdr, Map, Map)}</li>
+     * </ol>
+     * @param request {@link HttpRequestHdr}
+     * @param pageEncodings Map<String, String>
+     * @param formEncodings Map<String, String>
+     * @return {@link HTTPSamplerBase}
+     * @since 2.9
+     */
+    HTTPSamplerBase createAndPopulateSampler(HttpRequestHdr request,
+            Map<String, String> pageEncodings, Map<String, String> formEncodings)
+                    throws Exception;
 }

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1418340&r1=1418339&r2=1418340&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Fri Dec  7 14:51:45 2012
@@ -214,6 +214,7 @@ to the elements View Results Tree, Asser
 <li><bugzilla>54232</bugzilla> - Search Feature : Add a button to search and expand results</li>
 <li><bugzilla>54155</bugzilla> - ModuleController : Add a shortcut button to unfold the tree up to referenced controller and highlight it</li>
 <li><bugzilla>54251</bugzilla> - Add tristate checkbox implementation</li>
+<li><bugzilla>54257</bugzilla> - Enhance SamplerCreator interface to meet new requirements</li>
 </ul>
 
 <h2>Non-functional changes</h2>