jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject [jmeter] branch master updated: Freestyle format for names in (Default)SamplerCreator
Date Mon, 31 Aug 2020 16:33:33 GMT
This is an automated email from the ASF dual-hosted git repository.

fschumacher pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git


The following commit(s) were added to refs/heads/master by this push:
     new af8c105  Freestyle format for names in (Default)SamplerCreator
af8c105 is described below

commit af8c10529cd086f013e2a2081aae2ca85888c739
Author: Felix Schumacher <felix.schumacher@internetallee.de>
AuthorDate: Mon Aug 31 18:31:42 2020 +0200

    Freestyle format for names in (Default)SamplerCreator
    
    Use a default value for the format string, that can be controlled by
    a JMeter property.
    
    Bugzilla Id: 64696
    Relates to #595
---
 bin/jmeter.properties                              |  3 +++
 .../jmeter/protocol/http/proxy/ProxyControl.java   | 23 +++++++++++++---------
 .../protocol/http/proxy/gui/ProxyControlGui.java   |  2 ++
 xdocs/usermanual/properties_reference.xml          |  5 +++++
 4 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/bin/jmeter.properties b/bin/jmeter.properties
index c3e78c3..84f01e8 100644
--- a/bin/jmeter.properties
+++ b/bin/jmeter.properties
@@ -615,6 +615,9 @@ upgrade_properties=/bin/upgrade.properties
 # Add numeric suffix to Sampler names (default true)
 #proxy.number.requests=true
 
+# Default format string for new samplers when 'Use format string' is selected as 'naming
scheme'
+#proxy.sampler_format=#{counter,number,000} - #{path} (#{name})
+
 # List of URL patterns that will be added to URL Patterns to exclude
 # Separate multiple lines with ;
 #proxy.excludes.suggested=.*\\.(bmp|css|js|gif|ico|jpe?g|png|swf|woff|woff2)
diff --git a/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/proxy/ProxyControl.java
b/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/proxy/ProxyControl.java
index f634b16..7bdc0be 100644
--- a/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/proxy/ProxyControl.java
+++ b/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/proxy/ProxyControl.java
@@ -138,6 +138,7 @@ public class ProxyControl extends GenericController implements NonTestElement
{
     private static final String USE_KEEPALIVE = "ProxyControlGui.use_keepalive"; // $NON-NLS-1$
     private static final String SAMPLER_DOWNLOAD_IMAGES = "ProxyControlGui.sampler_download_images";
// $NON-NLS-1$
     private static final String HTTP_SAMPLER_NAMING_MODE = "ProxyControlGui.proxy_http_sampler_naming_mode";
// $NON-NLS-1$
+    private static final String HTTP_SAMPLER_FORMAT = "ProxyControlGui.proxy_http_sampler_format";
// $NON-NLS-1$
     private static final String PREFIX_HTTP_SAMPLER_NAME = "ProxyControlGui.proxy_prefix_http_sampler_name";
// $NON-NLS-1$
     private static final String PROXY_PAUSE_HTTP_SAMPLER = "ProxyControlGui.proxy_pause_http_sampler";
// $NON-NLS-1$
     private static final String DEFAULT_ENCODING_PROPERTY = "ProxyControlGui.default_encoding";
// $NON-NLS-1$
@@ -288,8 +289,6 @@ public class ProxyControl extends GenericController implements NonTestElement
{
 
     private transient javax.swing.Timer sampleWorkerTimer;
 
-    private String httpSampleNameFormat;
-
     public ProxyControl() {
         setPort(DEFAULT_PORT);
         setExcludeList(new HashSet<>());
@@ -490,6 +489,19 @@ public class ProxyControl extends GenericController implements NonTestElement
{
         return getPropertyAsString(CONTENT_TYPE_INCLUDE);
     }
 
+    public void setHttpSampleNameFormat(String text) {
+        if (StringUtils.isBlank(text)) {
+            removeProperty(HTTP_SAMPLER_FORMAT);
+        } else {
+            setProperty(new StringProperty(HTTP_SAMPLER_FORMAT, text));
+        }
+    }
+
+    public String getHttpSampleNameFormat() {
+        return getPropertyAsString(HTTP_SAMPLER_FORMAT,
+                JMeterUtils.getPropDefault("proxy.sampler_format", "#{counter,number,000}
- #{path} (#{name})"));
+    }
+
     /**
      * @return the {@link JMeterTreeModel} used when run in non-GUI mode, or {@code null}
when run in GUI mode
      */
@@ -1670,11 +1682,4 @@ public class ProxyControl extends GenericController implements NonTestElement
{
         }
     }
 
-    public void setHttpSampleNameFormat(String text) {
-        this.httpSampleNameFormat = text;
-    }
-
-    public String getHttpSampleNameFormat() {
-        return httpSampleNameFormat;
-    }
 }
diff --git a/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/proxy/gui/ProxyControlGui.java
b/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/proxy/gui/ProxyControlGui.java
index 58946c3..dc0cd53 100644
--- a/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/proxy/gui/ProxyControlGui.java
+++ b/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/proxy/gui/ProxyControlGui.java
@@ -332,6 +332,7 @@ public class ProxyControlGui extends LogicControllerGui implements JMeterGUIComp
             model.setRegexMatch(regexMatch.isSelected());
             model.setContentTypeInclude(contentTypeInclude.getText());
             model.setContentTypeExclude(contentTypeExclude.getText());
+            model.setHttpSampleNameFormat(httpSampleNameFormat.getText());
             TreeNodeWrapper nw = (TreeNodeWrapper) targetNodes.getSelectedItem();
             if (nw == null) {
                 model.setTarget(null);
@@ -396,6 +397,7 @@ public class ProxyControlGui extends LogicControllerGui implements JMeterGUIComp
         regexMatch.setSelected(model.getRegexMatch());
         contentTypeInclude.setText(model.getContentTypeInclude());
         contentTypeExclude.setText(model.getContentTypeExclude());
+        httpSampleNameFormat.setText(model.getHttpSampleNameFormat());
 
         reinitializeTargetCombo();// Set up list of potential targets and
                                     // enable listener
diff --git a/xdocs/usermanual/properties_reference.xml b/xdocs/usermanual/properties_reference.xml
index 18cdbad..25974c2 100644
--- a/xdocs/usermanual/properties_reference.xml
+++ b/xdocs/usermanual/properties_reference.xml
@@ -777,6 +777,11 @@ JMETER-SERVER</source>
     Add numeric suffix to Sampler names.<br/>
     defaults to: <code>true</code>
 </property>
+<property name="proxy.sampler_format">
+    Default format string for new samplers when <code>Use format string</code>
is selected
+    as <code>naming scheme</code>.<br/>
+    Defaults to: <code>#{counter,number,000} - #{path} (#{name})</code>
+</property>
 <property name="proxy.excludes.suggested">
     List of URL patterns that will be added to URL Patterns to exclude.<br/>
     Separate multiple lines with <code>;</code><br/>


Mime
View raw message