You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@jakarta.apache.org by se...@apache.org on 2010/07/06 18:06:40 UTC
svn commit: r960927 - in /jakarta/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/o...
Author: sebb
Date: Tue Jul 6 16:06:40 2010
New Revision: 960927
URL: http://svn.apache.org/viewvc?rev=960927&view=rev
Log:
Bug 49552 - Add Message Headers on SMTPSampler
Modified:
jakarta/jmeter/trunk/docs/images/screenshots/smtp_sampler.png
jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/SmtpSampler.java
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpPanel.java
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpSamplerGui.java
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/protocol/SendMailCommand.java
jakarta/jmeter/trunk/xdocs/changes.xml
jakarta/jmeter/trunk/xdocs/images/screenshots/smtp_sampler.png
jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml
Modified: jakarta/jmeter/trunk/docs/images/screenshots/smtp_sampler.png
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/docs/images/screenshots/smtp_sampler.png?rev=960927&r1=960926&r2=960927&view=diff
==============================================================================
Binary files - no diff available.
Modified: jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties?rev=960927&r1=960926&r2=960927&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties (original)
+++ jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties Tue Jul 6 16:06:40 2010
@@ -824,6 +824,10 @@ smtp_usenone=Use no security features
smtp_username=Username:
smtp_usessl=Use SSL
smtp_usestarttls=Use StartTLS
+smtp_header_add=Add Header
+smtp_header_remove=Remove
+smtp_header_name=Header Name
+smtp_header_value=Header Value
soap_action=Soap Action
soap_data_title=Soap/XML-RPC Data
soap_sampler_title=SOAP/XML-RPC Request
Modified: jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/SmtpSampler.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/SmtpSampler.java?rev=960927&r1=960926&r2=960927&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/SmtpSampler.java (original)
+++ jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/SmtpSampler.java Tue Jul 6 16:06:40 2010
@@ -36,6 +36,7 @@ import org.apache.jmeter.protocol.smtp.s
import org.apache.jmeter.samplers.AbstractSampler;
import org.apache.jmeter.samplers.Entry;
import org.apache.jmeter.samplers.SampleResult;
+import org.apache.jmeter.testelement.property.CollectionProperty;
import org.apache.jorphan.logging.LoggingManager;
import org.apache.log.Logger;
@@ -68,6 +69,7 @@ public class SmtpSampler extends Abstrac
public final static String INCLUDE_TIMESTAMP = "SMTPSampler.include_timestamp"; // $NON-NLS-1$
public final static String ATTACH_FILE = "SMTPSampler.attachFile"; // $NON-NLS-1$
public final static String MESSAGE_SIZE_STATS = "SMTPSampler.messageSizeStatistics"; // $NON-NLS-1$
+ public static final String HEADER_FIELDS = "SMTPSampler.headerFields"; // $NON-NLS-1$
public final static String USE_SSL = "SMTPSampler.useSSL"; // $NON-NLS-1$
public final static String USE_STARTTLS = "SMTPSampler.useStartTLS"; // $NON-NLS-1$
@@ -156,6 +158,7 @@ public class SmtpSampler extends Abstrac
// needed for measuring sending time
instance.setSynchronousMode(true);
+ instance.setHeaderFields((CollectionProperty)getProperty(SmtpSampler.HEADER_FIELDS));
message = instance.prepareMessage();
if (getPropertyAsBoolean(MESSAGE_SIZE_STATS)) {
Modified: jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpPanel.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpPanel.java?rev=960927&r1=960926&r2=960927&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpPanel.java (original)
+++ jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpPanel.java Tue Jul 6 16:06:40 2010
@@ -24,6 +24,9 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
@@ -36,7 +39,10 @@ import javax.swing.JRadioButton;
import javax.swing.JTextArea;
import javax.swing.JTextField;
+import org.apache.jmeter.config.Argument;
import org.apache.jmeter.protocol.smtp.sampler.SmtpSampler;
+import org.apache.jmeter.testelement.property.CollectionProperty;
+import org.apache.jmeter.testelement.property.TestElementProperty;
import org.apache.jmeter.util.JMeterUtils;
/**
@@ -93,6 +99,14 @@ public class SmtpPanel extends JPanel {
private JCheckBox cbMessageSizeStats;
private JCheckBox cbEnableDebug;
private JCheckBox cbUseEmlMessage;
+
+ private JPanel headerFieldsPanel;
+ private JButton addHeaderFieldButton;
+ private JLabel headerFieldName;
+ private JLabel headerFieldValue;
+ private Map<JTextField, JTextField> headerFields = new HashMap<JTextField, JTextField>();
+ private Map<JButton,JTextField> removeButtons = new HashMap<JButton, JTextField>();
+ private int headerGridY = 0;
/**
* Creates new form SmtpPanel, standard constructer. Calls
@@ -528,7 +542,33 @@ public class SmtpPanel extends JPanel {
tfAuthUsername.setText(username);
}
- /**
+ public CollectionProperty getHeaderFields() {
+ CollectionProperty result = new CollectionProperty();
+ result.setName(SmtpSampler.HEADER_FIELDS);
+ for (Iterator<JTextField> iterator = headerFields.keySet().iterator(); iterator.hasNext();) {
+ JTextField headerName = iterator.next();
+ String name = headerName.getText();
+ String value = headerFields.get(headerName).getText();
+ Argument argument = new Argument(name, value);
+ result.addItem(argument);
+ }
+ return result;
+ }
+
+ public void setHeaderFields(CollectionProperty fields) {
+ clearHeaderFields();
+ for (int i = 0; i < fields.size(); i++) {
+ Argument argument = (Argument)((TestElementProperty)fields.get(i)).getObjectValue();
+ String name = argument.getName();
+ JButton removeButton = addHeaderActionPerformed(null);
+ JTextField nameTF = removeButtons.get(removeButton);
+ nameTF.setText(name);
+ JTextField valueTF = headerFields.get(nameTF);
+ valueTF.setText(argument.getValue());
+ }
+ validate();
+ }
+ /**
* Main method of class, builds all gui-components for SMTP-sampler.
*/
private void initComponents() {
@@ -606,6 +646,7 @@ public class SmtpPanel extends JPanel {
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
gridBagConstraints.fill = GridBagConstraints.NONE;
gridBagConstraints.anchor = GridBagConstraints.WEST;
+ gridBagConstraints.weightx = 0.5;
/*
* Server Settings
@@ -707,24 +748,28 @@ public class SmtpPanel extends JPanel {
gridBagConstraints.gridy = 0;
panelAuthSettings.add(cbUseAuth, gridBagConstraints);
- gridBagConstraints.gridx = 0;
- gridBagConstraints.gridy = 1;
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = 0;
gridBagConstraints.gridwidth = 1;
+ gridBagConstraints.weightx = 0;
panelAuthSettings.add(jlUsername, gridBagConstraints);
- gridBagConstraints.gridx = 1;
- gridBagConstraints.gridy = 1;
+ gridBagConstraints.gridx = 2;
+ gridBagConstraints.gridy = 0;
gridBagConstraints.gridwidth = 2;
+ gridBagConstraints.weightx = 0.5;
panelAuthSettings.add(tfAuthUsername, gridBagConstraints);
tfAuthUsername.setEditable(false);
- gridBagConstraints.gridx = 0;
- gridBagConstraints.gridy = 2;
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = 1;
gridBagConstraints.gridwidth = 1;
+ gridBagConstraints.weightx = 0;
panelAuthSettings.add(jlPassword, gridBagConstraints);
- gridBagConstraints.gridx = 1;
- gridBagConstraints.gridy = 2;
+ gridBagConstraints.gridx = 2;
+ gridBagConstraints.gridy = 1;
+ gridBagConstraints.weightx = 0.5;
panelAuthSettings.add(tfAuthPassword, gridBagConstraints);
tfAuthPassword.setEditable(false);
@@ -750,12 +795,12 @@ public class SmtpPanel extends JPanel {
gridBagConstraints.gridy = 0;
panelSecuritySettings.add(rbUseNone, gridBagConstraints);
- gridBagConstraints.gridx = 0;
- gridBagConstraints.gridy = 1;
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = 0;
panelSecuritySettings.add(rbUseSSL, gridBagConstraints);
- gridBagConstraints.gridx = 0;
- gridBagConstraints.gridy = 2;
+ gridBagConstraints.gridx = 2;
+ gridBagConstraints.gridy = 0;
panelSecuritySettings.add(rbUseStartTLS, gridBagConstraints);
rbUseNone.addItemListener(new ItemListener() {
@@ -784,7 +829,7 @@ public class SmtpPanel extends JPanel {
}
});
- gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
panelSecuritySettings.add(cbTrustAllCerts, gridBagConstraints);
@@ -798,8 +843,8 @@ public class SmtpPanel extends JPanel {
});
cbEnforceStartTLS.setToolTipText(JMeterUtils.getResString("smtp_enforcestarttls_tooltip")); // $NON-NLS-1$
- gridBagConstraints.gridx = 1;
- gridBagConstraints.gridy = 2;
+ gridBagConstraints.gridx = 2;
+ gridBagConstraints.gridy = 1;
panelSecuritySettings.add(cbEnforceStartTLS, gridBagConstraints);
cbUseLocalTrustStore.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
@@ -813,18 +858,18 @@ public class SmtpPanel extends JPanel {
cbUseLocalTrustStore.setToolTipText(JMeterUtils.getResString("smtp_usetruststore_tooltip")); // $NON-NLS-1$
- gridBagConstraints.gridx = 0;
- gridBagConstraints.gridy = 5;
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = 1;
gridBagConstraints.gridwidth = 2;
panelSecuritySettings.add(cbUseLocalTrustStore, gridBagConstraints);
gridBagConstraints.gridx = 0;
- gridBagConstraints.gridy = 6;
+ gridBagConstraints.gridy = 2;
gridBagConstraints.gridwidth = 1;
panelSecuritySettings.add(jlTrustStoreToUse, gridBagConstraints);
gridBagConstraints.gridx = 1;
- gridBagConstraints.gridy = 6;
+ gridBagConstraints.gridy = 2;
panelSecuritySettings.add(tfTrustStoreToUse, gridBagConstraints);
gridBagConstraintsMain.gridx = 0;
@@ -845,29 +890,68 @@ public class SmtpPanel extends JPanel {
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 0;
+ gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
panelMessageSettings.add(tfSubject, gridBagConstraints);
cbIncludeTimestamp.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
cbIncludeTimestamp.setMargin(new java.awt.Insets(0, 0, 0, 0));
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 0;
+ gridBagConstraints.fill = GridBagConstraints.NONE;
panelMessageSettings.add(cbIncludeTimestamp, gridBagConstraints);
+ /*
+ * Add the header panel
+ */
+
+ addHeaderFieldButton = new JButton(JMeterUtils.getResString("smtp_header_add"));
+ addHeaderFieldButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ addHeaderActionPerformed(evt);
+ }
+ });
+ headerFieldName = new JLabel(JMeterUtils.getResString("smtp_header_name"));
+ headerFieldValue = new JLabel(JMeterUtils.getResString("smtp_header_value"));
+ headerFieldsPanel = new JPanel(new GridBagLayout());
+
+ headerFieldName.setVisible(false);
+ headerFieldValue.setVisible(false);
+
+ headerGridY=0;
gridBagConstraints.gridx = 0;
- gridBagConstraints.gridy = 1;
+ gridBagConstraints.gridy = headerGridY++;
+ headerFieldsPanel.add(addHeaderFieldButton, gridBagConstraints);
+
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = headerGridY;
+ headerFieldsPanel.add(headerFieldName, gridBagConstraints);
+
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = headerGridY++;
+ headerFieldsPanel.add(headerFieldValue, gridBagConstraints);
+
+ gridBagConstraintsMain.gridx = 1;
+ gridBagConstraintsMain.gridy = 1;
+ panelMessageSettings.add(headerFieldsPanel, gridBagConstraintsMain);
+
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 2;
panelMessageSettings.add(jlMessage, gridBagConstraints);
taMessage.setBorder(BorderFactory.createBevelBorder(1));
gridBagConstraints.gridx = 1;
- gridBagConstraints.gridy = 1;
+ gridBagConstraints.gridy = 2;
+ gridBagConstraints.fill = GridBagConstraints.BOTH;
panelMessageSettings.add(taMessage, gridBagConstraints);
gridBagConstraints.gridx = 0;
- gridBagConstraints.gridy = 2;
+ gridBagConstraints.gridy = 3;
+ gridBagConstraints.fill = GridBagConstraints.NONE;
panelMessageSettings.add(jlAttachFile, gridBagConstraints);
gridBagConstraints.gridx = 1;
- gridBagConstraints.gridy = 2;
+ gridBagConstraints.gridy = 3;
+ gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
panelMessageSettings.add(tfAttachment, gridBagConstraints);
tfAttachment.setToolTipText(JMeterUtils.getResString("smtp_attach_file_tooltip")); // $NON-NLS-1$
@@ -878,7 +962,8 @@ public class SmtpPanel extends JPanel {
});
gridBagConstraints.gridx = 2;
- gridBagConstraints.gridy = 2;
+ gridBagConstraints.gridy = 3;
+ gridBagConstraints.fill = GridBagConstraints.NONE;
panelMessageSettings.add(browseButton, gridBagConstraints);
cbUseEmlMessage.setSelected(false);
@@ -889,11 +974,13 @@ public class SmtpPanel extends JPanel {
});
gridBagConstraints.gridx = 0;
- gridBagConstraints.gridy = 3;
+ gridBagConstraints.gridy = 4;
+ gridBagConstraints.fill = GridBagConstraints.NONE;
panelMessageSettings.add(cbUseEmlMessage, gridBagConstraints);
gridBagConstraints.gridx = 1;
- gridBagConstraints.gridy = 3;
+ gridBagConstraints.gridy = 4;
+ gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
tfEmlMessage.setEnabled(false);
panelMessageSettings.add(tfEmlMessage, gridBagConstraints);
@@ -905,11 +992,12 @@ public class SmtpPanel extends JPanel {
emlBrowseButton.setEnabled(false);
gridBagConstraints.gridx = 2;
- gridBagConstraints.gridy = 3;
+ gridBagConstraints.gridy = 4;
+ gridBagConstraints.fill = GridBagConstraints.NONE;
panelMessageSettings.add(emlBrowseButton, gridBagConstraints);
gridBagConstraintsMain.gridx = 0;
- gridBagConstraintsMain.gridy = 4;
+ gridBagConstraintsMain.gridy = 5;
add(panelMessageSettings, gridBagConstraintsMain);
/*
@@ -932,7 +1020,7 @@ public class SmtpPanel extends JPanel {
panelAdditionalSettings.add(cbEnableDebug, gridBagConstraints);
gridBagConstraintsMain.gridx = 0;
- gridBagConstraintsMain.gridy = 5;
+ gridBagConstraintsMain.gridy = 6;
add(panelAdditionalSettings, gridBagConstraintsMain);
}
@@ -1122,6 +1210,85 @@ public class SmtpPanel extends JPanel {
tfSubject.setText("");
tfTrustStoreToUse.setText("");
rbUseNone.setSelected(true);
+ clearHeaderFields();
+ validate();
}
+ private void clearHeaderFields() {
+ headerFieldName.setVisible(false);
+ headerFieldValue.setVisible(false);
+
+ for (Iterator<JButton> iterator = removeButtons.keySet().iterator(); iterator.hasNext();) {
+ JButton removeButton = iterator.next();
+ JTextField headerName = removeButtons.get(removeButton);
+ JTextField headerValue = headerFields.get(headerName);
+
+ headerFieldsPanel.remove(headerName);
+ if (headerValue != null){ // Can be null (not sure why)
+ headerFieldsPanel.remove(headerValue);
+ }
+ headerFieldsPanel.remove(removeButton);
+ headerFields.remove(headerName);
+ iterator.remove();
+ }
+ }
+
+ private JButton addHeaderActionPerformed(ActionEvent evt){
+ if(headerFields.size() == 0){
+ headerFieldName.setVisible(true);
+ headerFieldValue.setVisible(true);
+ }
+ JTextField nameTF = new JTextField();
+ JTextField valueTF = new JTextField();
+ JButton removeButton = new JButton(JMeterUtils.getResString("smtp_header_remove"));
+ headerFields.put(nameTF, valueTF);
+ removeButtons.put(removeButton, nameTF);
+
+ removeButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ removeHeaderActionPerformed(evt);
+ }
+ });
+
+ GridBagConstraints gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
+ gridBagConstraints.weightx = 0.5;
+ gridBagConstraints.anchor = GridBagConstraints.WEST;
+
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = headerGridY;
+ gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
+ headerFieldsPanel.add(nameTF, gridBagConstraints);
+
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = headerGridY;
+ gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
+ headerFieldsPanel.add(valueTF, gridBagConstraints);
+
+ gridBagConstraints.gridx = 2;
+ gridBagConstraints.gridy = headerGridY++;
+ gridBagConstraints.fill = GridBagConstraints.NONE;
+ headerFieldsPanel.add(removeButton, gridBagConstraints);
+
+ validate();
+ return removeButton;
+ }
+
+ private void removeHeaderActionPerformed(ActionEvent evt){
+ final Object source = evt.getSource();
+ if(source != null && source instanceof JButton){
+ if(headerFields.size() == 1){
+ headerFieldName.setVisible(false);
+ headerFieldValue.setVisible(false);
+ }
+ JTextField nameTF = removeButtons.get(source);
+ JTextField valueTF = headerFields.get(nameTF);
+ headerFields.remove(nameTF);
+
+ headerFieldsPanel.remove(nameTF);
+ headerFieldsPanel.remove(valueTF);
+ headerFieldsPanel.remove((JButton)source);
+ validate();
+ }
+ }
}
\ No newline at end of file
Modified: jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpSamplerGui.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpSamplerGui.java?rev=960927&r1=960926&r2=960927&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpSamplerGui.java (original)
+++ jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpSamplerGui.java Tue Jul 6 16:06:40 2010
@@ -25,6 +25,8 @@ import java.awt.Component;
import org.apache.jmeter.protocol.smtp.sampler.SmtpSampler;
import org.apache.jmeter.samplers.gui.AbstractSamplerGui;
import org.apache.jmeter.testelement.TestElement;
+import org.apache.jmeter.testelement.property.CollectionProperty;
+import org.apache.jmeter.testelement.property.JMeterProperty;
/**
* Class to build superstructure-gui for SMTP-panel, sets/gets value for a JMeter's testElement-object (i.e. also for save/load-purposes).
@@ -61,9 +63,9 @@ public class SmtpSamplerGui extends Abst
*/
@Override
public void configure(TestElement element) {
- if (smtpPanel == null)
+ if (smtpPanel == null){
smtpPanel = new SmtpPanel();
-
+ }
smtpPanel.setServer(element.getPropertyAsString(SmtpSampler.SERVER));
smtpPanel.setPort(element.getPropertyAsString(SmtpSampler.SERVER_PORT));
smtpPanel.setMailFrom(element.getPropertyAsString(SmtpSampler.MAIL_FROM));
@@ -74,6 +76,12 @@ public class SmtpSamplerGui extends Abst
smtpPanel.setBody(element.getPropertyAsString(SmtpSampler.MESSAGE));
smtpPanel.setSubject(element.getPropertyAsString(SmtpSampler.SUBJECT));
smtpPanel.setIncludeTimestamp(element.getPropertyAsBoolean(SmtpSampler.INCLUDE_TIMESTAMP));
+ JMeterProperty headers = element.getProperty(SmtpSampler.HEADER_FIELDS);
+ if (headers instanceof CollectionProperty) { // Might be NullProperty
+ smtpPanel.setHeaderFields((CollectionProperty)headers);
+ } else {
+ smtpPanel.setHeaderFields(new CollectionProperty());
+ }
smtpPanel.setAttachments(element.getPropertyAsString(SmtpSampler.ATTACH_FILE));
smtpPanel.setUseEmlMessage(element.getPropertyAsBoolean(SmtpSampler.USE_EML));
@@ -145,6 +153,8 @@ public class SmtpSamplerGui extends Abst
te.setProperty(SmtpSampler.MESSAGE_SIZE_STATS, Boolean.toString(smtpPanel.isMessageSizeStatistics()));
te.setProperty(SmtpSampler.ENABLE_DEBUG, Boolean.toString(smtpPanel.isEnableDebug()));
+
+ te.setProperty(smtpPanel.getHeaderFields());
}
/**
Modified: jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/protocol/SendMailCommand.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/protocol/SendMailCommand.java?rev=960927&r1=960926&r2=960927&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/protocol/SendMailCommand.java (original)
+++ jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/protocol/SendMailCommand.java Tue Jul 6 16:06:40 2010
@@ -22,7 +22,6 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
import java.util.Properties;
@@ -39,7 +38,10 @@ import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
+import org.apache.jmeter.config.Argument;
import org.apache.jmeter.services.FileServer;
+import org.apache.jmeter.testelement.property.CollectionProperty;
+import org.apache.jmeter.testelement.property.TestElementProperty;
import org.apache.jorphan.logging.LoggingManager;
import org.apache.log.Logger;
@@ -70,7 +72,7 @@ public class SendMailCommand {
private List<InternetAddress> receiverTo;
private List<InternetAddress> receiverCC;
private List<InternetAddress> receiverBCC;
- private HashMap<String, String> headers; // Not currently set up
+ private CollectionProperty headerFields;
private String subject = "";
private boolean useAuthentication = false;
@@ -96,7 +98,7 @@ public class SendMailCommand {
* Standard-Constructor
*/
public SendMailCommand() {
- headers = new HashMap<String, String>();
+ headerFields = new CollectionProperty();
attachments = new ArrayList<File>();
}
@@ -211,8 +213,9 @@ public class SendMailCommand {
message.setRecipients(Message.RecipientType.BCC, bcc);
}
- for (String key : headers.keySet()) {
- message.setHeader(key, headers.get(key));
+ for (int i = 0; i < headerFields.size(); i++) {
+ Argument argument = (Argument)((TestElementProperty)headerFields.get(i)).getObjectValue();
+ message.setHeader(argument.getName(), argument.getValue());
}
message.saveChanges();
@@ -545,20 +548,20 @@ public class SendMailCommand {
/**
* Returns headers for current message - standard getter
*
- * @return HashMap of headers for current message
+ * @return CollectionProperty of headers for current message
*/
- public HashMap<String, String> getHeaders() {
- return headers;
+ public CollectionProperty getHeaders() {
+ return headerFields;
}
/**
* Sets headers for current message
*
- * @param headers
- * HashMap of headers for current message
+ * @param headerFields
+ * CollectionProperty of headers for current message
*/
- public void setHeaders(HashMap<String, String> headers) {
- this.headers = headers;
+ public void setHeaderFields(CollectionProperty headerFields) {
+ this.headerFields = headerFields;
}
/**
@@ -571,19 +574,22 @@ public class SendMailCommand {
* Value for current header
*/
public void addHeader(String headerName, String headerValue) {
- if (this.headers == null)
- this.headers = new HashMap<String, String>();
- this.headers.put(headerName, headerValue);
+ if (this.headerFields == null){
+ this.headerFields = new CollectionProperty();
+ }
+ Argument argument = new Argument(headerName, headerValue);
+ this.headerFields.addItem(argument);
}
/**
* Deletes all current headers in HashMap
*/
public void clearHeaders() {
- if (this.headers == null)
- this.headers = new HashMap<String, String>();
- else
- this.headers.clear();
+ if (this.headerFields == null){
+ this.headerFields = new CollectionProperty();
+ }else{
+ this.headerFields.clear();
+ }
}
/**
Modified: jakarta/jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/changes.xml?rev=960927&r1=960926&r2=960927&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/changes.xml (original)
+++ jakarta/jmeter/trunk/xdocs/changes.xml Tue Jul 6 16:06:40 2010
@@ -173,6 +173,8 @@ This does not affect existing test plans
<li>Bug 47947 - Mail Reader Sampler should allow port to be overridden</li>
<li>Bug 48155 - Multiple problems / enhancements with JMS protocol classes</li>
<li>Allow MailReader sampler to use arbitrary protocols</li>
+<li>Bug 45053 - SMTP-Sampler for JMeter</li>
+<li>Bug 49552 - Add Message Headers on SMTPSampler</li>
<li>
JMS Publisher and Subscriber now support both Topics and Queues.
Added read Timeout to JMS Subscriber.
Modified: jakarta/jmeter/trunk/xdocs/images/screenshots/smtp_sampler.png
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/images/screenshots/smtp_sampler.png?rev=960927&r1=960926&r2=960927&view=diff
==============================================================================
Binary files - no diff available.
Modified: jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml?rev=960927&r1=960926&r2=960927&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
+++ jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml Tue Jul 6 16:06:40 2010
@@ -1492,7 +1492,7 @@ In non-GUI mode, JMeter will exit if som
</component>
-<component name="SMTP Sampler" index="§-num;.1.19" width="644" height="810" screenshot="smtp_sampler.png">
+<component name="SMTP Sampler" index="§-num;.1.19" width="644" height="759" screenshot="smtp_sampler.png">
<description>
<p>
The SMTP Sampler can send mail messages using SMTP/SMTPS protocol.
@@ -1526,6 +1526,7 @@ Defaults are: SMTP=25, SSL=465, StartTLS
<property name="Local truststore" required="">Local file containing the trusted certificates.</property>
<property name="Subject" required="">The e-mail message subject.</property>
<property name="Include timestamp in subject" required="">Includes the System.currentTimemilis() in the subject line.</property>
+<property name="Add Header" required="No">Additional headers can be defined using this button.</property>
<property name="Message" required="">The message body.</property>
<property name="Attach files" required="">Files to be attached to the message.</property>
<property name="Send .eml" required="">If set, the .eml file will be sent instead of the entries in the Subject, Message, and Attached files</property>
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@jakarta.apache.org
For additional commands, e-mail: notifications-help@jakarta.apache.org