Author: sebb
Date: Mon May 22 14:49:11 2006
New Revision: 408770
URL: http://svn.apache.org/viewvc?rev=408770&view=rev
Log:
Bug 39626 - Loading SOAP/XML-RPC requests from file
Modified:
jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/gui/util/FileDialoger.java
jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/gui/util/FilePanel.java
jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/resources/messages.properties
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/control/gui/SoapSamplerGui.java
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/sampler/SoapSampler.java
jakarta/jmeter/branches/rel-2-1/xdocs/changes.xml
jakarta/jmeter/branches/rel-2-1/xdocs/images/screenshots/soap_sampler.png
jakarta/jmeter/branches/rel-2-1/xdocs/usermanual/component_reference.xml
Modified:
jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/gui/util/FileDialoger.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/gui/util/FileDialoger.java?rev=408770&r1=408769&r2=408770&view=diff
==============================================================================
---
jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/gui/util/FileDialoger.java
(original)
+++
jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/gui/util/FileDialoger.java
Mon May 22 14:49:11 2006
@@ -60,14 +60,16 @@
// JFileChooser jfc = null;
if (lastJFCDirectory == null) {
- String start = JMeterUtils.getPropDefault("user.dir",
"");
+ String start = JMeterUtils.getPropDefault("user.dir",
""); //$NON-NLS-1$//$NON-NLS-2$
- if (!start.equals("")) {
+ if (start.length() > 0) {
jfc.setCurrentDirectory(new File(start));
}
}
clearFileFilters();
- jfc.addChoosableFileFilter(new JMeterFileFilter(exts));
+ if(exts != null && exts.length > 0) {
+ jfc.addChoosableFileFilter(new JMeterFileFilter(exts));
+ }
int retVal =
jfc.showOpenDialog(GuiPackage.getInstance().getMainFrame());
lastJFCDirectory = jfc.getCurrentDirectory().getAbsolutePath();
@@ -114,17 +116,17 @@
*/
public static JFileChooser promptToSaveFile(String filename, String[]
extensions) {
if (lastJFCDirectory == null) {
- String start = JMeterUtils.getPropDefault("user.dir",
"");
- if (!start.equals("")) {
+ String start = JMeterUtils.getPropDefault("user.dir",
"");//$NON-NLS-1$//$NON-NLS-2$
+ if (start.length() > 0) {
jfc = new JFileChooser(new File(start));
}
lastJFCDirectory =
jfc.getCurrentDirectory().getAbsolutePath();
}
- String ext = ".jmx";
+ String ext = ".jmx";//$NON-NLS-1$
if (filename != null) {
jfc.setSelectedFile(new File(lastJFCDirectory,
filename));
int i = -1;
- if ((i = filename.lastIndexOf(".")) > -1) {
+ if ((i = filename.lastIndexOf(".")) > -1) {//$NON-NLS-1$
ext = filename.substring(i);
}
}
Modified:
jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/gui/util/FilePanel.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/gui/util/FilePanel.java?rev=408770&r1=408769&r2=408770&view=diff
==============================================================================
---
jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/gui/util/FilePanel.java
(original)
+++
jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/gui/util/FilePanel.java
Mon May 22 14:49:11 2006
@@ -36,17 +36,18 @@
import org.apache.jmeter.util.JMeterUtils;
/**
- * @author Michael Stover Created April 18, 2002
- * @version $Revision$ Last updated: $Date$
+ * author Michael Stover Created April 18, 2002
*/
public class FilePanel extends HorizontalPanel implements ActionListener {
JTextField filename = new JTextField(20);
- JLabel label = new
JLabel(JMeterUtils.getResString("file_visualizer_filename"));
+ JLabel label = new
JLabel(JMeterUtils.getResString("file_visualizer_filename")); //$NON-NLS-1$
- JButton browse = new JButton(JMeterUtils.getResString("browse"));
+ JButton browse = new JButton(JMeterUtils.getResString("browse"));
//$NON-NLS-1$
- List listeners = new LinkedList();
+ private static final String ACTION_BROWSE = "browse"; //$NON-NLS-1$
+
+ List listeners = new LinkedList();
String title;
@@ -56,7 +57,7 @@
* Constructor for the FilePanel object.
*/
public FilePanel() {
- title = "";
+ title = ""; //$NON-NLS-1$
init();
}
@@ -91,7 +92,7 @@
add(Box.createHorizontalStrut(5));
filename.addActionListener(this);
add(browse);
- browse.setActionCommand("browse");
+ browse.setActionCommand(ACTION_BROWSE);
browse.addActionListener(this);
}
@@ -133,8 +134,13 @@
}
public void actionPerformed(ActionEvent e) {
- if (e.getActionCommand().equals("browse")) {
- JFileChooser chooser =
FileDialoger.promptToOpenFile(new String[] { filetype });
+ if (e.getActionCommand().equals(ACTION_BROWSE)) {
+ JFileChooser chooser;
+ if(filetype == null){
+ chooser = FileDialoger.promptToOpenFile();
+ } else {
+ chooser = FileDialoger.promptToOpenFile(new String[] {
filetype });
+ }
if (chooser != null && chooser.getSelectedFile() !=
null) {
filename.setText(chooser.getSelectedFile().getPath());
fireFileChanged();
Modified:
jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/resources/messages.properties
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/resources/messages.properties?rev=408770&r1=408769&r2=408770&view=diff
==============================================================================
---
jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/resources/messages.properties
(original)
+++
jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/resources/messages.properties
Mon May 22 14:49:11 2006
@@ -639,6 +639,7 @@
soap_action=Soap Action
soap_data_title=Soap/XML-RPC Data
soap_sampler_title=SOAP/XML-RPC Request
+soap_send_action=Send SOAPAction:
spline_visualizer_average=Average
spline_visualizer_incoming=Incoming
spline_visualizer_maximum=Maximum
Modified:
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/control/gui/SoapSamplerGui.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/control/gui/SoapSamplerGui.java?rev=408770&r1=408769&r2=408770&view=diff
==============================================================================
---
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/control/gui/SoapSamplerGui.java
(original)
+++
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/control/gui/SoapSamplerGui.java
Mon May 22 14:49:11 2006
@@ -31,11 +31,11 @@
import org.apache.jmeter.samplers.gui.AbstractSamplerGui;
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;
/**
- * @version $Revision$ on $Date$
*/
public class SoapSamplerGui extends AbstractSamplerGui {
private JLabeledTextField urlField;
@@ -43,12 +43,14 @@
private JCheckBox sendSoapAction;
private JLabeledTextArea soapXml;
+ private FilePanel soapXmlFile = new FilePanel();
+
public SoapSamplerGui() {
init();
}
public String getLabelResource() {
- return "soap_sampler_title";
+ return "soap_sampler_title"; //$NON-NLS-1$
}
/*
@@ -73,6 +75,7 @@
SoapSampler sampler = (SoapSampler) s;
sampler.setURLData(urlField.getText());
sampler.setXmlData(soapXml.getText());
+ sampler.setXmlFile(soapXmlFile.getFilename());
sampler.setSOAPAction(soapAction.getText());
sampler.setSendSOAPAction(sendSoapAction.isSelected());
}
@@ -84,10 +87,10 @@
add(makeTitlePanel(), BorderLayout.NORTH);
- urlField = new
JLabeledTextField(JMeterUtils.getResString("url"), 10);
- soapXml = new
JLabeledTextArea(JMeterUtils.getResString("soap_data_title"), null);
- soapAction = new JLabeledTextField("", 10);
- sendSoapAction = new JCheckBox("Send SOAPAction: ", true);
+ urlField = new
JLabeledTextField(JMeterUtils.getResString("url"), 10); //$NON-NLS-1$
+ soapXml = new
JLabeledTextArea(JMeterUtils.getResString("soap_data_title"), null);
//$NON-NLS-1$
+ soapAction = new JLabeledTextField("", 10); //$NON-NLS-1$
+ sendSoapAction = new
JCheckBox(JMeterUtils.getResString("soap_send_action"), true); //$NON-NLS-1$
JPanel mainPanel = new JPanel(new BorderLayout());
JPanel soapActionPanel = new JPanel();
@@ -110,6 +113,7 @@
soapActionPanel.add(soapAction, 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) {
@@ -127,6 +131,7 @@
sendSoapAction.setSelected(sampler.getSendSOAPAction());
soapAction.setText(sampler.getSOAPAction());
soapXml.setText(sampler.getXmlData());
+ soapXmlFile.setFilename(sampler.getXmlFile());
}
public Dimension getPreferredSize() {
Modified:
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/sampler/SoapSampler.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/sampler/SoapSampler.java?rev=408770&r1=408769&r2=408770&view=diff
==============================================================================
---
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/sampler/SoapSampler.java
(original)
+++
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/sampler/SoapSampler.java
Mon May 22 14:49:11 2006
@@ -19,6 +19,9 @@
import java.io.IOException;
import java.io.PrintWriter;
+import java.io.OutputStream;
+import java.io.InputStream;
+import java.io.FileInputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
@@ -34,19 +37,20 @@
/**
* Sampler to handle SOAP Requests.
*
- * @author Jordi Salvat i Alabart
- * @version $Id$
+ * author Jordi Salvat i Alabart
*/
public class SoapSampler extends HTTPSampler {
- private static Logger log = LoggingManager.getLoggerForClass();
+ private static final Logger log = LoggingManager.getLoggerForClass();
- public static final String XML_DATA = "HTTPSamper.xml_data";
+ public static final String XML_DATA = "HTTPSamper.xml_data";
//$NON-NLS-1$
- public static final String URL_DATA = "SoapSampler.URL_DATA";
+ public static final String URL_DATA = "SoapSampler.URL_DATA";
//$NON-NLS-1$
- public static final String SOAP_ACTION = "SoapSampler.SOAP_ACTION";
+ public static final String SOAP_ACTION = "SoapSampler.SOAP_ACTION";
//$NON-NLS-1$
- public static final String SEND_SOAP_ACTION =
"SoapSampler.SEND_SOAP_ACTION";
+ 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 void setXmlData(String data) {
setProperty(XML_DATA, data);
@@ -56,6 +60,25 @@
return getPropertyAsString(XML_DATA);
}
+ /**
+ * it's kinda obvious, but we state it anyways. Set the xml file with a
+ * string path.
+ *
+ * @param filename
+ */
+ public void setXmlFile(String filename) {
+ setProperty(XML_DATA_FILE, filename);
+ }
+
+ /**
+ * Get the file location of the xml file.
+ *
+ * @return String file path.
+ */
+ public String getXmlFile() {
+ return getPropertyAsString(XML_DATA_FILE);
+ }
+
public String getURLData() {
return getPropertyAsString(URL_DATA);
}
@@ -90,8 +113,8 @@
* if an I/O exception occurs
*/
protected void setPostHeaders(URLConnection connection) throws
IOException {
- ((HttpURLConnection) connection).setRequestMethod("POST");
- connection.setRequestProperty("Content-Length", "" +
getXmlData().length());
+ ((HttpURLConnection) connection).setRequestMethod(POST);
+ connection.setRequestProperty(HEADER_CONTENT_LENGTH,
String.valueOf(getXmlData().length()));
// my first attempt at fixing the bug failed, due to user
// error on my part. HeaderManager does not use the normal
// setProperty, and getPropertyAsString methods. Instead,
@@ -108,8 +131,10 @@
}
} else {
// otherwise we use "text/xml" as the default
- connection.setRequestProperty("Content-Type",
"text/xml");
- if(getSendSOAPAction())
connection.setRequestProperty("SOAPAction", "\"" + getSOAPAction() + "\"");
+ connection.setRequestProperty(HEADER_CONTENT_TYPE,
"text/xml"); //$NON-NLS-1$
+ if(getSendSOAPAction()) {
+ connection.setRequestProperty("SOAPAction", "\"" +
getSOAPAction() + "\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
}
connection.setDoOutput(true);
}
@@ -123,9 +148,27 @@
* if an I/O exception occurs
*/
protected void sendPostData(URLConnection connection) throws
IOException {
- PrintWriter out = new PrintWriter(connection.getOutputStream());
- out.print(getXmlData());
- out.close();
+ String xmlFile = getXmlFile();
+ if (xmlFile != null && getXmlFile().length() > 0) {
+ OutputStream out = connection.getOutputStream();
+ byte[] buf = new byte[1024];
+ // 1k - the previous 100k made no sense (there's tons of buffers
+ // elsewhere in the chain) and it caused OOM when many concurrent
+ // uploads were being done. Could be fixed by increasing the
evacuation
+ // ratio in bin/jmeter[.bat], but this is better.
+ int read;
+ InputStream in = new FileInputStream(xmlFile);
+ while ((read = in.read(buf)) > 0) {
+ out.write(buf, 0, read);
+ }
+ in.close();
+ out.flush();
+ out.close();
+ } else {
+ PrintWriter out = new PrintWriter(connection.getOutputStream());
+ out.print(getXmlData());
+ out.close();
+ }
}
/*
@@ -142,8 +185,8 @@
setPort(url.getPort());
setProtocol(url.getProtocol());
setMethod(POST);
- if (url.getQuery() != null &&
url.getQuery().compareTo("") != 0) {
- setPath(url.getPath() + "?" + url.getQuery());
+ if (url.getQuery() != null && url.getQuery().length() >
0) {
+ setPath(url.getPath() + "?" + url.getQuery());
//$NON-NLS-1$
} else {
setPath(url.getPath());
}
@@ -163,7 +206,7 @@
sampleResult = new HTTPSampleResult();
sampleResult.setSampleLabel(getName());
}
- sampleResult.setResponseCode("000");
+ sampleResult.setResponseCode("000"); //$NON-NLS-1$
sampleResult.setResponseMessage(ex.getLocalizedMessage());
}
// Bug 39252 set SoapSampler sampler data from XML data
Modified: jakarta/jmeter/branches/rel-2-1/xdocs/changes.xml
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-1/xdocs/changes.xml?rev=408770&r1=408769&r2=408770&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/xdocs/changes.xml (original)
+++ jakarta/jmeter/branches/rel-2-1/xdocs/changes.xml Mon May 22 14:49:11 2006
@@ -102,6 +102,7 @@
<li>Summary Report - similar to Aggregate Report, but uses less memory</li>
<li>Bug 39580 - recycle option for CSV Dataset</li>
<li>Bug 37652 - support for Ajp Tomcat protocol</li>
+<li>Bug 39626 - Loading SOAP/XML-RPC requests from file</li>
</ul>
<h4>Bug fixes:</h4>
Modified:
jakarta/jmeter/branches/rel-2-1/xdocs/images/screenshots/soap_sampler.png
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-1/xdocs/images/screenshots/soap_sampler.png?rev=408770&r1=408769&r2=408770&view=diff
==============================================================================
Binary files - no diff available.
Modified:
jakarta/jmeter/branches/rel-2-1/xdocs/usermanual/component_reference.xml
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-1/xdocs/usermanual/component_reference.xml?rev=408770&r1=408769&r2=408770&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/xdocs/usermanual/component_reference.xml
(original)
+++ jakarta/jmeter/branches/rel-2-1/xdocs/usermanual/component_reference.xml
Mon May 22 14:49:11 2006
@@ -240,7 +240,7 @@
<description><p>This sampler lets you send a SOAP request to a webservice. It
can also be
used to send XML-RPC over HTTP. It creates an HTTP POST request, with the
specified XML as the
-POST content. To change the "Content-type", use the HeaderManager. The sampler
will pick up any
+POST content. To change the "Content-type" from the default of "text/html",
use a HeaderManager. The sampler will pick up any
required headers from the HeaderManager. The primary difference between the
soap sampler and
webservice sampler, is the soap sampler uses raw post and does not require
conformance to
XML.</p>
@@ -250,8 +250,11 @@
<property name="Name" required="No">Descriptive name for this sampler
that is shown in the tree.</property>
<property name="URL" required="Yes">The URL to direct the SOAP request
to.</property>
- <property name="Soap/XML-RPC Data" required="No">The Soap XML message,
or XML-RPC
- instructions.</property>
+ <property name="Send SOAP action" required="No">Send a SOAP action
header? (ignored if there is a HeaderManager)</property>
+ <property name="Soap/XML-RPC Data" required="No">The Soap XML message,
or XML-RPC instructions.
+ Not used if the filename is provided.
+ </property>
+ <property name="Filename" required="No">If specified, then the
contents of the file are sent, and the Data field is ignored</property>
</properties>
</component>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]