jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1532114 - /jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/config/gui/JavaConfigGui.java
Date Mon, 14 Oct 2013 21:50:27 GMT
Author: pmouawad
Date: Mon Oct 14 21:50:26 2013
New Revision: 1532114

URL: http://svn.apache.org/r1532114
Log:
Bug 55652 - JavaSampler silently resets classname if class can not be found
Add as a minimum an error log
Bugzilla Id: 55652

Modified:
    jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/config/gui/JavaConfigGui.java

Modified: jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/config/gui/JavaConfigGui.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/config/gui/JavaConfigGui.java?rev=1532114&r1=1532113&r2=1532114&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/config/gui/JavaConfigGui.java
(original)
+++ jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/config/gui/JavaConfigGui.java
Mon Oct 14 21:50:26 2013
@@ -22,9 +22,12 @@ import java.awt.BorderLayout;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
+import javax.swing.ComboBoxModel;
 import javax.swing.JComboBox;
 import javax.swing.JLabel;
 import javax.swing.JPanel;
@@ -225,7 +228,27 @@ public class JavaConfigGui extends Abstr
 
         argsPanel.configure((Arguments) config.getProperty(JavaSampler.ARGUMENTS).getObjectValue());
 
-        classnameCombo.setSelectedItem(config.getPropertyAsString(JavaSampler.CLASSNAME));
+        String className = config.getPropertyAsString(JavaSampler.CLASSNAME);
+        if(checkContainsClassName(classnameCombo.getModel(), className)) {
+            classnameCombo.setSelectedItem(className);
+        } else {
+            log.error("Error setting class:'"+className+"' in JavaSampler "+getName()+",
check for a missing jar in your jmeter classpath");
+        }
+    }
+
+    /**
+     * Check combo contains className
+     * @param model ComboBoxModel
+     * @param className String class name
+     * @return boolean
+     */
+    private static final boolean checkContainsClassName(ComboBoxModel model, String className)
{
+        int size = model.getSize();
+        Set<String> set = new HashSet<String>(size);
+        for (int i = 0; i < size; i++) {
+            set.add((String)model.getElementAt(i));
+        }
+        return set.contains(className);
     }
 
     /** {@inheritDoc} */



Mime
View raw message