jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1748004 - in /jmeter/trunk: src/protocol/http/org/apache/jmeter/protocol/http/proxy/ProxyControl.java xdocs/changes.xml
Date Sun, 12 Jun 2016 13:44:17 GMT
Author: pmouawad
Date: Sun Jun 12 13:44:17 2016
New Revision: 1748004

URL: http://svn.apache.org/viewvc?rev=1748004&view=rev
Log:
Bug 58888 - HTTP(S) Test Script Recorder (ProxyControl) does not add TestElement's returned
by SamplerCreator createChildren () 
Bugzilla Id: 58888

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

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/ProxyControl.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/ProxyControl.java?rev=1748004&r1=1748003&r2=1748004&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/ProxyControl.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/ProxyControl.java
Sun Jun 12 13:44:17 2016
@@ -47,6 +47,7 @@ import org.apache.commons.lang3.RandomSt
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.time.DateUtils;
 import org.apache.http.conn.ssl.AbstractVerifier;
+import org.apache.jmeter.assertions.Assertion;
 import org.apache.jmeter.assertions.ResponseAssertion;
 import org.apache.jmeter.assertions.gui.AssertionGui;
 import org.apache.jmeter.config.Arguments;
@@ -62,6 +63,8 @@ import org.apache.jmeter.functions.Inval
 import org.apache.jmeter.gui.GuiPackage;
 import org.apache.jmeter.gui.tree.JMeterTreeModel;
 import org.apache.jmeter.gui.tree.JMeterTreeNode;
+import org.apache.jmeter.processor.PostProcessor;
+import org.apache.jmeter.processor.PreProcessor;
 import org.apache.jmeter.protocol.http.control.AuthManager;
 import org.apache.jmeter.protocol.http.control.Authorization;
 import org.apache.jmeter.protocol.http.control.Header;
@@ -90,6 +93,7 @@ import org.apache.jmeter.testelement.pro
 import org.apache.jmeter.threads.AbstractThreadGroup;
 import org.apache.jmeter.timers.Timer;
 import org.apache.jmeter.util.JMeterUtils;
+import org.apache.jmeter.visualizers.Visualizer;
 import org.apache.jorphan.exec.KeyToolUtils;
 import org.apache.jorphan.logging.LoggingManager;
 import org.apache.jorphan.util.JOrphanUtils;
@@ -539,12 +543,12 @@ public class ProxyControl extends Generi
      * Always sends the result to any registered sample listeners.
      *
      * @param sampler the sampler, may be null
-     * @param subConfigs the configuration elements to be added (e.g. header namager)
+     * @param testElements the test elements to be added (e.g. header namager) under the
Sampler
      * @param result the sample result, not null
      * TODO param serverResponse to be added to allow saving of the
      * server's response while recording.
      */
-    public synchronized void deliverSampler(final HTTPSamplerBase sampler, final TestElement[]
subConfigs, final SampleResult result) {
+    public synchronized void deliverSampler(final HTTPSamplerBase sampler, final TestElement[]
testElements, final SampleResult result) {
         boolean notifySampleListeners = true;
         if (sampler != null) {
             if (ATTEMPT_REDIRECT_DISABLING && (samplerRedirectAutomatically || samplerFollowRedirects))
{
@@ -575,7 +579,7 @@ public class ProxyControl extends Generi
                 Collection<Arguments> userDefinedVariables = (Collection<Arguments>)
findApplicableElements(myTarget, Arguments.class, true);
 
                 removeValuesFromSampler(sampler, defaultConfigurations);
-                replaceValues(sampler, subConfigs, userDefinedVariables);
+                replaceValues(sampler, testElements, userDefinedVariables);
                 sampler.setAutoRedirects(samplerRedirectAutomatically);
                 sampler.setFollowRedirects(samplerFollowRedirects);
                 sampler.setUseKeepAlive(useKeepAlive);
@@ -585,11 +589,11 @@ public class ProxyControl extends Generi
                     sampler.setName(prefix + sampler.getName());
                     result.setSampleLabel(prefix + result.getSampleLabel());
                 }
-                Authorization authorization = createAuthorization(subConfigs, sampler);
+                Authorization authorization = createAuthorization(testElements, sampler);
                 if (authorization != null) {
                     setAuthorization(authorization, myTarget);
                 }
-                placeSampler(sampler, subConfigs, myTarget);
+                placeSampler(sampler, testElements, myTarget);
             } else {
                 if(log.isDebugEnabled()) {
                     log.debug("Sample excluded based on url or content-type: " + result.getUrlAsString()
+ " - " + result.getContentType());
@@ -616,11 +620,11 @@ public class ProxyControl extends Generi
      * @param sampler {@link HTTPSamplerBase}
      * @return {@link Authorization}
      */
-    private Authorization createAuthorization(final TestElement[] subConfigs, HTTPSamplerBase
sampler) {
+    private Authorization createAuthorization(final TestElement[] testElements, HTTPSamplerBase
sampler) {
         Header authHeader = null;
         Authorization authorization = null;
         // Iterate over subconfig elements searching for HeaderManager
-        for (TestElement te : subConfigs) {
+        for (TestElement te : testElements) {
             if (te instanceof HeaderManager) {
                 @SuppressWarnings("unchecked") // headers should only contain the correct
classes
                 List<TestElementProperty> headers = (ArrayList<TestElementProperty>)
((HeaderManager) te).getHeaders().getObjectValue();
@@ -1093,7 +1097,7 @@ public class ProxyControl extends Generi
         return elements;
     }
 
-    private void placeSampler(final HTTPSamplerBase sampler, final TestElement[] subConfigs,
+    private void placeSampler(final HTTPSamplerBase sampler, final TestElement[] testElements,
             JMeterTreeNode myTarget) {
         try {
             final JMeterTreeModel treeModel = GuiPackage.getInstance().getTreeModel();
@@ -1157,17 +1161,16 @@ public class ProxyControl extends Generi
                             addTimers(treeModel, newNode, deltaTFinal);
                         }
 
-                        for (int i = 0; subConfigs != null && i < subConfigs.length;
i++) {
-                            if (subConfigs[i] instanceof HeaderManager) {
-                                final TestElement headerManager = subConfigs[i];
-                                headerManager.setProperty(TestElement.GUI_CLASS, HEADER_PANEL);
-                                treeModel.addComponent(headerManager, newNode);
+                        for (int i = 0; testElements != null && i < testElements.length;
i++) {
+                            if(canTestElementBeAddedUnderSampler(testElements[i])) {
+                                treeModel.addComponent(testElements[i], newNode);
                             }
                         }
                     } catch (IllegalUserActionException e) {
                         JMeterUtils.reportErrorToUser(e.getMessage());
                     }
                 }
+
             });
         } catch (Exception e) {
             JMeterUtils.reportErrorToUser(e.getMessage());
@@ -1175,6 +1178,33 @@ public class ProxyControl extends Generi
     }
 
     /**
+     * @param testElement {@link TestElement} to add
+     * @return true if testElement can be added to Sampler
+     */
+    private boolean canTestElementBeAddedUnderSampler(
+            TestElement testElement) {
+        boolean isElementAddable = 
+                testElement instanceof Visualizer
+                || testElement instanceof ConfigElement
+                || testElement instanceof Assertion
+                || testElement instanceof Timer
+                || testElement instanceof PreProcessor
+                || testElement instanceof PostProcessor;
+        if(isElementAddable) {
+            if(testElement.getProperty(TestElement.GUI_CLASS) != null) {
+                return true;
+            } else {
+                log.error("Cannot add element with no " + TestElement.GUI_CLASS + " property
"
+                        + "for testElement:"+testElement);
+                return false;
+            }
+        } else {
+            return false;
+        }
+    }
+
+    
+    /**
      * Remove from the sampler all values which match the one provided by the
      * first configuration in the given collection which provides a value for
      * that property.

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1748004&r1=1748003&r2=1748004&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Sun Jun 12 13:44:17 2016
@@ -123,6 +123,7 @@ Summary
 
 <h3>HTTP Samplers and Test Script Recorder</h3>
 <ul>
+    <li><bug>58888</bug>HTTP(S) Test Script Recorder (ProxyControl) does
not add TestElement's returned by SamplerCreator createChildren ()</li>
  </ul>
 
 <h3>Other Samplers</h3>



Mime
View raw message