You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by mi...@apache.org on 2014/01/19 20:09:35 UTC
svn commit: r1559557 - in /jmeter/trunk: docs/images/screenshots/
src/core/org/apache/jmeter/resources/
src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/
src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/
src/protocol/mail/org/apac...
Author: milamber
Date: Sun Jan 19 19:09:35 2014
New Revision: 1559557
URL: http://svn.apache.org/r1559557
Log:
Add Connection timeout and Read timeout to SMTP Sampler
Bugzilla Id: 56033
Modified:
jmeter/trunk/docs/images/screenshots/smtp_sampler.png
jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties
jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/SmtpSampler.java
jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpPanel.java
jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpSamplerGui.java
jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/protocol/SendMailCommand.java
jmeter/trunk/xdocs/changes.xml
jmeter/trunk/xdocs/images/screenshots/smtp_sampler.png
jmeter/trunk/xdocs/usermanual/component_reference.xml
Modified: jmeter/trunk/docs/images/screenshots/smtp_sampler.png
URL: http://svn.apache.org/viewvc/jmeter/trunk/docs/images/screenshots/smtp_sampler.png?rev=1559557&r1=1559556&r2=1559557&view=diff
==============================================================================
Binary files - no diff available.
Modified: jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties?rev=1559557&r1=1559556&r2=1559557&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties Sun Jan 19 19:09:35 2014
@@ -992,6 +992,9 @@ smtp_security_settings=Security settings
smtp_server=Server:
smtp_server_port=Port:
smtp_server_settings=Server settings
+smtp_server_connection_timeout=Connection timeout:
+smtp_server_timeout=Read timeout:
+smtp_server_timeouts_settings=Timeouts (milliseconds)
smtp_subject=Subject:
smtp_suppresssubj=Suppress Subject Header
smtp_timestamp=Include timestamp in subject
Modified: jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties?rev=1559557&r1=1559556&r2=1559557&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties Sun Jan 19 19:09:35 2014
@@ -1,4 +1,3 @@
-
# 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.
@@ -986,6 +985,9 @@ smtp_security_settings=Param\u00E8tres d
smtp_server=Serveur \:
smtp_server_port=Port \:
smtp_server_settings=Param\u00E8tres du serveur
+smtp_server_connection_timeout=D\u00E9lai d'attente de connexion :
+smtp_server_timeout=D\u00E9lai d'attente de r\u00E9ponse :
+smtp_server_timeouts_settings=D\u00E9lais d'attente (milli-secondes)
smtp_subject=Sujet \:
smtp_suppresssubj=Supprimer l'ent\u00EAte Sujet (Subject)
smtp_timestamp=Ajouter un horodatage dans le sujet
Modified: jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/SmtpSampler.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/SmtpSampler.java?rev=1559557&r1=1559556&r2=1559557&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/SmtpSampler.java (original)
+++ jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/SmtpSampler.java Sun Jan 19 19:09:35 2014
@@ -75,6 +75,8 @@ public class SmtpSampler extends Abstrac
public static final String SERVER_PORT = "SMTPSampler.serverPort"; // $NON-NLS-1$
+ public static final String SERVER_TIMEOUT = "SMTPSampler.serverTimeout"; // $NON-NLS-1$
+ public static final String SERVER_CONNECTION_TIMEOUT = "SMTPSampler.serverConnectionTimeout"; // $NON-NLS-1$
public static final String USE_AUTH = "SMTPSampler.useAuth"; // $NON-NLS-1$
public static final String USERNAME = "SMTPSampler.username"; // $NON-NLS-1$
public static final String PASSWORD = "SMTPSampler.password"; // $NON-NLS-1$
@@ -122,6 +124,8 @@ public class SmtpSampler extends Abstrac
SendMailCommand instance = new SendMailCommand();
instance.setSmtpServer(getPropertyAsString(SmtpSampler.SERVER));
instance.setSmtpPort(getPropertyAsString(SmtpSampler.SERVER_PORT));
+ instance.setConnectionTimeOut(getPropertyAsString(SmtpSampler.SERVER_CONNECTION_TIMEOUT));
+ instance.setTimeOut(getPropertyAsString(SmtpSampler.SERVER_TIMEOUT));
instance.setUseSSL(getPropertyAsBoolean(SecuritySettingsPanel.USE_SSL));
instance.setUseStartTLS(getPropertyAsBoolean(SecuritySettingsPanel.USE_STARTTLS));
Modified: jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpPanel.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpPanel.java?rev=1559557&r1=1559556&r2=1559557&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpPanel.java (original)
+++ jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpPanel.java Sun Jan 19 19:09:35 2014
@@ -18,6 +18,7 @@
package org.apache.jmeter.protocol.smtp.sampler.gui;
+import java.awt.BorderLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
@@ -40,6 +41,8 @@ import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import org.apache.jmeter.config.Argument;
+import org.apache.jmeter.gui.util.HorizontalPanel;
+import org.apache.jmeter.gui.util.VerticalPanel;
import org.apache.jmeter.protocol.smtp.sampler.SmtpSampler;
import org.apache.jmeter.testelement.property.CollectionProperty;
import org.apache.jmeter.testelement.property.TestElementProperty;
@@ -62,6 +65,8 @@ public class SmtpPanel extends JPanel {
private JCheckBox cbUseAuth;
private JTextField tfMailServer;
private JTextField tfMailServerPort;
+ private JTextField tfMailServerTimeout;
+ private JTextField tfMailServerConnectionTimeout;
private JTextField tfMailTo;
private JTextField tfMailToCC;
private JTextField tfMailToBCC;
@@ -76,6 +81,8 @@ public class SmtpPanel extends JPanel {
private JLabel jlAddressToCC;
private JLabel jlAddressToBCC;
private JLabel jlMailServerPort;
+ private JLabel jlMailServerTimeout;
+ private JLabel jlMailServerConnectionTimeout;
private JLabel jlMailServer;
private JLabel jlAttachFile;
private JLabel jlDutPortStandard;
@@ -267,6 +274,44 @@ public class SmtpPanel extends JPanel {
}
/**
+ * Returns timeout for SMTP connection from textfield
+ *
+ * @return Smtp timeout
+ */
+ public String getTimeout() {
+ return tfMailServerTimeout.getText();
+ }
+
+ /**
+ * Sets timeout (ms) for SMTP connection
+ *
+ * @param timeout
+ * SMTP Timeout (ms)
+ */
+ public void setTimeout(String timeout) {
+ tfMailServerTimeout.setText(timeout);
+ }
+
+ /**
+ * Returns connection timeout for SMTP connection from textfield
+ *
+ * @return SMTP connection timeout
+ */
+ public String getConnectionTimeout() {
+ return tfMailServerConnectionTimeout.getText();
+ }
+
+ /**
+ * Sets connection timeout (ms) for SMTP connection
+ *
+ * @param connectionTimeout
+ * SMTP Connection Timeout (ms)
+ */
+ public void setConnectionTimeout(String connectionTimeout) {
+ tfMailServerConnectionTimeout.setText(connectionTimeout);
+ }
+
+ /**
* Returns subject of the e-mail from textfield
*
* @return Subject of e-mail
@@ -499,6 +544,8 @@ public class SmtpPanel extends JPanel {
jlAddressToBCC = new JLabel(JMeterUtils.getResString("smtp_bcc")); // $NON-NLS-1$
jlMailServerPort = new JLabel(JMeterUtils.getResString("smtp_server_port")); // $NON-NLS-1$
jlMailServer = new JLabel(JMeterUtils.getResString("smtp_server")); // $NON-NLS-1$
+ jlMailServerTimeout = new JLabel(JMeterUtils.getResString("smtp_server_timeout")); // $NON-NLS-1$
+ jlMailServerConnectionTimeout = new JLabel(JMeterUtils.getResString("smtp_server_connection_timeout")); // $NON-NLS-1$
jlAttachFile = new JLabel(JMeterUtils.getResString("smtp_attach_file")); // $NON-NLS-1$
jlDutPortStandard = new JLabel(JMeterUtils.getResString("smtp_default_port")); // $NON-NLS-1$
jlUsername = new JLabel(JMeterUtils.getResString("smtp_username")); // $NON-NLS-1$
@@ -508,6 +555,8 @@ public class SmtpPanel extends JPanel {
tfMailServer = new JTextField(30);
tfMailServerPort = new JTextField(6);
+ tfMailServerTimeout = new JTextField(6);
+ tfMailServerConnectionTimeout = new JTextField(6);
tfMailFrom = new JTextField(25);
tfMailReplyTo = new JTextField(25);
tfMailTo = new JTextField(25);
@@ -575,39 +624,42 @@ public class SmtpPanel extends JPanel {
/*
* Server Settings
*/
- JPanel panelServerSettings = new JPanel(new GridBagLayout());
- panelServerSettings.setBorder(BorderFactory.createTitledBorder(
- BorderFactory.createEtchedBorder(),
+ JPanel panelServerSettings = new VerticalPanel();
+ panelServerSettings.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
JMeterUtils.getResString("smtp_server_settings"))); // $NON-NLS-1$
+
+ JPanel panelMailServer = new JPanel(new BorderLayout(5, 0));
+ panelMailServer.add(jlMailServer, BorderLayout.WEST);
+ panelMailServer.add(tfMailServer, BorderLayout.CENTER);
+ JPanel panelMailServerPort = new JPanel(new BorderLayout(5, 0));
+ panelMailServerPort.add(jlMailServerPort, BorderLayout.WEST);
+ panelMailServerPort.add(tfMailServerPort, BorderLayout.CENTER);
+ panelMailServerPort.add(jlDutPortStandard, BorderLayout.EAST);
+
+ panelServerSettings.add(panelMailServer, BorderLayout.CENTER);
+ panelServerSettings.add(panelMailServerPort, BorderLayout.SOUTH);
- gridBagConstraints.gridx = 0;
- gridBagConstraints.gridy = 0;
- panelServerSettings.add(jlMailServer, gridBagConstraints);
-
- gridBagConstraints.gridx = 1;
- gridBagConstraints.gridy = 0;
- panelServerSettings.add(tfMailServer, gridBagConstraints);
-
- gridBagConstraints.gridx = 0;
- gridBagConstraints.gridy = 1;
- panelServerSettings.add(jlMailServerPort, gridBagConstraints);
-
- JPanel panelServerPortSettings = new JPanel(new GridBagLayout());
- gridBagConstraints.gridx = 0;
- gridBagConstraints.gridy = 0;
- panelServerPortSettings.add(tfMailServerPort, gridBagConstraints);
-
- gridBagConstraints.gridx = 1;
- gridBagConstraints.gridy = 0;
- panelServerPortSettings.add(jlDutPortStandard, gridBagConstraints);
+ JPanel panelServerTimeoutsSettings = new VerticalPanel();
+ panelServerTimeoutsSettings.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
+ JMeterUtils.getResString("smtp_server_timeouts_settings"))); // $NON-NLS-1$
+
+ JPanel panelMailServerConnectionTimeout = new JPanel(new BorderLayout(5, 0));
+ panelMailServerConnectionTimeout.add(jlMailServerConnectionTimeout, BorderLayout.WEST);
+ panelMailServerConnectionTimeout.add(tfMailServerConnectionTimeout, BorderLayout.CENTER);
+ JPanel panelMailServerTimeout = new JPanel(new BorderLayout(5, 0));
+ panelMailServerTimeout.add(jlMailServerTimeout, BorderLayout.WEST);
+ panelMailServerTimeout.add(tfMailServerTimeout, BorderLayout.CENTER);
+
+ panelServerTimeoutsSettings.add(panelMailServerConnectionTimeout, BorderLayout.CENTER);
+ panelServerTimeoutsSettings.add(panelMailServerTimeout, BorderLayout.SOUTH);
- gridBagConstraints.gridx = 1;
- gridBagConstraints.gridy = 1;
- panelServerSettings.add(panelServerPortSettings, gridBagConstraints);
+ JPanel panelServerConfig = new HorizontalPanel();
+ panelServerConfig.add(panelServerSettings, BorderLayout.CENTER);
+ panelServerConfig.add(panelServerTimeoutsSettings, BorderLayout.EAST);
gridBagConstraintsMain.gridx = 0;
gridBagConstraintsMain.gridy = 0;
- add(panelServerSettings, gridBagConstraintsMain);
+ add(panelServerConfig, gridBagConstraintsMain);
/*
* E-Mail Settings
@@ -1000,6 +1052,8 @@ public class SmtpPanel extends JPanel {
tfMailReplyTo.setText("");
tfMailServer.setText("");
tfMailServerPort.setText("");
+ tfMailServerConnectionTimeout.setText("");
+ tfMailServerTimeout.setText("");
tfMailTo.setText("");
tfMailToBCC.setText("");
tfMailToCC.setText("");
Modified: jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpSamplerGui.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpSamplerGui.java?rev=1559557&r1=1559556&r2=1559557&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpSamplerGui.java (original)
+++ jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpSamplerGui.java Sun Jan 19 19:09:35 2014
@@ -69,6 +69,8 @@ public class SmtpSamplerGui extends Abst
}
smtpPanel.setServer(element.getPropertyAsString(SmtpSampler.SERVER));
smtpPanel.setPort(element.getPropertyAsString(SmtpSampler.SERVER_PORT));
+ smtpPanel.setTimeout(element.getPropertyAsString(SmtpSampler.SERVER_TIMEOUT));
+ smtpPanel.setConnectionTimeout(element.getPropertyAsString(SmtpSampler.SERVER_CONNECTION_TIMEOUT));
smtpPanel.setMailFrom(element.getPropertyAsString(SmtpSampler.MAIL_FROM));
smtpPanel.setMailReplyTo(element.getPropertyAsString(SmtpSampler.MAIL_REPLYTO));
smtpPanel.setReceiverTo(element.getPropertyAsString(SmtpSampler.RECEIVER_TO));
@@ -127,6 +129,8 @@ public class SmtpSamplerGui extends Abst
super.configureTestElement(te);
te.setProperty(SmtpSampler.SERVER, smtpPanel.getServer());
te.setProperty(SmtpSampler.SERVER_PORT, smtpPanel.getPort());
+ te.setProperty(SmtpSampler.SERVER_TIMEOUT, smtpPanel.getTimeout());
+ te.setProperty(SmtpSampler.SERVER_CONNECTION_TIMEOUT, smtpPanel.getConnectionTimeout());
te.setProperty(SmtpSampler.MAIL_FROM, smtpPanel.getMailFrom());
te.setProperty(SmtpSampler.MAIL_REPLYTO, smtpPanel.getMailReplyTo());
te.setProperty(SmtpSampler.RECEIVER_TO, smtpPanel.getReceiverTo());
Modified: jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/protocol/SendMailCommand.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/protocol/SendMailCommand.java?rev=1559557&r1=1559556&r2=1559557&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/protocol/SendMailCommand.java (original)
+++ jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/protocol/SendMailCommand.java Sun Jan 19 19:09:35 2014
@@ -90,6 +90,9 @@ public class SendMailCommand {
private String mailBody;
+ private String timeOut; // Socket read timeout value in milliseconds. This timeout is implemented by java.net.Socket.
+ private String connectionTimeOut; // Socket connection timeout value in milliseconds. This timeout is implemented by java.net.Socket.
+
// case we are measuring real time of spedition
private boolean synchronousMode;
@@ -126,6 +129,10 @@ public class SendMailCommand {
props.setProperty("mail." + protocol + ".host", smtpServer);
props.setProperty("mail." + protocol + ".port", getPort());
props.setProperty("mail." + protocol + ".auth", Boolean.toString(useAuthentication));
+
+ // set timeout
+ props.setProperty("mail." + protocol + ".timeout", getTimeout());
+ props.setProperty("mail." + protocol + ".connectiontimeout", getConnectionTimeout());
if (enableDebug) {
props.setProperty("mail.debug","true");
@@ -709,6 +716,48 @@ public class SendMailCommand {
}
/**
+ * @param timeOut the timeOut to set
+ */
+ public void setTimeOut(String timeOut) {
+ this.timeOut = timeOut;
+ }
+
+ /**
+ * Returns timeout for the SMTP-connection - returns the
+ * default timeout if no value has been supplied.
+ *
+ * @return Timeout to be set for SMTP-connection
+ */
+ public String getTimeout() {
+ String timeout = timeOut.trim();
+ if (timeout.length() > 0) { // OK, it has been supplied
+ return timeout;
+ }
+ return "0"; // Default is infinite timeout (value 0).
+ }
+
+ /**
+ * @param connectionTimeOut the connectionTimeOut to set
+ */
+ public void setConnectionTimeOut(String connectionTimeOut) {
+ this.connectionTimeOut = connectionTimeOut;
+ }
+
+ /**
+ * Returns connection timeout for the SMTP-connection - returns the
+ * default connection timeout if no value has been supplied.
+ *
+ * @return Connection timeout to be set for SMTP-connection
+ */
+ public String getConnectionTimeout() {
+ String connectionTimeout = connectionTimeOut.trim();
+ if (connectionTimeout.length() > 0) { // OK, it has been supplied
+ return connectionTimeout;
+ }
+ return "0"; // Default is infinite timeout (value 0).
+ }
+
+ /**
* Assigns the object to use a local truststore for SSL / StartTLS - to be
* called by SmtpSampler-object
*
Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1559557&r1=1559556&r2=1559557&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Sun Jan 19 19:09:35 2014
@@ -166,6 +166,7 @@ A workaround is to use a Java 7 update 4
<h3>Other samplers</h3>
<ul>
+<li><bugzilla>Bug 56033</bugzilla> - Add Connection timeout and Read timeout to SMTP Sampler</li>
</ul>
<h3>Controllers</h3>
Modified: jmeter/trunk/xdocs/images/screenshots/smtp_sampler.png
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/images/screenshots/smtp_sampler.png?rev=1559557&r1=1559556&r2=1559557&view=diff
==============================================================================
Binary files - no diff available.
Modified: jmeter/trunk/xdocs/usermanual/component_reference.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/component_reference.xml?rev=1559557&r1=1559556&r2=1559557&view=diff
==============================================================================
--- jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
+++ jmeter/trunk/xdocs/usermanual/component_reference.xml Sun Jan 19 19:09:35 2014
@@ -1794,7 +1794,7 @@ In non-GUI mode, JMeter will exit if som
</component>
-<component name="SMTP Sampler" index="§-num;.1.19" width="713" height="802" screenshot="smtp_sampler.png">
+<component name="SMTP Sampler" index="§-num;.1.19" width="825" height="728" screenshot="smtp_sampler.png">
<description>
<p>
The SMTP Sampler can send mail messages using SMTP/SMTPS protocol.
@@ -1812,6 +1812,8 @@ Two alternatives to handle this verifica
<property name="Port" required="No">Port to be used to connect to the server.
Defaults are: SMTP=25, SSL=465, StartTLS=587
</property>
+<property name="Connection timeout" required="No">Connection timeout value in milliseconds (socket level). Default is infinite timeout.</property>
+<property name="Read timeout" required="No">Read timeout value in milliseconds (socket level). Default is infinite timeout.</property>
<property name="Address From" required="Yes">The from address that will appear in the e-mail</property>
<property name="Address To" required="Yes, unless CC or BCC is specified">The destination e-mail address (multiple values separated by ";")</property>
<property name="Address To CC" required="No">Carbon copy destinations e-mail address (multiple values separated by ";")</property>