jmeter-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [jmeter] pmouawad commented on a change in pull request #571: Add prefix or suffix sampler numbering for HTTP Test Script Recorder
Date Mon, 27 Apr 2020 12:05:07 GMT

pmouawad commented on a change in pull request #571:
URL: https://github.com/apache/jmeter/pull/571#discussion_r415749145



##########
File path: src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/proxy/AbstractSamplerCreator.java
##########
@@ -86,30 +96,49 @@ public AbstractSamplerCreator() {
     /**
      * @return int request number
      */
-    protected static int getRequestNumber() {
+    public int getRequestNumber() {
         return REQUEST_NUMBER.get();
     }
 
+    /**
+     * set the RequestNumber to a specify value
+     * @param iValue
+     */
+    public void setRequestNumber(int iValue) {
+        REQUEST_NUMBER.set(iValue);
+    }
+
     /**
      * Increment request number
      */
-    protected static void incrementRequestNumber() {
+    protected void incrementRequestNumber() {
         incrementRequestNumberAndGet();
     }
 
     /**
      * Increment request number
      * @return int number for created sampler
      */
-    protected static int incrementRequestNumberAndGet() {
+    protected int incrementRequestNumberAndGet() {
         return REQUEST_NUMBER.incrementAndGet();
     }
 
     /**
      * @return boolean is numbering requests is required
      */
-    protected static boolean isNumberRequests() {
-        return NUMBER_REQUESTS;
+    protected boolean isNumberRequests() {
+        boolean bNumberRequest = JMeterUtils.getPropDefault("proxy.number.requests", true);
// $NON-NLS-1$;
+        return bNumberRequest;
+    }
+
+    protected String getNumberValueFormat() {
+        String sNumberValueFormat = JMeterUtils.getPropDefault("proxy.number.value_format",
"%03d");
+       return sNumberValueFormat;
+    }
+
+    protected String getNumberMode() {
+        String sMumberMode = JMeterUtils.getPropDefault("proxy.number.mode", "prefix");

Review comment:
       same note

##########
File path: src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/proxy/AbstractSamplerCreator.java
##########
@@ -55,9 +55,19 @@
     /*
      * Optionally number the requests
      */
-    private static final boolean NUMBER_REQUESTS =
+    private final boolean NUMBER_REQUESTS =

Review comment:
       if those fields are not static, then they should be camel case

##########
File path: src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/proxy/AbstractSamplerCreator.java
##########
@@ -86,30 +96,49 @@ public AbstractSamplerCreator() {
     /**
      * @return int request number
      */
-    protected static int getRequestNumber() {
+    public int getRequestNumber() {
         return REQUEST_NUMBER.get();
     }
 
+    /**
+     * set the RequestNumber to a specify value
+     * @param iValue
+     */
+    public void setRequestNumber(int iValue) {
+        REQUEST_NUMBER.set(iValue);
+    }
+
     /**
      * Increment request number
      */
-    protected static void incrementRequestNumber() {
+    protected void incrementRequestNumber() {
         incrementRequestNumberAndGet();
     }
 
     /**
      * Increment request number
      * @return int number for created sampler
      */
-    protected static int incrementRequestNumberAndGet() {
+    protected int incrementRequestNumberAndGet() {
         return REQUEST_NUMBER.incrementAndGet();
     }
 
     /**
      * @return boolean is numbering requests is required
      */
-    protected static boolean isNumberRequests() {
-        return NUMBER_REQUESTS;
+    protected boolean isNumberRequests() {
+        boolean bNumberRequest = JMeterUtils.getPropDefault("proxy.number.requests", true);
// $NON-NLS-1$;

Review comment:
       Why it's not a simple getter ? just return NUMBER_REQUEST (to be camelCased)

##########
File path: src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/proxy/AbstractSamplerCreator.java
##########
@@ -86,30 +96,49 @@ public AbstractSamplerCreator() {
     /**
      * @return int request number
      */
-    protected static int getRequestNumber() {
+    public int getRequestNumber() {
         return REQUEST_NUMBER.get();
     }
 
+    /**
+     * set the RequestNumber to a specify value
+     * @param iValue
+     */
+    public void setRequestNumber(int iValue) {
+        REQUEST_NUMBER.set(iValue);
+    }
+
     /**
      * Increment request number
      */
-    protected static void incrementRequestNumber() {
+    protected void incrementRequestNumber() {
         incrementRequestNumberAndGet();
     }
 
     /**
      * Increment request number
      * @return int number for created sampler
      */
-    protected static int incrementRequestNumberAndGet() {
+    protected int incrementRequestNumberAndGet() {
         return REQUEST_NUMBER.incrementAndGet();
     }
 
     /**
      * @return boolean is numbering requests is required
      */
-    protected static boolean isNumberRequests() {
-        return NUMBER_REQUESTS;
+    protected boolean isNumberRequests() {
+        boolean bNumberRequest = JMeterUtils.getPropDefault("proxy.number.requests", true);
// $NON-NLS-1$;
+        return bNumberRequest;
+    }
+
+    protected String getNumberValueFormat() {
+        String sNumberValueFormat = JMeterUtils.getPropDefault("proxy.number.value_format",
"%03d");

Review comment:
       same note

##########
File path: src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/proxy/ProxyControl.java
##########
@@ -276,13 +310,36 @@
 
     private String keyPassword;
 
+    private int iNumberingStartValue;
+    private String sNumberingMode;
+    private String sNumberingFormat;
+
     private JMeterTreeModel nonGuiTreeModel;
 
     public ProxyControl() {
         setPort(DEFAULT_PORT);
         setExcludeList(new HashSet<>());
         setIncludeList(new HashSet<>());
         setCaptureHttpHeaders(true); // maintain original behaviour
+        
+        iNumberingStartValue = HTTP_SAMPLER_NUMBERING_START_VALUE_DEFAULT;
+        sNumberingFormat = JMeterUtils.getPropDefault("proxy.number.value_format", HTTP_SAMPLER_NUMBERING_INTEGER_FORMAT_DEFAULT);
+        setHttpSamplerNumberingIntegerFormat(sNumberingFormat);
+
+        sNumberingMode = JMeterUtils.getPropDefault("proxy.number.mode", HTTP_SAMPLER_NUMBERING_MODE_DEFAULT);
+
+        if (HttpSamplerNumberingMode.PREFIX.getStringMode().equals(sNumberingMode)) {
+            setHttpSampleNumberingMode(HttpSamplerNumberingMode.PREFIX.getIntValue());
+        }
+        if (HttpSamplerNumberingMode.SUFFIX.getStringMode().equals(sNumberingMode)) {

Review comment:
       else if 

##########
File path: src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/proxy/DefaultSamplerCreator.java
##########
@@ -61,6 +62,8 @@
     private static final int SAMPLER_NAME_NAMING_MODE_PREFIX = 0;  // $NON-NLS-1$
     private static final int SAMPLER_NAME_NAMING_MODE_COMPLETE = 1;  // $NON-NLS-1$
 
+    private static final String  SAMPLER_NUMBERING_MODE_NAME_PREFIX = "prefix";  // $NON-NLS-1$

Review comment:
       Why you didn't use the enum HttpSamplerNumberingMode ?

##########
File path: src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/proxy/gui/ProxyControlGui.java
##########
@@ -412,10 +445,25 @@ private void populateTable(PowerTableModel pModel, PropertyIterator
iter) {
     public void itemStateChanged(ItemEvent e) {
         if (e.getSource() instanceof JComboBox) {
             JComboBox combo = (JComboBox) e.getSource();
-            if(HTTP_SAMPLER_NAMING_MODE.equals(combo.getName())){
+            if(HTTP_SAMPLER_NAMING_MODE.equals(combo.getName())) {
                 model.setHTTPSampleNamingMode(httpSampleNamingMode.getSelectedIndex());
+            }
+
+            if(HTTP_SAMPLER_NUMBERING_MODE.equals(combo.getName())) {
+                model.setHttpSampleNumberingMode(httpSampleNumberingMode.getSelectedIndex());
+                if (httpSampleNumberingMode.getSelectedIndex() == 0) {
+                	JMeterUtils.setProperty("proxy.number.mode", "prefix");

Review comment:
       Why this and not using setter/getters ?

##########
File path: src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/proxy/ProxyControl.java
##########
@@ -355,6 +412,47 @@ public void setHTTPSampleNamingMode(int httpNamingMode) {
         setProperty(new IntegerProperty(HTTP_SAMPLER_NAMING_MODE, httpNamingMode));
     }
 
+    public void setHttpSampleNumberingMode(int httpSampleNumberingMode) {
+        
+        if (httpSampleNumberingMode == HttpSamplerNumberingMode.PREFIX.getIntValue()) {
+        	sNumberingMode = HttpSamplerNumberingMode.PREFIX.getStringMode(); 
+        }
+        
+        if (httpSampleNumberingMode ==  HttpSamplerNumberingMode.SUFFIX.getIntValue()) {
+            // choose suffix numbering
+        	sNumberingMode =  HttpSamplerNumberingMode.SUFFIX.getStringMode();
+        }
+        
+        if (httpSampleNumberingMode == HttpSamplerNumberingMode.NO_NUMBER.getIntValue())
{
+            // choose no numbering
+        	sNumberingMode = HttpSamplerNumberingMode.NO_NUMBER.getStringMode();
+        }
+    }
+
+    public void setHttpSamplerNumberingStartValue(int httpSamplerNumberingStartValue) {
+        iNumberingStartValue=  httpSamplerNumberingStartValue;
+    }
+
+    public void setHttpSamplerNumberingStartForSamplerCreator(int httpSamplerNumberingStartValue)
{
+        iNumberingStartValue =  httpSamplerNumberingStartValue;
+
+        SamplerCreator samplerCreator = samplerCreatorFactory.getDefaultSamplerCreator();
+        samplerCreator.setRequestNumber(httpSamplerNumberingStartValue);
+    }
+
+    public int getRequestNumberFromSamplerCreator() {
+        int iRequestNumber = 1;
+        SamplerCreator samplerCreator = samplerCreatorFactory.getDefaultSamplerCreator();
+ 
+        iRequestNumber = samplerCreator.getRequestNumber();
+        iNumberingStartValue = iRequestNumber;

Review comment:
       Why this ?

##########
File path: src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/proxy/ProxyControl.java
##########
@@ -355,6 +412,47 @@ public void setHTTPSampleNamingMode(int httpNamingMode) {
         setProperty(new IntegerProperty(HTTP_SAMPLER_NAMING_MODE, httpNamingMode));
     }
 
+    public void setHttpSampleNumberingMode(int httpSampleNumberingMode) {
+        
+        if (httpSampleNumberingMode == HttpSamplerNumberingMode.PREFIX.getIntValue()) {
+        	sNumberingMode = HttpSamplerNumberingMode.PREFIX.getStringMode(); 
+        }
+        
+        if (httpSampleNumberingMode ==  HttpSamplerNumberingMode.SUFFIX.getIntValue()) {

Review comment:
       else if




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



Mime
View raw message