jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1818752 - in /jmeter/trunk: src/protocol/http/org/apache/jmeter/protocol/http/config/gui/ src/protocol/http/org/apache/jmeter/protocol/http/control/ src/protocol/http/org/apache/jmeter/protocol/http/control/gui/ src/protocol/http/org/apach...
Date Wed, 20 Dec 2017 08:54:45 GMT
Author: pmouawad
Date: Wed Dec 20 08:54:45 2017
New Revision: 1818752

URL: http://svn.apache.org/viewvc?rev=1818752&view=rev
Log:
Bug 61919 - UX : Reorder Menus
Contributed by Graham Russell
Reordered menus (2/3)
This comment #360
Bugzilla Id: 61919

Added:
    jmeter/trunk/test/src/org/apache/jmeter/gui/util/MenuFactorySpec.groovy
Removed:
    jmeter/trunk/test/src/org/apache/jmeter/gui/util/TestMenuFactory.java
Modified:
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/HttpDefaultsGui.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CookieManager.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/gui/HttpTestSampleGui.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/CacheManagerGui.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/CookiePanel.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/HeaderPanel.java
    jmeter/trunk/test/src/org/apache/jmeter/visualizers/GenerateTreeGui.java

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/HttpDefaultsGui.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/HttpDefaultsGui.java?rev=1818752&r1=1818751&r2=1818752&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/HttpDefaultsGui.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/HttpDefaultsGui.java
Wed Dec 20 08:54:45 2017
@@ -36,6 +36,7 @@ import javax.swing.UIManager;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.jmeter.config.ConfigTestElement;
 import org.apache.jmeter.config.gui.AbstractConfigGui;
+import org.apache.jmeter.gui.GUIMenuSortOrder;
 import org.apache.jmeter.gui.util.HorizontalPanel;
 import org.apache.jmeter.gui.util.VerticalPanel;
 import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
@@ -51,6 +52,7 @@ import org.apache.jorphan.gui.JLabeledTe
 /**
  * GUI for Http Request defaults
  */
+@GUIMenuSortOrder(1)
 public class HttpDefaultsGui extends AbstractConfigGui {
 
     private static final long serialVersionUID = 241L;

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java?rev=1818752&r1=1818751&r2=1818752&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java
Wed Dec 20 08:54:45 2017
@@ -54,22 +54,24 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * Handles HTTP Caching
+ * Handles HTTP Caching.
  */
 public class CacheManager extends ConfigTestElement implements TestStateListener, TestIterationListener,
Serializable {
 
-    private static final Date EXPIRED_DATE = new Date(0L);
-
     private static final long serialVersionUID = 235L;
 
     private static final Logger log = LoggerFactory.getLogger(CacheManager.class);
 
+    private static final Date EXPIRED_DATE = new Date(0L);
+    private static final int DEFAULT_MAX_SIZE = 5000;
+    private static final long ONE_YEAR_MS = 365*24*60*60*1000L;
     private static final String[] CACHEABLE_METHODS = JMeterUtils.getPropDefault("cacheable_methods",
"GET").split("[ ,]");
 
     static {
-        log.info("Will only cache the following methods: "+Arrays.toString(CACHEABLE_METHODS));
+        if (log.isInfoEnabled()) {
+            log.info("Will only cache the following methods: " + Arrays.toString(CACHEABLE_METHODS));
+        }
     }
-
     //+ JMX attributes, do not change values
     public static final String CLEAR = "clearEachIteration"; // $NON-NLS-1$
     public static final String USE_EXPIRES = "useExpires"; // $NON-NLS-1$
@@ -80,11 +82,8 @@ public class CacheManager extends Config
 
     private transient boolean useExpires; // Cached value
 
-    private static final int DEFAULT_MAX_SIZE = 5000;
-
-    private static final long ONE_YEAR_MS = 365*24*60*60*1000L;
-    
-    /** used to share the cache between 2 cache managers
+    /**
+     * used to share the cache between 2 cache managers
      * @see CacheManager#createCacheManagerProxy() 
      * @since 3.0 */
     private transient Map<String, CacheEntry> localCache;

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CookieManager.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CookieManager.java?rev=1818752&r1=1818751&r2=1818752&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CookieManager.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CookieManager.java
Wed Dec 20 08:54:45 2017
@@ -50,7 +50,6 @@ import org.slf4j.LoggerFactory;
 /**
  * This class provides an interface to the netscape cookies file to pass cookies
  * along with a request.
- *
  */
 public class CookieManager extends ConfigTestElement implements TestStateListener, TestIterationListener,
Serializable {
     private static final long serialVersionUID = 234L;
@@ -59,11 +58,8 @@ public class CookieManager extends Confi
 
     //++ JMX tag values
     private static final String CLEAR = "CookieManager.clearEachIteration";// $NON-NLS-1$
-
     private static final String COOKIES = "CookieManager.cookies";// $NON-NLS-1$
-
     private static final String POLICY = "CookieManager.policy"; //$NON-NLS-1$
-    
     private static final String IMPLEMENTATION = "CookieManager.implementation"; //$NON-NLS-1$
     //-- JMX tag values
 
@@ -92,8 +88,8 @@ public class CookieManager extends Confi
                 DELETE_NULL_COOKIES, CHECK_COOKIES, ALLOW_VARIABLE_COOKIES, 
                 SAVE_COOKIES, COOKIE_NAME_PREFIX);
     }
-    private transient CookieHandler cookieHandler;
 
+    private transient CookieHandler cookieHandler;
     private transient CollectionProperty initialCookies;
 
     /**

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/gui/HttpTestSampleGui.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/gui/HttpTestSampleGui.java?rev=1818752&r1=1818751&r2=1818752&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/gui/HttpTestSampleGui.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/gui/HttpTestSampleGui.java
Wed Dec 20 08:54:45 2017
@@ -34,6 +34,7 @@ import javax.swing.JTabbedPane;
 import javax.swing.JTextField;
 import javax.swing.UIManager;
 
+import org.apache.jmeter.gui.GUIMenuSortOrder;
 import org.apache.jmeter.gui.util.HorizontalPanel;
 import org.apache.jmeter.gui.util.VerticalPanel;
 import org.apache.jmeter.protocol.http.config.gui.UrlConfigGui;
@@ -48,6 +49,7 @@ import org.apache.jorphan.gui.JLabeledTe
 /**
  * HTTP Sampler GUI
  */
+@GUIMenuSortOrder(1)
 public class HttpTestSampleGui extends AbstractSamplerGui {
     
     private static final long serialVersionUID = 241L;

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/CacheManagerGui.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/CacheManagerGui.java?rev=1818752&r1=1818751&r2=1818752&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/CacheManagerGui.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/CacheManagerGui.java
Wed Dec 20 08:54:45 2017
@@ -26,28 +26,24 @@ import javax.swing.JPanel;
 import javax.swing.JTextField;
 
 import org.apache.jmeter.config.gui.AbstractConfigGui;
+import org.apache.jmeter.gui.GUIMenuSortOrder;
 import org.apache.jmeter.protocol.http.control.CacheManager;
 import org.apache.jmeter.testelement.TestElement;
 import org.apache.jmeter.util.JMeterUtils;
 import org.apache.jorphan.gui.layout.VerticalLayout;
 
 /**
- * The GUI for the HTTP Cache Manager
- *
+ * The GUI for the HTTP Cache Manager {@link CacheManager}
  */
+@GUIMenuSortOrder(2)
 public class CacheManagerGui extends AbstractConfigGui {
 
     private static final long serialVersionUID = 240L;
 
     private JCheckBox clearEachIteration;
-
     private JCheckBox useExpires;
-
     private JTextField maxCacheSize;
 
-    /**
-     * Create a new LoginConfigGui as a standalone component.
-     */
     public CacheManagerGui() {
         init();
     }
@@ -57,15 +53,6 @@ public class CacheManagerGui extends Abs
         return "cache_manager_title"; // $NON-NLS-1$
     }
 
-    /**
-     * A newly created component can be initialized with the contents of a Test
-     * Element object by calling this method. The component is responsible for
-     * querying the Test Element object for the relevant information to display
-     * in its GUI.
-     *
-     * @param element
-     *            the TestElement to configure
-     */
     @Override
     public void configure(TestElement element) {
         super.configure(element);
@@ -75,7 +62,6 @@ public class CacheManagerGui extends Abs
         maxCacheSize.setText(Integer.toString(cacheManager.getMaxSize()));
     }
 
-    /* Implements JMeterGUIComponent.createTestElement() */
     @Override
     public TestElement createTestElement() {
         CacheManager element = new CacheManager();
@@ -83,7 +69,6 @@ public class CacheManagerGui extends Abs
         return element;
     }
 
-    /* Implements JMeterGUIComponent.modifyTestElement(TestElement) */
     @Override
     public void modifyTestElement(TestElement element) {
         configureTestElement(element);
@@ -92,7 +77,7 @@ public class CacheManagerGui extends Abs
         cacheManager.setUseExpires(useExpires.isSelected());
         try {
             cacheManager.setMaxSize(Integer.parseInt(maxCacheSize.getText()));
-        } catch (NumberFormatException e) {
+        } catch (NumberFormatException ignored) {
             // NOOP
         }
     }
@@ -110,8 +95,9 @@ public class CacheManagerGui extends Abs
 
     /**
      * Initialize the components and layout of this component.
+     * WARNING: called from ctor so must not be overridden (i.e. must be private or final)
      */
-    private void init() { // WARNING: called from ctor so must not be overridden (i.e. must
be private or final)
+    private void init() {
         setLayout(new BorderLayout(0, 5));
         setBorder(makeBorder());
 

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/CookiePanel.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/CookiePanel.java?rev=1818752&r1=1818751&r2=1818752&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/CookiePanel.java (original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/CookiePanel.java Wed
Dec 20 08:54:45 2017
@@ -35,6 +35,7 @@ import javax.swing.JTable;
 import javax.swing.ListSelectionModel;
 
 import org.apache.jmeter.config.gui.AbstractConfigGui;
+import org.apache.jmeter.gui.GUIMenuSortOrder;
 import org.apache.jmeter.gui.util.FileDialoger;
 import org.apache.jmeter.gui.util.HeaderAsPropertyRenderer;
 import org.apache.jmeter.gui.util.PowerTableModel;
@@ -51,12 +52,12 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * This is the GUI for Cookie Manager
+ * This is the GUI for Cookie Manager {@link CookieManager}
  *
  * Allows the user to specify if she needs cookie services, and give parameters
  * for this service.
- *
  */
+@GUIMenuSortOrder(3)
 public class CookiePanel extends AbstractConfigGui implements ActionListener {
 
     private static final long serialVersionUID = 241L;
@@ -65,53 +66,36 @@ public class CookiePanel extends Abstrac
 
     //++ Action command names
     private static final String ADD_COMMAND = "Add"; //$NON-NLS-1$
-
     private static final String DELETE_COMMAND = "Delete"; //$NON-NLS-1$
-
     private static final String LOAD_COMMAND = "Load"; //$NON-NLS-1$
-
     private static final String SAVE_COMMAND = "Save"; //$NON-NLS-1$
     //--
-    /**
-     * The default policy that is used when creating a new CookieManager
-     */
-    private static final String DEFAULT_POLICY = HC4CookieHandler.DEFAULT_POLICY_NAME;
-
-    private JTable cookieTable;
-
-    private PowerTableModel tableModel;
-
-    private JCheckBox clearEachIteration;
 
+    private static final String DEFAULT_POLICY = HC4CookieHandler.DEFAULT_POLICY_NAME;
     private static final String[] COLUMN_RESOURCE_NAMES = {
-        "name",   //$NON-NLS-1$
-        "value",  //$NON-NLS-1$
-        "domain", //$NON-NLS-1$
-        "path",   //$NON-NLS-1$
-        "secure", //$NON-NLS-1$
-        // removed expiration because it's just an annoyance for static cookies
+            "name",   //$NON-NLS-1$
+            "value",  //$NON-NLS-1$
+            "domain", //$NON-NLS-1$
+            "path",   //$NON-NLS-1$
+            "secure", //$NON-NLS-1$
+            // removed expiration because it's just an annoyance for static cookies
     };
-
     private static final Class<?>[] columnClasses = {
-        String.class,
-        String.class,
-        String.class,
-        String.class,
-        Boolean.class, };
+            String.class,
+            String.class,
+            String.class,
+            String.class,
+            Boolean.class, };
 
+    private JTable cookieTable;
+    private PowerTableModel tableModel;
+    private JCheckBox clearEachIteration;
     private JButton addButton;
-
     private JButton deleteButton;
-
     private JButton loadButton;
-
     private JButton saveButton;
-
     private JLabeledChoice policy;
 
-    /**
-     * Default constructor.
-     */
     public CookiePanel() {
         init();
     }

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/HeaderPanel.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/HeaderPanel.java?rev=1818752&r1=1818751&r2=1818752&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/HeaderPanel.java (original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/HeaderPanel.java Wed
Dec 20 08:54:45 2017
@@ -37,6 +37,7 @@ import javax.swing.ListSelectionModel;
 import javax.swing.table.AbstractTableModel;
 
 import org.apache.jmeter.config.gui.AbstractConfigGui;
+import org.apache.jmeter.gui.GUIMenuSortOrder;
 import org.apache.jmeter.gui.util.FileDialoger;
 import org.apache.jmeter.gui.util.HeaderAsPropertyRenderer;
 import org.apache.jmeter.protocol.http.control.Header;
@@ -51,39 +52,26 @@ import org.slf4j.LoggerFactory;
  * Allows the user to specify if she needs HTTP header services, and give
  * parameters for this service.
  */
+@GUIMenuSortOrder(4)
 public class HeaderPanel extends AbstractConfigGui implements ActionListener {
-    /** When pasting from the clipboard, split lines on linebreak */
-    private static final String CLIPBOARD_LINE_DELIMITER = "\n"; //$NON-NLS-1$
 
-    /** When pasting from the clipboard, split parameters on ':' */
-    private static final String CLIPBOARD_COLON_DELIMITER = ":"; //$NON-NLS-1$
+    private static final Logger log = LoggerFactory.getLogger(HeaderPanel.class);
 
-    /** When pasting from the clipboard, split parameters on '\t' */
-    private static final String CLIPBOARD_TAB_DELIMITER = "\t";
-    
     private static final long serialVersionUID = 241L;
 
-    private static final Logger log = LoggerFactory.getLogger(HeaderPanel.class);
-
+    private static final String CLIPBOARD_LINE_DELIMITER = "\n";
+    private static final String CLIPBOARD_COLON_DELIMITER = ":";
+    private static final String CLIPBOARD_TAB_DELIMITER = "\t";
     private static final String ADD_COMMAND = "Add"; // $NON-NLS-1$
-
     private static final String DELETE_COMMAND = "Delete"; // $NON-NLS-1$
-
     private static final String LOAD_COMMAND = "Load"; // $NON-NLS-1$
-
     private static final String SAVE_COMMAND = "Save"; // $NON-NLS-1$
-
-    /** Command for adding rows from the clipboard */
     private static final String ADD_FROM_CLIPBOARD = "addFromClipboard"; // $NON-NLS-1$
 
     private final InnerTableModel tableModel;
-
     private final HeaderManager headerManager;
-
     private JTable headerTable;
-
     private JButton deleteButton;
-
     private JButton saveButton;
 
     public HeaderPanel() {
@@ -111,9 +99,6 @@ public class HeaderPanel extends Abstrac
         configureTestElement(el);
     }
 
-    /**
-     * Implements JMeterGUIComponent.clearGui
-     */
     @Override
     public void clearGui() {
         super.clearGui();
@@ -362,25 +347,16 @@ public class HeaderPanel extends Abstrac
             return manager.getHeaders().size();
         }
 
-        /**
-         * Required by table model interface.
-         */
         @Override
         public int getColumnCount() {
             return manager.getColumnCount();
         }
 
-        /**
-         * Required by table model interface.
-         */
         @Override
         public String getColumnName(int column) {
             return manager.getColumnName(column);
         }
 
-        /**
-         * Required by table model interface.
-         */
         @Override
         public Object getValueAt(int row, int column) {
             Header head = manager.getHeader(row);
@@ -392,9 +368,6 @@ public class HeaderPanel extends Abstrac
             return null;
         }
 
-        /**
-         * Required by table model interface.
-         */
         @Override
         public void setValueAt(Object value, int row, int column) {
             Header header = manager.getHeader(row);

Added: jmeter/trunk/test/src/org/apache/jmeter/gui/util/MenuFactorySpec.groovy
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/gui/util/MenuFactorySpec.groovy?rev=1818752&view=auto
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/gui/util/MenuFactorySpec.groovy (added)
+++ jmeter/trunk/test/src/org/apache/jmeter/gui/util/MenuFactorySpec.groovy Wed Dec 20 08:54:45
2017
@@ -0,0 +1,16 @@
+package org.apache.jmeter.gui.util
+
+import org.apache.jmeter.junit.categories.NeedGuiTests
+import org.apache.jmeter.junit.spock.JMeterSpec
+import org.junit.experimental.categories.Category
+
+@Category(NeedGuiTests.class)
+class MenuFactorySpec extends JMeterSpec {
+
+    def "ensure each menu has something in it"() {
+        expect:
+            MenuFactory.menuMap.size() == 11
+            MenuFactory.menuMap.values().stream().noneMatch({ it.isEmpty() })
+            !MenuFactory.elementsToSkip.isEmpty()
+    }
+}

Modified: jmeter/trunk/test/src/org/apache/jmeter/visualizers/GenerateTreeGui.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/visualizers/GenerateTreeGui.java?rev=1818752&r1=1818751&r2=1818752&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/visualizers/GenerateTreeGui.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/visualizers/GenerateTreeGui.java Wed Dec 20 08:54:45
2017
@@ -26,7 +26,6 @@ import java.awt.event.ActionListener;
 import java.lang.reflect.InvocationTargetException;
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.List;
 
 import javax.swing.Box;
 import javax.swing.ButtonGroup;
@@ -52,15 +51,15 @@ import org.apache.jmeter.util.JMeterUtil
 /**
  * Workbench test element to create a test plan containing samples of each test element
  * (apart from Threads and Test Fragment).
- *<p>
+ * <p>
  * The user creates a Thread Group, and the elements are created as child elements of
  * Simple Controllers.
- *<p>
+ * <p>
  * Note: the code currently runs on all versions of JMeter back to 2.2.
  * Beware of making changes that rely on more recent APIs.
  */
-public class GenerateTreeGui extends AbstractConfigGui implements
-        ActionListener, UnsharedComponent {
+public class GenerateTreeGui extends AbstractConfigGui
+        implements ActionListener, UnsharedComponent {
 
     private static final long serialVersionUID = 1L;
 
@@ -88,40 +87,42 @@ public class GenerateTreeGui extends Abs
 
     @Override
     public Collection<String> getMenuCategories() {
-        return Arrays.asList(new String[] { MenuFactory.NON_TEST_ELEMENTS });
+        return Arrays.asList(MenuFactory.NON_TEST_ELEMENTS);
     }
 
     @Override
     public void actionPerformed(ActionEvent action) {
         GuiPackage guiPackage = GuiPackage.getInstance();
         JMeterTreeModel treeModel = guiPackage.getTreeModel();
-        JMeterTreeNode myTarget = findFirstNodeOfType(org.apache.jmeter.threads.ThreadGroup.class,
treeModel);
+        JMeterTreeNode myTarget = findFirstNodeOfType(ThreadGroup.class, treeModel);
         if (myTarget == null) {
             JMeterUtils.reportErrorToUser("Cannot find Thread Group");
             return;
         }
 
         addElements(MenuFactory.CONTROLLERS,     "Controllers",     guiPackage, treeModel,
myTarget);
-        addElements(MenuFactory.CONFIG_ELEMENTS, "Config Elements", guiPackage, treeModel,
myTarget);
+        addElements(MenuFactory.SAMPLERS,        "Samplers",        guiPackage, treeModel,
myTarget);
         addElements(MenuFactory.TIMERS,          "Timers",          guiPackage, treeModel,
myTarget);
+        addElements(MenuFactory.ASSERTIONS,      "Assertions",      guiPackage, treeModel,
myTarget);
         addElements(MenuFactory.PRE_PROCESSORS,  "Pre Processors",  guiPackage, treeModel,
myTarget);
-        addElements(MenuFactory.SAMPLERS,        "Samplers",        guiPackage, treeModel,
myTarget);
         addElements(MenuFactory.POST_PROCESSORS, "Post Processors", guiPackage, treeModel,
myTarget);
-        addElements(MenuFactory.ASSERTIONS,      "Assertions",      guiPackage, treeModel,
myTarget);
+        addElements(MenuFactory.CONFIG_ELEMENTS, "Config Elements", guiPackage, treeModel,
myTarget);
         addElements(MenuFactory.LISTENERS,       "Listeners",       guiPackage, treeModel,
myTarget);
     }
 
-    private void addElements(String menuKey, String title, GuiPackage guiPackage, JMeterTreeModel
treeModel,
-            JMeterTreeNode myTarget) {
+    private void addElements(
+            String menuKey, String title, GuiPackage guiPackage,
+            JMeterTreeModel treeModel, JMeterTreeNode myTarget) {
+
         myTarget = addSimpleController(treeModel, myTarget, title);
         JPopupMenu jp = MenuFactory.makeMenu(menuKey, "").getPopupMenu();
         for (Component comp : jp.getComponents()) {
-            JMenuItem jmi = (JMenuItem) comp;
+            JMenuItem item = (JMenuItem) comp;
             try {
-                TestElement testElement = guiPackage.createTestElement(jmi.getName());
+                TestElement testElement = guiPackage.createTestElement(item.getName());
                 addToTree(treeModel, myTarget, testElement);
             } catch (Exception e) {
-                addSimpleController(treeModel, myTarget, jmi.getName()+" "+e.getMessage());
+                addSimpleController(treeModel, myTarget, item.getName()+" "+e.getMessage());
             }
         }
     }
@@ -167,15 +168,14 @@ public class GenerateTreeGui extends Abs
         p.add(Box.createVerticalStrut(70), BorderLayout.WEST);
         add(p, BorderLayout.CENTER);
     }
+
     /**
      * Helper method to add a Simple Controller to contain the elements.
      * Called from Application Thread that needs to update GUI (JMeterTreeModel)
-     * @param model
-     *            Test component tree model
-     * @param node
-     *            Node in the tree where we will add the Controller
-     * @param name
-     *            A name for the Controller
+     *
+     * @param model Test component tree model
+     * @param node  Node in the tree where we will add the Controller
+     * @param name  A name for the Controller
      * @return the new node
      */
     private JMeterTreeNode addSimpleController(JMeterTreeModel model, JMeterTreeNode node,
String name) {
@@ -228,20 +228,15 @@ public class GenerateTreeGui extends Abs
     /**
      * Finds the first enabled node of a given type in the tree.
      *
-     * @param type
-     *            class of the node to be found
+     * @param type      class of the node to be found
      * @param treeModel the tree to search in
-     *
      * @return the first node of the given type in the test component tree, or
-     *         <code>null</code> if none was found.
+     * <code>null</code> if none was found.
      */
     private JMeterTreeNode findFirstNodeOfType(Class<?> type, JMeterTreeModel treeModel)
{
-        List<JMeterTreeNode> nodes = treeModel.getNodesOfType(type);
-        for (JMeterTreeNode node : nodes) {
-            if (node.isEnabled()) {
-                return node;
-            }
-        }
-        return null;
+        return treeModel.getNodesOfType(type).stream()
+                .filter(JMeterTreeNode::isEnabled)
+                .findFirst()
+                .orElse(null);
     }
 }



Mime
View raw message