jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1226109 - in /jmeter/trunk: src/core/org/apache/jmeter/util/ src/protocol/java/org/apache/jmeter/protocol/java/control/gui/ src/protocol/java/org/apache/jmeter/protocol/java/sampler/ xdocs/
Date Sat, 31 Dec 2011 15:43:06 GMT
Author: pmouawad
Date: Sat Dec 31 15:43:06 2011
New Revision: 1226109

URL: http://svn.apache.org/viewvc?rev=1226109&view=rev
Log:
Bug 52048 - BSFSampler, BSFPreProcessor and BSFPostProcessor should share the same GUI

Rollback because implementation would introduce backward incompatibility (old scripts cannot
be read), will do it later.

Added:
    jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/control/gui/BSFSamplerGui.java
  (with props)
Removed:
    jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/BSFSamplerBeanInfo.java
    jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/BSFSamplerResources.properties
    jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/BSFSamplerResources_fr.properties
Modified:
    jmeter/trunk/src/core/org/apache/jmeter/util/BSFBeanInfoSupport.java
    jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/BSFSampler.java
    jmeter/trunk/xdocs/changes.xml

Modified: jmeter/trunk/src/core/org/apache/jmeter/util/BSFBeanInfoSupport.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/util/BSFBeanInfoSupport.java?rev=1226109&r1=1226108&r2=1226109&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/util/BSFBeanInfoSupport.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/util/BSFBeanInfoSupport.java Sat Dec 31 15:43:06
2011
@@ -19,10 +19,8 @@
 package org.apache.jmeter.util;
 
 import java.beans.PropertyDescriptor;
-import java.util.Properties;
 
 import org.apache.jmeter.testbeans.BeanInfoSupport;
-import org.apache.jmeter.testbeans.gui.FileEditor;
 import org.apache.jmeter.testbeans.gui.TextAreaEditor;
 
 /**
@@ -30,18 +28,6 @@ import org.apache.jmeter.testbeans.gui.T
  */
 public abstract class BSFBeanInfoSupport extends BeanInfoSupport {
 
-    private final static String[] LANGUAGE_TAGS;
-
-    static {
-        Properties languages = JMeterUtils.loadProperties("org/apache/bsf/Languages.properties");
// $NON-NLS-1$
-        LANGUAGE_TAGS = new String[languages.size() + 1];
-        int i = 0;
-        for (Object language : languages.keySet()) {
-            LANGUAGE_TAGS[i++] = language.toString();
-        }
-        LANGUAGE_TAGS[i] = "jexl";
-    }
-
     protected BSFBeanInfoSupport(Class<?> beanClass) {
         super(beanClass);
         PropertyDescriptor p;
@@ -49,7 +35,6 @@ public abstract class BSFBeanInfoSupport
         p = property("scriptLanguage"); // $NON-NLS-1$
         p.setValue(NOT_UNDEFINED, Boolean.TRUE);
         p.setValue(DEFAULT, ""); // $NON-NLS-1$
-        p.setValue(TAGS, LANGUAGE_TAGS);
 
         createPropertyGroup("scriptingLanguage", // $NON-NLS-1$
                 new String[] { "scriptLanguage" }); // $NON-NLS-1$
@@ -64,7 +49,6 @@ public abstract class BSFBeanInfoSupport
         p = property("filename"); // $NON-NLS-1$
         p.setValue(NOT_UNDEFINED, Boolean.TRUE);
         p.setValue(DEFAULT, ""); // $NON-NLS-1$
-        p.setPropertyEditorClass(FileEditor.class);
 
         createPropertyGroup("filenameGroup",  // $NON-NLS-1$
                 new String[] { "filename" }); // $NON-NLS-1$

Added: jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/control/gui/BSFSamplerGui.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/control/gui/BSFSamplerGui.java?rev=1226109&view=auto
==============================================================================
--- jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/control/gui/BSFSamplerGui.java
(added)
+++ jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/control/gui/BSFSamplerGui.java
Sat Dec 31 15:43:06 2011
@@ -0,0 +1,180 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.jmeter.protocol.java.control.gui;
+
+import java.awt.BorderLayout;
+import java.util.Arrays;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.swing.Box;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+
+import org.apache.jmeter.protocol.java.sampler.BSFSampler;
+import org.apache.jmeter.samplers.gui.AbstractSamplerGui;
+import org.apache.jmeter.testelement.TestElement;
+import org.apache.jmeter.util.JMeterUtils;
+
+public class BSFSamplerGui extends AbstractSamplerGui {
+    private static final long serialVersionUID = 240L;
+
+    private JTextArea scriptField;
+
+    private JComboBox langField;// Language
+
+    private JTextField filename;// script file name (if present)
+
+    private JTextField parameters;// parameters to pass to script file (or script)
+
+    public BSFSamplerGui() {
+        init();
+    }
+
+    @Override
+    public void configure(TestElement element) {
+        super.configure(element);
+        BSFSampler sampler = (BSFSampler) element;
+        scriptField.setText(sampler.getScript());
+        langField.setSelectedItem(sampler.getScriptLanguage());
+        filename.setText(sampler.getFilename());
+        parameters.setText(sampler.getParameters());
+    }
+
+    public TestElement createTestElement() {
+        BSFSampler sampler = new BSFSampler();
+        modifyTestElement(sampler);
+        return sampler;
+    }
+
+    /**
+     * Modifies a given TestElement to mirror the data in the gui components.
+     *
+     * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
+     */
+    public void modifyTestElement(TestElement te) {
+        te.clear();
+        this.configureTestElement(te);
+        BSFSampler sampler = (BSFSampler) te;
+        sampler.setFilename(filename.getText());
+        sampler.setScriptLanguage((String) langField.getSelectedItem());
+        sampler.setParameters(parameters.getText());
+        sampler.setScript(scriptField.getText());
+    }
+
+    /**
+     * Implements JMeterGUIComponent.clearGui
+     */
+    @Override
+    public void clearGui() {
+        super.clearGui();
+
+        scriptField.setText(""); //$NON-NLS-1$
+        langField.setSelectedIndex(0);
+        filename.setText(""); //$NON-NLS-1$
+        parameters.setText(""); //$NON-NLS-1$
+    }
+
+    public String getLabelResource() {
+        return "bsf_sampler_title"; // $NON-NLS-1$
+    }
+
+    private void init() {
+        setLayout(new BorderLayout(0, 5));
+        setBorder(makeBorder());
+
+        Box box = Box.createVerticalBox();
+        box.add(makeTitlePanel());
+        box.add(createLanguagePanel());
+        box.add(createFilenamePanel());
+        box.add(createParameterPanel());
+        add(box, BorderLayout.NORTH);
+
+        JPanel panel = createScriptPanel();
+        add(panel, BorderLayout.CENTER);
+        // Don't let the input field shrink too much
+        add(Box.createVerticalStrut(panel.getPreferredSize().height), BorderLayout.WEST);
+    }
+
+    private JPanel createParameterPanel() {
+        JLabel label = new JLabel(JMeterUtils.getResString("bsf_script_parameters")); //
$NON-NLS-1$
+
+        parameters = new JTextField(10);
+        label.setLabelFor(parameters);
+
+        JPanel parameterPanel = new JPanel(new BorderLayout(5, 0));
+        parameterPanel.add(label, BorderLayout.WEST);
+        parameterPanel.add(parameters, BorderLayout.CENTER);
+        return parameterPanel;
+    }
+
+    private JPanel createFilenamePanel()// TODO ought to be a FileChooser ...
+    {
+        JLabel label = new JLabel(JMeterUtils.getResString("bsf_script_file")); // $NON-NLS-1$
+
+        filename = new JTextField(10);
+        label.setLabelFor(filename);
+
+        JPanel filenamePanel = new JPanel(new BorderLayout(5, 0));
+        filenamePanel.add(label, BorderLayout.WEST);
+        filenamePanel.add(filename, BorderLayout.CENTER);
+        return filenamePanel;
+    }
+
+    private JPanel createLanguagePanel() {
+        JLabel label = new JLabel(JMeterUtils.getResString("bsf_script_language")); // $NON-NLS-1$
+
+        Properties p = JMeterUtils.loadProperties("org/apache/bsf/Languages.properties");
// $NON-NLS-1$
+        // We have added Jexl in BSFSampler.
+        p.put("jexl", ""); // $NON-NLS-1$
+        Set<Object> keySet = p.keySet();
+        // TODO - perhaps weed out ones which don't exist?
+        String [] items = keySet.toArray(new String[]{});
+        Arrays.sort(items);
+
+        langField = new JComboBox(items);
+        langField.setEditable(true);
+        label.setLabelFor(langField);
+
+        JPanel langPanel = new JPanel(new BorderLayout(5, 0));
+        langPanel.add(label, BorderLayout.WEST);
+        langPanel.add(langField, BorderLayout.CENTER);
+
+        return langPanel;
+    }
+
+    private JPanel createScriptPanel() {
+        scriptField = new JTextArea();
+        scriptField.setRows(4);
+        scriptField.setLineWrap(true);
+        scriptField.setWrapStyleWord(true);
+
+        JLabel label = new JLabel(JMeterUtils.getResString("bsf_script")); // $NON-NLS-1$
+        label.setLabelFor(scriptField);
+
+        JPanel panel = new JPanel(new BorderLayout());
+        panel.add(label, BorderLayout.NORTH);
+        panel.add(new JScrollPane(scriptField), BorderLayout.CENTER);
+        return panel;
+    }
+}

Propchange: jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/control/gui/BSFSamplerGui.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/control/gui/BSFSamplerGui.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/BSFSampler.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/BSFSampler.java?rev=1226109&r1=1226108&r2=1226109&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/BSFSampler.java
(original)
+++ jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/BSFSampler.java
Sat Dec 31 15:43:06 2011
@@ -27,7 +27,6 @@ import org.apache.commons.io.IOUtils;
 import org.apache.jmeter.samplers.Entry;
 import org.apache.jmeter.samplers.SampleResult;
 import org.apache.jmeter.samplers.Sampler;
-import org.apache.jmeter.testbeans.TestBean;
 import org.apache.jmeter.util.BSFTestElement;
 import org.apache.jorphan.logging.LoggingManager;
 import org.apache.log.Logger;
@@ -36,7 +35,7 @@ import org.apache.log.Logger;
  * A sampler which understands BSF
  *
  */
-public class BSFSampler extends BSFTestElement implements Sampler, TestBean {
+public class BSFSampler extends BSFTestElement implements Sampler {
 
     private static final long serialVersionUID = 240L;
 

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1226109&r1=1226108&r2=1226109&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Sat Dec 31 15:43:06 2011
@@ -183,7 +183,6 @@ This behaviour can be changed with prope
 <li>Bug 52115 - SOAP/XML-RPC should not send a POST request when file to send is not
found</li>
 <li>Bug 40750 - TCPSampler : Behaviour when sockets are closed by remote host</li>
 <li>Bug 52396 - TCP Sampler in "reuse connection mode" reuses previous sampler's connection
even if it's configured with other host, port, user or password</li>
-<li>Bug 52048 - BSFSampler, BSFPreProcessor and BSFPostProcessor should share the same
GUI</li>
 </ul>
 
 <h3>Controllers</h3>



Mime
View raw message