Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to specify keepalives on XML/RPC request #2025

Closed
asfimport opened this issue Sep 26, 2007 · 4 comments
Closed

Ability to specify keepalives on XML/RPC request #2025

asfimport opened this issue Sep 26, 2007 · 4 comments

Comments

@asfimport
Copy link
Collaborator

Dan Keeley (Bug 43485):
Would like the ability to specify keepalives on an XML/RPC request.

I have a patch for this, which i will attach shortly.

OS: other

@asfimport
Copy link
Collaborator Author

Dan Keeley (migrated from Bugzilla):
Created attachment SoapSampler.diff: Path for SoapSampler.java

SoapSampler.diff
Index: SoapSampler.java
===================================================================
--- SoapSampler.java	(revision 587078)
+++ SoapSampler.java	(working copy)
@@ -23,6 +23,7 @@
 import org.apache.commons.httpclient.methods.RequestEntity;
 import org.apache.jmeter.protocol.http.control.Header;
 import org.apache.jmeter.protocol.http.control.HeaderManager;
+import org.apache.jmeter.testelement.property.BooleanProperty;
 import org.apache.jorphan.logging.LoggingManager;
 import org.apache.jorphan.util.JOrphanUtils;
 import org.apache.log.Logger;
@@ -53,11 +54,13 @@
 	public static final String SEND_SOAP_ACTION = "SoapSampler.SEND_SOAP_ACTION"; //$NON-NLS-1$
 
 	public static final String XML_DATA_FILE = "SoapSampler.xml_data_file"; //$NON-NLS-1$
+	
+	public final static String USE_KEEPALIVE = "HTTPSampler.use_keepalive"; // $NON-NLS-1$
 
 	private static final String DOUBLE_QUOTE = "\""; //$NON-NLS-1$
 
 	private static final String SOAPACTION = "SOAPAction"; //$NON-NLS-1$
-
+	
 	public void setXmlData(String data) {
 		setProperty(XML_DATA, data);
 	}
@@ -75,7 +78,7 @@
     public void setXmlFile(String filename) {
         setProperty(XML_DATA_FILE, filename);
     }
-
+    
     /**
      * Get the file location of the xml file.
      *
@@ -84,7 +87,16 @@
     public String getXmlFile() {
         return getPropertyAsString(XML_DATA_FILE);
     }
+    
+	public void setUseKeepAlive(boolean value) {
+		setProperty(new BooleanProperty(USE_KEEPALIVE, value));
+	}
 
+	public boolean getUseKeepAlive() {
+		return getPropertyAsBoolean(USE_KEEPALIVE);
+	}
+
+
 	public String getURLData() {
 		return getPropertyAsString(URL_DATA);
 	}

@asfimport
Copy link
Collaborator Author

Dan Keeley (migrated from Bugzilla):
Created attachment SoapSamplerGui.java: Path for SoapSamplerGui.java

SoapSamplerGui.java
/*
 * 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.http.control.gui;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JCheckBox;
import javax.swing.JPanel;

import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
import org.apache.jmeter.protocol.http.sampler.SoapSampler;
import org.apache.jmeter.samplers.gui.AbstractSamplerGui;
import org.apache.jmeter.testelement.AbstractTestElement;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jmeter.gui.util.FilePanel;
import org.apache.jorphan.gui.JLabeledTextArea;
import org.apache.jorphan.gui.JLabeledTextField;

public class SoapSamplerGui extends AbstractSamplerGui {
	private JLabeledTextField urlField;
	private JLabeledTextField soapAction;
    private JCheckBox sendSoapAction;
    private JCheckBox useKeepAlive;
	private JLabeledTextArea soapXml;

    private FilePanel soapXmlFile = new FilePanel();

	public SoapSamplerGui() {
		init();
	}

	public String getLabelResource() {
		return "soap_sampler_title"; //$NON-NLS-1$
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
	 */
	public TestElement createTestElement() {
		SoapSampler sampler = new SoapSampler();
		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 s) {
		this.configureTestElement(s);
		if (s instanceof SoapSampler) {
			SoapSampler sampler = (SoapSampler) s;
			sampler.setURLData(urlField.getText());
			sampler.setXmlData(soapXml.getText());
            sampler.setXmlFile(soapXmlFile.getFilename());
			sampler.setSOAPAction(soapAction.getText());
			sampler.setSendSOAPAction(sendSoapAction.isSelected());
			sampler.setUseKeepAlive(useKeepAlive.isSelected());
		}
	}

    /**
     * Implements JMeterGUIComponent.clearGui
     */
    public void clearGui() {
        super.clearGui();
        
        urlField.setText(""); //$NON-NLS-1$
        soapAction.setText(""); //$NON-NLS-1$
        soapXml.setText(""); //$NON-NLS-1$
        sendSoapAction.setSelected(true);
        soapXmlFile.setFilename(""); //$NON-NLS-1$
        useKeepAlive.setSelected(false);
    }    

	private void init() {
		setLayout(new BorderLayout());
		setBorder(makeBorder());

		add(makeTitlePanel(), BorderLayout.NORTH);

		urlField = new JLabeledTextField(JMeterUtils.getResString("url"), 10); //$NON-NLS-1$
		soapXml = new JLabeledTextArea(JMeterUtils.getResString("soap_data_title")); //$NON-NLS-1$
		soapAction = new JLabeledTextField("", 10); //$NON-NLS-1$
		sendSoapAction = new JCheckBox(JMeterUtils.getResString("soap_send_action"), true); //$NON-NLS-1$
		useKeepAlive = new JCheckBox(JMeterUtils.getResString("use_keepalive")); // $NON-NLS-1$


		JPanel mainPanel = new JPanel(new BorderLayout());

		JPanel soapActionPanel = new JPanel();
	    soapActionPanel.setLayout(new GridBagLayout());
	    GridBagConstraints c = new GridBagConstraints();
	    c.fill = GridBagConstraints.HORIZONTAL;
	    c.gridwidth = 2;
	    c.gridx = 0;
	    c.gridy = 0;
	    c.weightx = 1;
	    soapActionPanel.add(urlField, c);
	    c.fill = GridBagConstraints.NONE;
	    c.gridwidth = 1;
	    c.gridy = 1;
	    c.weightx = 0;
	    soapActionPanel.add(sendSoapAction, c);
	    c.gridx = 1;
	    c.fill = GridBagConstraints.HORIZONTAL;
	    c.weightx = 1;
		soapActionPanel.add(soapAction, c);

		c.fill = GridBagConstraints.HORIZONTAL;
	    c.gridwidth = 2;
	    c.gridy = 2;
	    c.gridx = 0;
		soapActionPanel.add(useKeepAlive, c);
		
		mainPanel.add(soapActionPanel, BorderLayout.NORTH);
		mainPanel.add(soapXml, BorderLayout.CENTER);
        mainPanel.add(soapXmlFile, BorderLayout.SOUTH);
        
        sendSoapAction.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
		        soapAction.setEnabled(sendSoapAction.isSelected());
		    }
            });

		add(mainPanel, BorderLayout.CENTER);
	}

	public void configure(TestElement el) {
		super.configure(el);
		SoapSampler sampler = (SoapSampler) el;
		urlField.setText(sampler.getURLData());
		sendSoapAction.setSelected(sampler.getSendSOAPAction());
		soapAction.setText(sampler.getSOAPAction());
		soapXml.setText(sampler.getXmlData());
        soapXmlFile.setFilename(sampler.getXmlFile());
        useKeepAlive.setSelected(((AbstractTestElement) el).getPropertyAsBoolean(SoapSampler.USE_KEEPALIVE));
	}

	public Dimension getPreferredSize() {
		return getMinimumSize();
	}
}

@asfimport
Copy link
Collaborator Author

Sebb (migrated from Bugzilla):
Not needed

@asfimport
Copy link
Collaborator Author

Sebb (migrated from Bugzilla):
Thanks for the patch. It has been applied in SVN r587135.

[I simplified it slightly to use the superclass methods]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant