You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by se...@apache.org on 2016/03/17 18:37:44 UTC

svn commit: r1735467 - in /jmeter/trunk: src/core/org/apache/jmeter/gui/SavePropertyDialog.java src/core/org/apache/jmeter/samplers/SampleSaveConfiguration.java test/src/org/apache/jmeter/samplers/TestSampleSaveConfiguration.java

Author: sebb
Date: Thu Mar 17 17:37:43 2016
New Revision: 1735467

URL: http://svn.apache.org/viewvc?rev=1735467&view=rev
Log:
Sample Result SaveConfig Dialog is generated in random order
Move knowledge of method names to the class that contains them
Bugzilla Id: 59171

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/gui/SavePropertyDialog.java
    jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleSaveConfiguration.java
    jmeter/trunk/test/src/org/apache/jmeter/samplers/TestSampleSaveConfiguration.java

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/SavePropertyDialog.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/SavePropertyDialog.java?rev=1735467&r1=1735466&r2=1735467&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/SavePropertyDialog.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/SavePropertyDialog.java Thu Mar 17 17:37:43 2016
@@ -57,8 +57,6 @@ public class SavePropertyDialog extends
 
     private static final Map<String, Functor> functors = new HashMap<>();
 
-    private static final String NAME_SAVE_PFX   = "save";  // $NON-NLS-1$ i.e. boolean saveXXX()
-    private static final String NAME_SET_PREFIX = "set";   // $NON-NLS-1$ i.e. void setXXX(boolean)
     private static final String RESOURCE_PREFIX = "save_"; // $NON-NLS-1$ e.g. save_XXX property
 
     private SampleSaveConfiguration saveConfig;
@@ -94,9 +92,9 @@ public class SavePropertyDialog extends
             try {
                 JCheckBox check = new JCheckBox(
                         JMeterUtils.getResString(RESOURCE_PREFIX + name),
-                        getSaveState(NAME_SAVE_PFX + name));
+                        getSaveState(SampleSaveConfiguration.getterName(name)));
                 check.addActionListener(this);
-                final String actionCommand = NAME_SET_PREFIX + name; // $NON-NLS-1$
+                final String actionCommand = SampleSaveConfiguration.setterName(name); // $NON-NLS-1$
                 check.setActionCommand(actionCommand);
                 if (!functors.containsKey(actionCommand)) {
                     functors.put(actionCommand, new Functor(actionCommand));

Modified: jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleSaveConfiguration.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleSaveConfiguration.java?rev=1735467&r1=1735466&r2=1735467&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleSaveConfiguration.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleSaveConfiguration.java Thu Mar 17 17:37:43 2016
@@ -429,6 +429,32 @@ public class SampleSaveConfiguration imp
         return _static;
     }
 
+    // for test code only
+    static final String CONFIG_GETTER_PREFIX = "save";  // $NON-NLS-1$
+
+    /**
+     * Convert a config name to the method name of the getter.
+     * The getter method returns a boolean.
+     * @param configName
+     * @return the getter method name
+     */
+    public static final String getterName(String configName) {
+        return CONFIG_GETTER_PREFIX + configName;
+    }
+
+    // for test code only
+    static final String CONFIG_SETTER_PREFIX = "set";  // $NON-NLS-1$
+
+    /**
+     * Convert a config name to the method name of the setter
+     * The setter method requires a boolean parameter.
+     * @param configName
+     * @return the setter method name
+     */
+    public static final String setterName(String configName) {
+        return CONFIG_SETTER_PREFIX + configName;
+    }
+
     /**
      * List of saveXXX/setXXX(boolean) methods which is used to build the Sample Result Save Configuration dialog.
      * New method names should be added at the end so that existing layouts are not affected.

Modified: jmeter/trunk/test/src/org/apache/jmeter/samplers/TestSampleSaveConfiguration.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/samplers/TestSampleSaveConfiguration.java?rev=1735467&r1=1735466&r2=1735467&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/samplers/TestSampleSaveConfiguration.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/samplers/TestSampleSaveConfiguration.java Thu Mar 17 17:37:43 2016
@@ -151,26 +151,24 @@ public class TestSampleSaveConfiguration
     @Test
     // Checks that all the saveXX() and setXXX(boolean) methods are in the list
     public void testSaveConfigNames() throws Exception {
-        List<String> saveMethodNames = new ArrayList<>();
+        List<String> getMethodNames = new ArrayList<>();
         List<String> setMethodNames = new ArrayList<>();
         Method[] methods = SampleSaveConfiguration.class.getMethods();
         for(Method method : methods) {
             String name = method.getName();
-            final String SAVE = "save";
-            if (name.startsWith(SAVE) && method.getParameterTypes().length == 0) {
-                name = name.substring(SAVE.length());
-                saveMethodNames.add(name);
+            if (name.startsWith(SampleSaveConfiguration.CONFIG_GETTER_PREFIX) && method.getParameterTypes().length == 0) {
+                name = name.substring(SampleSaveConfiguration.CONFIG_GETTER_PREFIX.length());
+                getMethodNames.add(name);
                 assertTrue("SAVE_CONFIG_NAMES should contain save" + name, SampleSaveConfiguration.SAVE_CONFIG_NAMES.contains(name));
             }
-            final String SET = "set";
-            if (name.startsWith(SET) && method.getParameterTypes().length == 1 && boolean.class.equals(method.getParameterTypes()[0])) {
-                name = name.substring(SET.length());
+            if (name.startsWith(SampleSaveConfiguration.CONFIG_SETTER_PREFIX) && method.getParameterTypes().length == 1 && boolean.class.equals(method.getParameterTypes()[0])) {
+                name = name.substring(SampleSaveConfiguration.CONFIG_SETTER_PREFIX.length());
                 setMethodNames.add(name);
                 assertTrue("SAVE_CONFIG_NAMES should contain set" + name, SampleSaveConfiguration.SAVE_CONFIG_NAMES.contains(name));
             }
         }
         for (String name : SampleSaveConfiguration.SAVE_CONFIG_NAMES) {
-            assertTrue("SAVE_CONFIG_NAMES should NOT contain save" + name, saveMethodNames.contains(name));
+            assertTrue("SAVE_CONFIG_NAMES should NOT contain save" + name, getMethodNames.contains(name));
             assertTrue("SAVE_CONFIG_NAMES should NOT contain set" + name, setMethodNames.contains(name));
         }
     }