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/01 16:34:35 UTC
svn commit: r959681 [1/2] - in /jakarta/jmeter/trunk:
docs/images/screenshots/ src/core/org/apache/jmeter/resources/
src/protocol/mail/org/apache/jmeter/protocol/smtp/
src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/
src/protocol/mail/org/apa...
Author: sebb
Date: Thu Jul 1 14:34:35 2010
New Revision: 959681
URL: http://svn.apache.org/viewvc?rev=959681&view=rev
Log:
Bug 45053 - SMTP-Sampler for JMeter
Initial version from BZ, plus local changes:
- dropped references to BouncyCastle
- use resources rather than fixed strings
- minimize visibility of fields
- tab and layout police
Added:
jakarta/jmeter/trunk/docs/images/screenshots/smtp_sampler.png (with props)
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/SmtpSampler.java (with props)
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpPanel.java (with props)
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpSamplerGui.java (with props)
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/protocol/
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/protocol/MailBodyProvider.java (with props)
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/protocol/SendMailCommand.java (with props)
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/protocol/SynchronousTransportListener.java (with props)
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/protocol/TrustAllSSLSocketFactory.java (with props)
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/tools/
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/tools/CounterOutputStream.java (with props)
jakarta/jmeter/trunk/xdocs/images/screenshots/smtp_sampler.png (with props)
Modified:
jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml
Added: 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=959681&view=auto
==============================================================================
Binary file - no diff available.
Propchange: jakarta/jmeter/trunk/docs/images/screenshots/smtp_sampler.png
------------------------------------------------------------------------------
svn:mime-type = image/png
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=959681&r1=959680&r2=959681&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 Thu Jul 1 14:34:35 2010
@@ -789,7 +789,40 @@ smime_assertion_signer_no_check=No check
smime_assertion_signer_serial=Serial Number
smime_assertion_title=SMIME Assertion
smime_assertion_verify_signature=Verify signature
+smtp_additional_settings=Additional Settings
+smtp_attach_file=Attach file(s):
+smtp_attach_file_tooltip=Separate multiple files with ";"
+smtp_auth_settings=Auth settings
+smtp_bcc=Address To BCC:
+smtp_cc=Address To CC:
+smtp_default_port=(Default: 25)
+smtp_eml=Send .eml:
+smtp_enforcestarttls=Enforce StartTLS
+smtp_enforcestarttls_tooltip=<html><b>Enforces</b> the server to use StartTLS.<br />If not selected and the SMTP-Server doesn't support StartTLS, <br />a normal SMTP-Connection will be used as fallback instead. <br /><i>Please note</i> that this checkbox creates a file in \"/tmp/\", <br />so this will cause problems under windows.</html>
+smtp_from=Address From:
+smtp_mail_settings=Mail settings
+smtp_message=Message:
+smtp_message_settings=Message settings
+smtp_messagesize=Calculate message size
+smtp_password=Password:
smtp_sampler_title=SMTP Sampler
+smtp_security_settings=Security settings
+smtp_server_port=Port:
+smtp_server=Server:
+smtp_server_settings=Server settings
+smtp_subject=Subject:
+smtp_to=Address To:
+smtp_timestamp=Include timestamp in subject
+smtp_trustall=Trust all certificates
+smtp_trustall_tooltip=<html><b>Enforces</b> JMeter to trust all certificates, whatever CA it comes from. <br />If not selected, you should install the server certificate manually <br />(using the corresponding option below)</html>
+smtp_truststore=Local truststore:
+smtp_useauth=Use Auth
+smtp_usetruststore=Use local truststore
+smtp_usetruststore_tooltip=<html><b>Please note:</b></html>
+smtp_usenone=Use no security features
+smtp_username=Username:
+smtp_usessl=Use SSL
+smtp_usestarttls=Use StartTLS
soap_action=Soap Action
soap_data_title=Soap/XML-RPC Data
soap_sampler_title=SOAP/XML-RPC Request
Added: 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=959681&view=auto
==============================================================================
--- jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/SmtpSampler.java (added)
+++ jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/SmtpSampler.java Thu Jul 1 14:34:35 2010
@@ -0,0 +1,431 @@
+/*
+ * 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.smtp.sampler;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Date;
+import java.util.List;
+import java.util.Vector;
+
+import javax.mail.AuthenticationFailedException;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.internet.AddressException;
+import javax.mail.internet.InternetAddress;
+
+import org.apache.jmeter.protocol.smtp.sampler.protocol.MailBodyProvider;
+import org.apache.jmeter.protocol.smtp.sampler.protocol.SendMailCommand;
+import org.apache.jmeter.protocol.smtp.sampler.tools.CounterOutputStream;
+
+import org.apache.jmeter.samplers.AbstractSampler;
+import org.apache.jmeter.samplers.Entry;
+import org.apache.jmeter.samplers.SampleResult;
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.log.Logger;
+
+/**
+ * Sampler-Class for JMeter - builds, starts and interprets the results of the
+ * sampler. Has to implement some standard-methods for JMeter in order to be
+ * integrated in the framework. All getter/setter methods just deliver/set
+ * values from/to the sampler, not from/to the message-object. Therefore, all
+ * these methods are also present in class SendMailCommand.
+ */
+public class SmtpSampler extends AbstractSampler {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final Logger log = LoggingManager.getLoggerForClass();
+
+ //+JMX file attribute names - do not change any values!
+ public final static String SERVER = "SMTPSampler.server"; // $NON-NLS-1$
+ public final static String SERVER_PORT = "SMTPSampler.serverPort"; // $NON-NLS-1$
+ public final static String USE_AUTH = "SMTPSampler.useAuth"; // $NON-NLS-1$
+ public final static String USERNAME = "SMTPSampler.username"; // $NON-NLS-1$
+ public final static String PASSWORD = "SMTPSampler.password"; // $NON-NLS-1$
+ public final static String MAIL_FROM = "SMTPSampler.mailFrom"; // $NON-NLS-1$
+ public final static String RECEIVER_TO = "SMTPSampler.receiverTo"; // $NON-NLS-1$
+ public final static String RECEIVER_CC = "SMTPSampler.receiverCC"; // $NON-NLS-1$
+ public final static String RECEIVER_BCC = "SMTPSampler.receiverBCC"; // $NON-NLS-1$
+
+ public final static String SUBJECT = "SMTPSampler.subject"; // $NON-NLS-1$
+ public final static String MESSAGE = "SMTPSampler.message"; // $NON-NLS-1$
+ 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 final static String USE_SSL = "SMTPSampler.useSSL"; // $NON-NLS-1$
+ public final static String USE_STARTTLS = "SMTPSampler.useStartTLS"; // $NON-NLS-1$
+ public final static String SSL_TRUST_ALL_CERTS = "SMTPSampler.trustAllCerts"; // $NON-NLS-1$
+ public final static String ENFORCE_STARTTLS = "SMTPSampler.enforceStartTLS"; // $NON-NLS-1$
+ public final static String USE_LOCAL_TRUSTSTORE = "SMTPSampler.useLocalTrustStore"; // $NON-NLS-1$
+ public final static String TRUSTSTORE_TO_USE = "SMTPSampler.trustStoreToUse"; // $NON-NLS-1$
+ public final static String USE_EML = "SMTPSampler.use_eml"; // $NON-NLS-1$
+ public final static String EML_MESSAGE_TO_SEND = "SMTPSampler.emlMessageToSend"; // $NON-NLS-1$
+
+ // Used to separate attachment file names in JMX fields - do not change!
+ public static final String FILENAME_SEPARATOR = ";";
+ //-JMX file attribute names
+
+
+ public SmtpSampler() {
+ }
+
+ /**
+ * Performs the sample, and returns the result
+ *
+ * @param e
+ * Standard-method-header from JMeter
+ * @return sampleresult Result of the sample
+ * @see org.apache.jmeter.samplers.Sampler#sample(org.apache.jmeter.samplers.Entry)
+ */
+ public SampleResult sample(Entry e) {
+ Message message = null;
+ SampleResult res = new SampleResult();
+ res.setSampleLabel(getName());
+ boolean isOK = false; // Did sample succeed?
+ SendMailCommand instance = new SendMailCommand();
+ instance.setSmtpServer(getPropertyAsString(SmtpSampler.SERVER));
+ instance.setSmtpPort(getPropertyAsString(SmtpSampler.SERVER_PORT));
+
+ instance.setUseSSL(getPropertyAsBoolean(USE_SSL));
+ instance.setUseStartTLS(getPropertyAsBoolean(USE_STARTTLS));
+ instance.setTrustAllCerts(getPropertyAsBoolean(SSL_TRUST_ALL_CERTS));
+ instance.setEnforceStartTLS(getPropertyAsBoolean(ENFORCE_STARTTLS));
+
+ instance.setUseAuthentication(getPropertyAsBoolean(USE_AUTH));
+ instance.setUsername(getPropertyAsString(USERNAME));
+ instance.setPassword(getPropertyAsString(PASSWORD));
+
+ instance.setUseLocalTrustStore(getPropertyAsBoolean(USE_LOCAL_TRUSTSTORE));
+ instance.setTrustStoreToUse(getPropertyAsString(TRUSTSTORE_TO_USE));
+ instance.setEmlMessage(getPropertyAsString(EML_MESSAGE_TO_SEND));
+ instance.setUseEmlMessage(getPropertyAsBoolean(USE_EML));
+
+ if (getMailFrom().matches(".*@.*")) {
+ instance.setSender(getMailFrom());
+ }
+
+ try {
+ if (!getPropertyAsBoolean(USE_EML)) { // part is only needed if we
+ // don't send an .eml-file
+
+ // check if there are really mail-addresses in the fields and if
+ // there are multiple ones
+ List<InternetAddress> receiversTo = new Vector<InternetAddress>();
+ if (getPropertyAsString(SmtpSampler.RECEIVER_TO).matches(".*@.*")) {
+ String[] strReceivers = (getPropertyAsString(SmtpSampler.RECEIVER_TO))
+ .split(";");
+ for (int i = 0; i < strReceivers.length; i++) {
+ receiversTo.add(new InternetAddress(strReceivers[i].trim()));
+ }
+ } else {
+ receiversTo.add(new InternetAddress(getMailFrom()));
+ }
+
+ instance.setReceiverTo(receiversTo);
+
+ // check if there are really mail-addresses in the fields and if
+ // there are multiple ones
+ if (getPropertyAsString(SmtpSampler.RECEIVER_CC).matches(".*@.*")) {
+ List<InternetAddress> receiversCC = new Vector<InternetAddress>();
+ String[] strReceivers = (getPropertyAsString(SmtpSampler.RECEIVER_CC))
+ .split(";");
+ for (int i = 0; i < strReceivers.length; i++) {
+ receiversCC.add(new InternetAddress(strReceivers[i].trim()));
+ }
+ instance.setReceiverCC(receiversCC);
+ }
+
+ // check if there are really mail-addresses in the fields and if
+ // there are multiple ones
+ if (getPropertyAsString(SmtpSampler.RECEIVER_BCC).matches(".*@.*")) {
+ List<InternetAddress> receiversBCC = new Vector<InternetAddress>();
+ String[] strReceivers = (getPropertyAsString(SmtpSampler.RECEIVER_BCC))
+ .split(";");
+ for (int i = 0; i < strReceivers.length; i++) {
+ receiversBCC.add(new InternetAddress(strReceivers[i].trim()));
+ }
+ instance.setReceiverBCC(receiversBCC);
+ }
+
+ MailBodyProvider mb = new MailBodyProvider();
+ if (getPropertyAsString(MESSAGE) != null
+ && !getPropertyAsString(MESSAGE).equals(""))
+ mb.setBody(getPropertyAsString(MESSAGE));
+ instance.setMbProvider(mb);
+
+ if (!getAttachments().equals("")) {
+ String[] attachments = getAttachments().split(FILENAME_SEPARATOR);
+ for (String attachment : attachments) {
+ instance.addAttachment(new File(attachment));
+ }
+ }
+
+ instance.setSubject(getPropertyAsString(SUBJECT)
+ + (getPropertyAsBoolean(INCLUDE_TIMESTAMP) ? " <<< current timestamp: "
+ + new Date().getTime() + " >>>"
+ : ""));
+ } else {
+
+ // send an .eml-file
+
+ // check if there are really mail-addresses in the fields and if
+ // there are multiple ones
+ if (getPropertyAsString(SmtpSampler.RECEIVER_TO).matches(".*@.*")) {
+ List<InternetAddress> receiversTo = new Vector<InternetAddress>();
+ String[] strReceivers = (getPropertyAsString(SmtpSampler.RECEIVER_TO))
+ .split(";");
+ for (int i = 0; i < strReceivers.length; i++) {
+ receiversTo.add(new InternetAddress(strReceivers[i].trim()));
+ }
+ instance.setReceiverTo(receiversTo);
+ }
+
+ // check if there are really mail-addresses in the fields and if
+ // there are multiple ones
+ if (getPropertyAsString(SmtpSampler.RECEIVER_CC).matches(".*@.*")) {
+ List<InternetAddress> receiversCC = new Vector<InternetAddress>();
+ String[] strReceivers = (getPropertyAsString(SmtpSampler.RECEIVER_CC))
+ .split(";");
+ for (int i = 0; i < strReceivers.length; i++) {
+ receiversCC.add(new InternetAddress(strReceivers[i].trim()));
+ }
+ instance.setReceiverCC(receiversCC);
+ }
+
+ // check if there are really mail-addresses in the fields and if
+ // there are multiple ones
+ if (getPropertyAsString(SmtpSampler.RECEIVER_BCC).matches(
+ ".*@.*")) {
+ List<InternetAddress> receiversBCC = new Vector<InternetAddress>();
+ String[] strReceivers = (getPropertyAsString(SmtpSampler.RECEIVER_BCC))
+ .split(";");
+ for (int i = 0; i < strReceivers.length; i++) {
+ receiversBCC.add(new InternetAddress(strReceivers[i]
+ .trim()));
+ }
+ instance.setReceiverBCC(receiversBCC);
+ }
+
+ String subj = getPropertyAsString(SUBJECT);
+ if (subj.trim().length() > 0) {
+ instance.setSubject(subj
+ + (getPropertyAsBoolean(INCLUDE_TIMESTAMP) ? " <<< current timestamp: "
+ + new Date().getTime() + " >>>"
+ : ""));
+ }
+ }
+ // needed for measuring sending time
+ instance.setSynchronousMode(true);
+
+ message = instance.prepareMessage();
+
+ if (getPropertyAsBoolean(MESSAGE_SIZE_STATS)) {
+ // calculate message size
+ CounterOutputStream cs = new CounterOutputStream();
+ message.writeTo(cs);
+ res.setBytes(cs.getCount());
+ } else {
+ res.setBytes(-1);
+ }
+
+ } catch (AddressException ex) {
+ log.warn("Error while preparing message", ex);
+ return res;
+ } catch (IOException ex) {
+ // TODO Auto-generated catch block
+ ex.printStackTrace();
+ } catch (MessagingException ex) {
+ // TODO Auto-generated catch block
+ ex.printStackTrace();
+ }
+
+ // Perform the sampling
+ res.sampleStart();
+
+ try {
+ instance.execute(message);
+
+ // Set up the sample result details
+ res.setSamplerData("To: "
+ + getPropertyAsString(SmtpSampler.RECEIVER_TO) + "\nCC: "
+ + getPropertyAsString(SmtpSampler.RECEIVER_CC) + "\nBCC: "
+ + getPropertyAsString(SmtpSampler.RECEIVER_BCC));
+ res.setDataType(SampleResult.TEXT);
+ res.setResponseCodeOK();
+ /*
+ * TODO if(instance.getSMTPStatusCode == 250)
+ * res.setResponseMessage("Message successfully sent!"); else
+ * res.setResponseMessage(instance.getSMTPStatusCodeIncludingMessage);
+ */
+ res.setResponseMessage("Message successfully sent!\n"
+ + instance.getServerResponse());
+ isOK = true;
+ }
+ // username / password incorrect
+ catch (AuthenticationFailedException afex) {
+ log.warn("", afex);
+ res.setResponseCode("500");
+ res.setResponseMessage("AuthenticationFailedException: authentication failed - wrong username / password!\n"
+ + afex);
+ }
+ // SSL not supported, startTLS not supported, other messagingException
+ catch (MessagingException mex) {
+ log.warn("",mex);
+ res.setResponseCode("500");
+ if (mex.getMessage().matches(
+ ".*Could not connect to SMTP host.*465.*")
+ && mex.getCause().getMessage().matches(
+ ".*Connection timed out.*")) {
+ res.setResponseMessage("MessagingException: Probably, SSL is not supported by the SMTP-Server!\n"
+ + mex);
+ } else if (mex.getMessage().matches(".*StartTLS failed.*")) {
+ res.setResponseMessage("MessagingException: StartTLS not supported by server or initializing failed!\n"
+ + mex);
+ } else if (mex.getMessage().matches(".*send command to.*")
+ && mex.getCause().getMessage().matches(
+ ".*unable to find valid certification path to requested target.*")) {
+ res.setResponseMessage("MessagingException: Server certificate not trusted - perhaps you have to restart JMeter!\n"
+ + mex);
+ } else {
+ res.setResponseMessage("Other MessagingException: "
+ + mex.toString());
+ }
+ }
+ // general exception
+ catch (Exception ex) {
+ res.setResponseCode("500");
+ if (null != ex.getMessage()
+ && ex.getMessage().matches("Failed to build truststore")) {
+ res.setResponseMessage("Failed to build truststore - did not try to send mail!");
+ } else {
+ res.setResponseMessage("Other Exception: " + ex.toString());
+ }
+ }
+
+ res.sampleEnd();
+
+ try {
+ // process the sampler result
+ InputStream is = message.getInputStream();
+ StringBuffer sb = new StringBuffer();
+ byte[] buf = new byte[1024];
+ int read = is.read(buf);
+ while (read > 0) {
+ sb.append(new String(buf, 0, read));
+ read = is.read(buf);
+ }
+ res.setResponseData(sb.toString().getBytes()); // TODO this should really be request data, but there is none
+ } catch (IOException ex) {
+ log.warn("",ex);
+ } catch (MessagingException ex) {
+ log.warn("",ex);
+ }
+
+ res.setSuccessful(isOK);
+
+ return res;
+ }
+
+ /**
+ * @return FQDN or IP of mailserver
+ */
+ public String getServer() {
+ return getPropertyAsString(SERVER);
+ }
+
+ /**
+ * @return Mailserver-Port
+ */
+ public int getPort() {
+ return getPropertyAsInt(SERVER_PORT);
+ }
+
+ /**
+ * @return Sender's mail address
+ */
+ public String getMailFrom() {
+ return getPropertyAsString(MAIL_FROM);
+ }
+
+ /**
+ * @return Receiver in field "to"
+ */
+ public String getReceiverTo() {
+ return getPropertyAsString(RECEIVER_TO);
+ }
+
+ /**
+ * @return Receiver in field "cc"
+ */
+ public String getReceiverCC() {
+ return getPropertyAsString(RECEIVER_CC);
+ }
+
+ /**
+ * @return Receiver in field "bcc"
+ */
+ public String getReceiverBCC() {
+ return getPropertyAsString(RECEIVER_BCC);
+ }
+
+ /**
+ * @return Username for mailserver-login
+ */
+ public String getUsername() {
+ return getPropertyAsString(USERNAME);
+ }
+
+ /**
+ * @return Password for mailserver-login
+ */
+ public String getPassword() {
+ return getPropertyAsString(PASSWORD);
+ }
+
+ /**
+ * @return Mail-subject
+ */
+ public String getSubject() {
+ return this.getPropertyAsString(SUBJECT);
+ }
+
+ /**
+ * @return true if timestamp is included in subject
+ */
+ public boolean getIncludeTimestamp() {
+ return this.getPropertyAsBoolean(INCLUDE_TIMESTAMP);
+ }
+
+ /**
+ * @return Path to file(s) to attach
+ */
+ public String getAttachments() {
+ return this.getPropertyAsString(ATTACH_FILE);
+ }
+
+ /**
+ * @return true if authentication is used to access mailserver
+ */
+ public boolean getUseAuthentication() {
+ return this.getPropertyAsBoolean(USE_AUTH);
+ }
+}
\ No newline at end of file
Propchange: jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/SmtpSampler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/SmtpSampler.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: 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=959681&view=auto
==============================================================================
--- jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpPanel.java (added)
+++ jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpPanel.java Thu Jul 1 14:34:35 2010
@@ -0,0 +1,1069 @@
+/*
+ * 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.smtp.sampler.gui;
+
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+
+import javax.swing.BorderFactory;
+import javax.swing.ButtonGroup;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JFileChooser;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JRadioButton;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+
+import org.apache.jmeter.protocol.smtp.sampler.SmtpSampler;
+import org.apache.jmeter.util.JMeterUtils;
+
+/**
+ * Class to build gui-components for SMTP-sampler. Getter-methods serve the
+ * input-data to the sampler-object, which provides them to the
+ * SendMailCommand-object.
+ */
+public class SmtpPanel extends JPanel {
+
+ private static final long serialVersionUID = 1L;
+
+ // local vars
+ private JTextField tfMailFrom;
+ private JButton browseButton;
+ private JButton emlBrowseButton;
+ private JCheckBox cbTrustAllCerts;
+ private JCheckBox cbEnforceStartTLS;
+ private JCheckBox cbUseAuth;
+ private JCheckBox cbUseLocalTrustStore;
+ private JRadioButton rbUseNone;
+ private JRadioButton rbUseSSL;
+ private JRadioButton rbUseStartTLS;
+ private ButtonGroup bgSecuritySettings;
+ private JTextField tfMailServer;
+ private JTextField tfMailServerPort;
+ private JTextField tfTrustStoreToUse;
+ private JTextField tfMailTo;
+ private JTextField tfMailToCC;
+ private JTextField tfMailToBCC;
+ private JTextField tfAttachment;
+ private JTextField tfEmlMessage;
+ private JTextArea taMessage;
+
+ private JLabel jlAddressFrom;
+ private JLabel jlAddressTo;
+ private JLabel jlAddressToCC;
+ private JLabel jlAddressToBCC;
+ private JLabel jlMailServerPort;
+ private JLabel jlMailServer;
+ private JLabel jlAttachFile;
+ private JLabel jlDutPortStandard;
+ private JLabel jlTrustStoreToUse;
+ private JLabel jlPassword;
+ private JLabel jlSubject;
+ private JLabel jlUsername;
+ private JLabel jlMessage;
+
+ private JFileChooser attachmentFileChooser;
+ private JFileChooser emlFileChooser;
+ private JTextField tfAuthPassword;
+ private JTextField tfAuthUsername;
+ private JTextField tfSubject;
+ private JCheckBox cbIncludeTimestamp;
+ private JCheckBox cbMessageSizeStats;
+ private JCheckBox cbUseEmlMessage;
+
+ /**
+ * Creates new form SmtpPanel, standard constructer. Calls
+ * initComponents();.
+ */
+ public SmtpPanel() {
+ initComponents();
+ }
+
+ /**
+ * Returns sender-address for e-mail from textfield
+ *
+ * @return Sender
+ */
+ public String getMailFrom() {
+ return tfMailFrom.getText();
+ }
+
+ /**
+ * Returns receiver in field "to" from textfield
+ *
+ * @return Receiver "to"
+ */
+ public String getReceiverTo() {
+ return tfMailTo.getText();
+ }
+
+ /**
+ * Returns receiver in field "cc" from textfield
+ *
+ * @return Receiver "cc"
+ */
+ public String getReceiverCC() {
+ return tfMailToCC.getText();
+ }
+
+ /**
+ * Returns receiver in field "bcc" from textfield
+ *
+ * @return Receiver "bcc"
+ */
+ public String getReceiverBCC() {
+ return tfMailToBCC.getText();
+ }
+
+ /**
+ * Returns message body, i.e. main-mime-part of message (from textfield)
+ *
+ * @return Message body
+ */
+ public String getBody() {
+ return taMessage.getText();
+ }
+
+ /**
+ * Sets message body, i.e. main-mime-part of message in textfield
+ *
+ * @param messageBodyText
+ * Message body
+ */
+ public void setBody(String messageBodyText) {
+ taMessage.setText(messageBodyText);
+ }
+
+ /**
+ * Sets sender-address of e-mail in textfield
+ *
+ * @param mailFrom
+ * Sender
+ */
+ public void setMailFrom(String mailFrom) {
+ tfMailFrom.setText(mailFrom);
+ }
+
+ /**
+ * Sets receiver in textfield "to"
+ *
+ * @param mailTo
+ * Receiver "to"
+ */
+ public void setReceiverTo(String mailTo) {
+ tfMailTo.setText(mailTo);
+ }
+
+ /**
+ * Sets receiver in textfield "cc"
+ *
+ * @param mailToCC
+ * Receiver "cc"
+ */
+ public void setReceiverCC(String mailToCC) {
+ tfMailToCC.setText(mailToCC);
+ }
+
+ /**
+ * Sets receiver in textfield "bcc"
+ *
+ * @param mailToBCC
+ * Receiver "bcc"
+ */
+ public void setReceiverBCC(String mailToBCC) {
+ tfMailToBCC.setText(mailToBCC);
+ }
+
+ /**
+ * Returns path of file(s) to be attached in e-mail from textfield
+ *
+ * @return File to attach
+ */
+ public String getAttachments() {
+ return tfAttachment.getText();
+ }
+
+ /**
+ * Sets path of file to be attached in e-mail in textfield
+ *
+ * @param attachments
+ * File to attach
+ */
+ public void setAttachments(String attachments) {
+ tfAttachment.setText(attachments);
+ }
+
+ /**
+ * Returns port of mail-server (standard 25 for SMTP/SMTP with StartTLS, 465
+ * for SSL) from textfield
+ *
+ * @return Mail-server port
+ */
+ public String getPort() {
+ return tfMailServerPort.getText();
+ }
+
+ /**
+ * Sets port of mail-server
+ *
+ * @param port
+ * Mail-server port
+ */
+ public void setPort(String port) {
+ tfMailServerPort.setText(port);
+ }
+
+ /**
+ * Returns mail-server to be used to send message (from textfield)
+ *
+ * @return FQDN or IP of mail-server
+ */
+ public String getServer() {
+ return tfMailServer.getText();
+ }
+
+ /**
+ * Sets mail-server to be used to send message in textfield
+ *
+ * @param server
+ * FQDN or IP of mail-server
+ */
+ public void setServer(String server) {
+ tfMailServer.setText(server);
+ }
+
+ /**
+ * Returns subject of the e-mail from textfield
+ *
+ * @return Subject of e-mail
+ */
+ public String getSubject() {
+ return tfSubject.getText();
+ }
+
+ /**
+ * Sets subject of the e-mail in textfield
+ *
+ * @param subject
+ * Subject of e-mail
+ */
+ public void setSubject(String subject) {
+ tfSubject.setText(subject);
+ }
+
+ /**
+ * Returns if mail-server needs authentication (checkbox)
+ *
+ * @return true if authentication is used
+ */
+ public boolean isUseAuth() {
+ return cbUseAuth.isSelected();
+ }
+
+ /**
+ * Set whether mail server needs auth.
+ *
+ * @param selected
+ */
+ public void setUseAuth(boolean selected){
+ cbUseAuth.setSelected(selected);
+ }
+
+ /**
+ * Returns if SSL is used to secure the SMTP-connection (checkbox)
+ *
+ * @return true if SSL is used to secure the SMTP-connection
+ */
+ public boolean isUseSSL() {
+ return rbUseSSL.isSelected();
+ }
+
+ /**
+ * Sets SSL to be used to secure the SMTP-connection (checkbox)
+ *
+ * @param useSSL
+ * Use SSL to secure the connection
+ */
+ public void setUseSSL(boolean useSSL) {
+ rbUseSSL.setSelected(useSSL);
+ }
+
+ /**
+ * Returns if StartTLS is used to secure the connection (checkbox)
+ *
+ * @return true if StartTLS is used to secure the connection
+ */
+ public boolean isUseStartTLS() {
+ return rbUseStartTLS.isSelected();
+ }
+
+ /**
+ * Sets StartTLS to be used to secure the SMTP-connection (checkbox)
+ *
+ * @param useStartTLS
+ * Use StartTLS to secure the connection
+ */
+ public void setUseStartTLS(boolean useStartTLS) {
+ rbUseStartTLS.setSelected(useStartTLS);
+ }
+
+ /**
+ * Returns if StartTLS is enforced (normally, SMTP uses plain
+ * SMTP-connection as fallback if "250-STARTTLS" isn't sent from the
+ * mailserver) (checkbox)
+ *
+ * @return true if StartTLS is enforced
+ */
+ public boolean isEnforceStartTLS() {
+ return cbEnforceStartTLS.isSelected();
+ }
+
+ /**
+ * Enforces StartTLS to secure the SMTP-connection (checkbox)
+ *
+ * @param enforceStartTLS
+ * Enforce the use of StartTLS to secure the connection
+ * @see #isEnforceStartTLS()
+ */
+ public void setEnforceStartTLS(boolean enforceStartTLS) {
+ cbEnforceStartTLS.setSelected(enforceStartTLS);
+ }
+
+ /**
+ * Returns if all certificates are blindly trusted (using according
+ * SocketFactory) (checkbox)
+ *
+ * @return true if all certificates are blindly trusted
+ */
+ public boolean isTrustAllCerts() {
+ return cbTrustAllCerts.isSelected();
+ }
+
+ /**
+ * Enforces JMeter to trust all certificates, no matter what CA is issuer
+ * (checkbox)
+ *
+ * @param trustAllCerts
+ * Trust all certificates
+ * @see #isTrustAllCerts()
+ */
+ public void setTrustAllCerts(boolean trustAllCerts) {
+ cbTrustAllCerts.setSelected(trustAllCerts);
+ }
+
+ /**
+ * Returns if local (pre-installed) truststore is used to avoid
+ * SSL-connection-exceptions (checkbox)
+ *
+ * @return true if a local truststore is used
+ */
+ public boolean isUseLocalTrustStore() {
+ return cbUseLocalTrustStore.isSelected();
+ }
+
+ /**
+ * Set the use of a local (pre-installed) truststore to avoid
+ * SSL-connection-exceptions (checkbox)
+ *
+ * @param useLocalTrustStore
+ * Use local keystore
+ */
+ public void setUseLocalTrustStore(boolean useLocalTrustStore) {
+ cbUseLocalTrustStore.setSelected(useLocalTrustStore);
+ }
+
+ /**
+ * Returns the path to the local (pre-installed) truststore to be used to
+ * avoid SSL-connection-exceptions
+ *
+ * @return Path to local truststore
+ */
+ public String getTrustStoreToUse() {
+ return tfTrustStoreToUse.getText();
+ }
+
+ /**
+ * Set the path to local (pre-installed) truststore to be used to avoid
+ * SSL-connection-exceptions
+ *
+ * @param trustStoreToUse
+ * Path to local truststore
+ */
+ public void setTrustStoreToUse(String trustStoreToUse) {
+ tfTrustStoreToUse.setText(trustStoreToUse);
+ }
+
+ /**
+ * Returns if an .eml-message is sent instead of the content of message-text
+ * area
+ *
+ * @return true if .eml is sent, false if text area content is sent in
+ * e-mail
+ */
+ public boolean isUseEmlMessage() {
+ return cbUseEmlMessage.isSelected();
+ }
+
+ /**
+ * Set the use of an .eml-message instead of the content of message-text
+ * area
+ *
+ * @param useEmlMessage
+ * Use eml message
+ */
+ public void setUseEmlMessage(boolean useEmlMessage) {
+ cbUseEmlMessage.setSelected(useEmlMessage);
+ }
+
+ /**
+ * Returns path to eml message to be sent
+ *
+ * @return path to eml message to be sent
+ */
+ public String getEmlMessage() {
+ return tfEmlMessage.getText();
+ }
+
+ /**
+ * Set path to eml message to be sent
+ *
+ * @param emlMessage
+ * path to eml message to be sent
+ */
+ public void setEmlMessage(String emlMessage) {
+ tfEmlMessage.setText(emlMessage);
+ }
+
+ /**
+ * Returns if current timestamp is included in the subject (checkbox)
+ *
+ * @return true if current timestamp is included in subject
+ */
+ public boolean isIncludeTimestamp() {
+ return cbIncludeTimestamp.isSelected();
+ }
+
+ /**
+ * Set timestamp to be included in the message-subject (checkbox)
+ *
+ * @param includeTimestamp
+ * Should timestamp be included in subject?
+ */
+ public void setIncludeTimestamp(boolean includeTimestamp) {
+ cbIncludeTimestamp.setSelected(includeTimestamp);
+ }
+
+ /**
+ * Returns if message size statistics are processed. Output of processing
+ * will be included in sample result. (checkbox)
+ *
+ * @return True if message size will be calculated
+ */
+ public boolean isMessageSizeStatistics() {
+ return cbMessageSizeStats.isSelected();
+ }
+
+ /**
+ * Set message size to be calculated and included in sample result
+ * (checkbox)
+ *
+ * @param val
+ * Schould message size be calculated?
+ */
+ public void setMessageSizeStatistic(boolean val) {
+ cbMessageSizeStats.setSelected(val);
+ }
+
+ public JRadioButton isUseNoSecurity() {
+ return rbUseNone;
+ }
+
+ public void setUseNoSecurity(boolean selected) {
+ rbUseNone.setSelected(selected);
+ }
+
+ public String getPassword() {
+ return tfAuthPassword.getText();
+ }
+
+ public void setPassword(String authPassword) {
+ tfAuthPassword.setText(authPassword);
+ }
+
+ public String getUsername() {
+ return tfAuthUsername.getText();
+ }
+
+ public void setUsername(String username) {
+ tfAuthUsername.setText(username);
+ }
+
+ /**
+ * Main method of class, builds all gui-components for SMTP-sampler.
+ */
+ private void initComponents() {
+ GridBagConstraints gridBagConstraints, gridBagConstraintsMain;
+
+ jlAddressFrom = new JLabel(JMeterUtils.getResString("smtp_from")); // $NON-NLS-1$
+ jlAddressTo = new JLabel(JMeterUtils.getResString("smtp_to")); // $NON-NLS-1$
+ jlAddressToCC = new JLabel(JMeterUtils.getResString("smtp_cc")); // $NON-NLS-1$
+ 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$
+ 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$
+ jlPassword = new JLabel(JMeterUtils.getResString("smtp_password")); // $NON-NLS-1$
+ jlTrustStoreToUse = new JLabel(JMeterUtils.getResString("smtp_truststore")); // $NON-NLS-1$
+ jlSubject = new JLabel(JMeterUtils.getResString("smtp_subject")); // $NON-NLS-1$
+ jlMessage = new JLabel(JMeterUtils.getResString("smtp_message")); // $NON-NLS-1$
+
+ tfMailServer = new JTextField(30);
+ tfMailServerPort = new JTextField(6);
+ tfTrustStoreToUse = new JTextField(20);
+ tfMailFrom = new JTextField(25);
+ tfMailTo = new JTextField(25);
+ tfMailToCC = new JTextField(25);
+ tfMailToBCC = new JTextField(25);
+ tfAuthUsername = new JTextField(20);
+ tfAuthPassword = new JTextField(20);
+ tfSubject = new JTextField(20);
+ tfAttachment = new JTextField(30);
+ tfEmlMessage = new JTextField(30);
+
+ taMessage = new JTextArea(5, 20);
+
+ cbUseAuth = new JCheckBox(JMeterUtils.getResString("smtp_useauth")); // $NON-NLS-1$
+ rbUseNone = new JRadioButton(JMeterUtils.getResString("smtp_usenone")); // $NON-NLS-1$
+ rbUseSSL = new JRadioButton(JMeterUtils.getResString("smtp_usessl")); // $NON-NLS-1$
+ rbUseStartTLS = new JRadioButton(JMeterUtils.getResString("smtp_usestarttls")); // $NON-NLS-1$
+
+ cbTrustAllCerts = new JCheckBox(JMeterUtils.getResString("smtp_trustall")); // $NON-NLS-1$
+ cbEnforceStartTLS = new JCheckBox(JMeterUtils.getResString("smtp_enforcestarttls")); // $NON-NLS-1$
+ cbIncludeTimestamp = new JCheckBox(JMeterUtils.getResString("smtp_timestamp")); // $NON-NLS-1$
+ cbMessageSizeStats = new JCheckBox(JMeterUtils.getResString("smtp_messagesize")); // $NON-NLS-1$
+ cbUseLocalTrustStore = new JCheckBox(JMeterUtils.getResString("smtp_usetruststore")); // $NON-NLS-1$
+ cbUseEmlMessage = new JCheckBox(JMeterUtils.getResString("smtp_eml")); // $NON-NLS-1$
+
+ attachmentFileChooser = new JFileChooser();
+ emlFileChooser = new JFileChooser();
+
+ browseButton = new JButton(JMeterUtils.getResString("browse")); // $NON-NLS-1$
+ emlBrowseButton = new JButton(JMeterUtils.getResString("browse")); // $NON-NLS-1$
+
+ attachmentFileChooser
+ .addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ attachmentFolderFileChooserActionPerformed(evt);
+ }
+ });
+
+ emlFileChooser.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ emlFileChooserActionPerformed(evt);
+ }
+ });
+
+ setLayout(new GridBagLayout());
+
+ gridBagConstraintsMain = new GridBagConstraints();
+ gridBagConstraintsMain.fill = GridBagConstraints.HORIZONTAL;
+ gridBagConstraintsMain.anchor = GridBagConstraints.WEST;
+
+ gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
+ gridBagConstraints.fill = GridBagConstraints.NONE;
+ gridBagConstraints.anchor = GridBagConstraints.WEST;
+
+ /*
+ * Server Settings
+ */
+ JPanel panelServerSettings = new JPanel(new GridBagLayout());
+ panelServerSettings.setBorder(BorderFactory.createTitledBorder(
+ BorderFactory.createEtchedBorder(),
+ JMeterUtils.getResString("smtp_server_settings"))); // $NON-NLS-1$
+
+ 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);
+
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = 1;
+ panelServerSettings.add(panelServerPortSettings, gridBagConstraints);
+
+ gridBagConstraintsMain.gridx = 0;
+ gridBagConstraintsMain.gridy = 0;
+ add(panelServerSettings, gridBagConstraintsMain);
+
+ /*
+ * E-Mail Settings
+ */
+ JPanel panelMailSettings = new JPanel(new GridBagLayout());
+ panelMailSettings.setBorder(BorderFactory.createTitledBorder(
+ BorderFactory.createEtchedBorder(),
+ JMeterUtils.getResString("smtp_mail_settings"))); // $NON-NLS-1$
+
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 0;
+ panelMailSettings.add(jlAddressFrom, gridBagConstraints);
+
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = 0;
+ panelMailSettings.add(tfMailFrom, gridBagConstraints);
+
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 1;
+ panelMailSettings.add(jlAddressTo, gridBagConstraints);
+
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = 1;
+ panelMailSettings.add(tfMailTo, gridBagConstraints);
+
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 2;
+ panelMailSettings.add(jlAddressToCC, gridBagConstraints);
+
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = 2;
+ panelMailSettings.add(tfMailToCC, gridBagConstraints);
+
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 3;
+ panelMailSettings.add(jlAddressToBCC, gridBagConstraints);
+
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = 3;
+ panelMailSettings.add(tfMailToBCC, gridBagConstraints);
+
+ gridBagConstraintsMain.gridx = 0;
+ gridBagConstraintsMain.gridy = 1;
+ add(panelMailSettings, gridBagConstraintsMain);
+
+ /*
+ * Auth Settings
+ */
+ JPanel panelAuthSettings = new JPanel(new GridBagLayout());
+ panelAuthSettings.setBorder(BorderFactory.createTitledBorder(
+ BorderFactory.createEtchedBorder(),
+ JMeterUtils.getResString("smtp_auth_settings"))); // $NON-NLS-1$
+
+ cbUseAuth.setBorder(BorderFactory.createEmptyBorder(0, 0,
+ 0, 0));
+ cbUseAuth.setMargin(new java.awt.Insets(0, 0, 0, 0));
+ cbUseAuth.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ cbUseAuthActionPerformed(evt);
+ }
+ });
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 0;
+ panelAuthSettings.add(cbUseAuth, gridBagConstraints);
+
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 1;
+ gridBagConstraints.gridwidth = 1;
+ panelAuthSettings.add(jlUsername, gridBagConstraints);
+
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = 1;
+ gridBagConstraints.gridwidth = 2;
+ panelAuthSettings.add(tfAuthUsername, gridBagConstraints);
+ tfAuthUsername.setEditable(false);
+
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 2;
+ gridBagConstraints.gridwidth = 1;
+ panelAuthSettings.add(jlPassword, gridBagConstraints);
+
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = 2;
+ panelAuthSettings.add(tfAuthPassword, gridBagConstraints);
+ tfAuthPassword.setEditable(false);
+
+ gridBagConstraintsMain.gridx = 0;
+ gridBagConstraintsMain.gridy = 2;
+ add(panelAuthSettings, gridBagConstraintsMain);
+
+ /*
+ * Security Settings
+ */
+ JPanel panelSecuritySettings = new JPanel(new GridBagLayout());
+ panelSecuritySettings.setBorder(BorderFactory.createTitledBorder(
+ BorderFactory.createEtchedBorder(),
+ JMeterUtils.getResString("smtp_security_settings"))); // $NON-NLS-1$
+
+ rbUseNone.setSelected(true);
+ bgSecuritySettings = new ButtonGroup();
+ bgSecuritySettings.add(rbUseNone);
+ bgSecuritySettings.add(rbUseSSL);
+ bgSecuritySettings.add(rbUseStartTLS);
+
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 0;
+ panelSecuritySettings.add(rbUseNone, gridBagConstraints);
+
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 1;
+ panelSecuritySettings.add(rbUseSSL, gridBagConstraints);
+
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 2;
+ panelSecuritySettings.add(rbUseStartTLS, gridBagConstraints);
+
+ rbUseNone.addItemListener(new ItemListener() {
+ public void itemStateChanged(ItemEvent evt) {
+ rbSecuritySettingsItemStateChanged(evt);
+ }
+ });
+ rbUseSSL.addItemListener(new ItemListener() {
+ public void itemStateChanged(ItemEvent evt) {
+ rbSecuritySettingsItemStateChanged(evt);
+ }
+ });
+ rbUseStartTLS.addItemListener(new ItemListener() {
+ public void itemStateChanged(ItemEvent evt) {
+ rbSecuritySettingsItemStateChanged(evt);
+ }
+ });
+
+ cbTrustAllCerts.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
+ cbTrustAllCerts.setMargin(new java.awt.Insets(0, 0, 0, 0));
+ cbTrustAllCerts.setEnabled(false);
+ cbTrustAllCerts.setToolTipText(JMeterUtils.getResString("smtp_trustall_tooltip")); // $NON-NLS-1$
+
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = 1;
+ panelSecuritySettings.add(cbTrustAllCerts, gridBagConstraints);
+
+ cbEnforceStartTLS.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
+ cbEnforceStartTLS.setMargin(new java.awt.Insets(0, 0, 0, 0));
+ cbEnforceStartTLS.setEnabled(false);
+ cbEnforceStartTLS.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ cbEnforceStartTLSActionPerformed(evt);
+ }
+ });
+ cbEnforceStartTLS.setToolTipText(JMeterUtils.getResString("smtp_enforcestarttls_tooltip")); // $NON-NLS-1$
+
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = 2;
+ panelSecuritySettings.add(cbEnforceStartTLS, gridBagConstraints);
+
+ cbUseLocalTrustStore.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
+ cbUseLocalTrustStore.setMargin(new java.awt.Insets(0, 0, 0, 0));
+ cbUseLocalTrustStore.setEnabled(false);
+ cbUseLocalTrustStore.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ cbUseLocalTrustStoreActionPerformed(evt);
+ }
+ });
+
+ cbUseLocalTrustStore.setToolTipText(JMeterUtils.getResString("smtp_usetruststore_tooltip")); // $NON-NLS-1$
+
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 5;
+ gridBagConstraints.gridwidth = 2;
+ panelSecuritySettings.add(cbUseLocalTrustStore, gridBagConstraints);
+
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 6;
+ gridBagConstraints.gridwidth = 1;
+ panelSecuritySettings.add(jlTrustStoreToUse, gridBagConstraints);
+
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = 6;
+ panelSecuritySettings.add(tfTrustStoreToUse, gridBagConstraints);
+
+ gridBagConstraintsMain.gridx = 0;
+ gridBagConstraintsMain.gridy = 3;
+ add(panelSecuritySettings, gridBagConstraintsMain);
+
+ /*
+ * (non-Javadoc) Message Settings
+ */
+ JPanel panelMessageSettings = new JPanel(new GridBagLayout());
+ panelMessageSettings.setBorder(BorderFactory.createTitledBorder(
+ BorderFactory.createEtchedBorder(),
+ JMeterUtils.getResString("smtp_message_settings"))); // $NON-NLS-1$
+
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 0;
+ panelMessageSettings.add(jlSubject, gridBagConstraints);
+
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = 0;
+ 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;
+ panelMessageSettings.add(cbIncludeTimestamp, gridBagConstraints);
+
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 1;
+ panelMessageSettings.add(jlMessage, gridBagConstraints);
+
+ taMessage.setBorder(BorderFactory.createBevelBorder(1));
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = 1;
+ panelMessageSettings.add(taMessage, gridBagConstraints);
+
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 2;
+ panelMessageSettings.add(jlAttachFile, gridBagConstraints);
+
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = 2;
+ panelMessageSettings.add(tfAttachment, gridBagConstraints);
+ tfAttachment.setToolTipText(JMeterUtils.getResString("smtp_attach_file_tooltip")); // $NON-NLS-1$
+
+ browseButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ browseButtonActionPerformed(evt);
+ }
+ });
+
+ gridBagConstraints.gridx = 2;
+ gridBagConstraints.gridy = 2;
+ panelMessageSettings.add(browseButton, gridBagConstraints);
+
+ cbUseEmlMessage.setSelected(false);
+ cbUseEmlMessage.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ cbUseEmlMessageActionPerformed(evt);
+ }
+ });
+
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 3;
+ panelMessageSettings.add(cbUseEmlMessage, gridBagConstraints);
+
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = 3;
+ tfEmlMessage.setEnabled(false);
+ panelMessageSettings.add(tfEmlMessage, gridBagConstraints);
+
+ emlBrowseButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ emlBrowseButtonActionPerformed(evt);
+ }
+ });
+ emlBrowseButton.setEnabled(false);
+
+ gridBagConstraints.gridx = 2;
+ gridBagConstraints.gridy = 3;
+ panelMessageSettings.add(emlBrowseButton, gridBagConstraints);
+
+ gridBagConstraintsMain.gridx = 0;
+ gridBagConstraintsMain.gridy = 4;
+ add(panelMessageSettings, gridBagConstraintsMain);
+
+ /*
+ * Additional Settings
+ */
+ JPanel panelAdditionalSettings = new JPanel(new GridBagLayout());
+ panelAdditionalSettings.setBorder(BorderFactory.createTitledBorder(
+ BorderFactory.createEtchedBorder(),
+ JMeterUtils.getResString("smtp_additional_settings"))); // $NON-NLS-1$
+
+ cbMessageSizeStats.setBorder(BorderFactory
+ .createEmptyBorder(0, 0, 0, 0));
+ cbMessageSizeStats.setMargin(new java.awt.Insets(0, 0, 0, 0));
+
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 0;
+ panelAdditionalSettings.add(cbMessageSizeStats, gridBagConstraints);
+
+ gridBagConstraintsMain.gridx = 0;
+ gridBagConstraintsMain.gridy = 5;
+ add(panelAdditionalSettings, gridBagConstraintsMain);
+ }
+
+ /**
+ * ActionPerformed-method for checkbox "useAuth"
+ *
+ * @param evt
+ * ActionEvent to be handeled
+ */
+ private void cbUseAuthActionPerformed(ActionEvent evt) {
+ tfAuthUsername.setEditable(cbUseAuth.isSelected());
+ tfAuthPassword.setEditable(cbUseAuth.isSelected());
+ }
+
+ /**
+ * ActionPerformed-method for checkbox "useLocalTrustStore"
+ *
+ * @param evt
+ * ActionEvent to be handeled
+ */
+ private void cbUseLocalTrustStoreActionPerformed(
+ ActionEvent evt) {
+ if (cbUseLocalTrustStore.isSelected()) {
+ tfTrustStoreToUse.setEditable(true);
+ cbTrustAllCerts.setSelected(false);
+ }
+ }
+
+ /**
+ * ActionPerformed-method for filechoser "attachmentFileChoser", creates
+ * FileChoser-Object
+ *
+ * @param evt
+ * ActionEvent to be handled
+ */
+ private void attachmentFolderFileChooserActionPerformed(ActionEvent evt) {
+ final String attachments = tfAttachment.getText().trim();
+ if (null != attachments && attachments.length() > 0) {
+ tfAttachment.setText(attachments
+ + SmtpSampler.FILENAME_SEPARATOR
+ + attachmentFileChooser.getSelectedFile()
+ .getAbsolutePath());
+ } else {
+ tfAttachment.setText(attachmentFileChooser.getSelectedFile()
+ .getAbsolutePath());
+ }
+
+ }
+
+ /**
+ * ActionPerformed-method for button "browseButton", opens FileDialog-Object
+ *
+ * @param evt
+ * ActionEvent to be handeled
+ */
+ private void browseButtonActionPerformed(ActionEvent evt) {
+ attachmentFileChooser.showOpenDialog(this);
+ }
+
+ private void cbUseEmlMessageActionPerformed(ActionEvent evt) {
+ if (cbUseEmlMessage.isSelected()) {
+ tfEmlMessage.setEnabled(true);
+ emlBrowseButton.setEnabled(true);
+
+ /*tfMailFrom.setEnabled(false);
+ tfMailTo.setEnabled(false);
+ tfMailToCC.setEnabled(false);
+ tfMailToBCC.setEnabled(false);
+ tfSubject.setEnabled(false);*/
+ taMessage.setEnabled(false);
+ tfAttachment.setEnabled(false);
+ browseButton.setEnabled(false);
+ } else {
+ tfEmlMessage.setEnabled(false);
+ emlBrowseButton.setEnabled(false);
+
+ /*tfMailFrom.setEnabled(true);
+ tfMailTo.setEnabled(true);
+ tfMailToCC.setEnabled(true);
+ tfMailToBCC.setEnabled(true);
+ tfSubject.setEnabled(true);*/
+ taMessage.setEnabled(true);
+ tfAttachment.setEnabled(true);
+ browseButton.setEnabled(true);
+ }
+ }
+
+ /**
+ * ActionPerformed-method for filechoser "emlFileChoser", creates
+ * FileChoser-Object
+ *
+ * @param evt
+ * ActionEvent to be handeled
+ */
+ private void emlFileChooserActionPerformed(ActionEvent evt) {
+ tfEmlMessage.setText(emlFileChooser.getSelectedFile().getAbsolutePath());
+ }
+
+ /**
+ * ActionPerformed-method for button "emlButton", opens FileDialog-Object
+ *
+ * @param evt
+ * ActionEvent to be handeled
+ */
+ private void emlBrowseButtonActionPerformed(ActionEvent evt) {
+ emlFileChooser.showOpenDialog(this);
+ }
+
+ /**
+ * ActionPerformed-method for checkbox "enforceStartTLS", empty method
+ * header
+ *
+ * @param evt
+ * ActionEvent to be handeled
+ */
+ private void cbEnforceStartTLSActionPerformed(ActionEvent evt) {
+ }
+
+ /**
+ * ItemStateChanged-method for radiobutton "securitySettings"
+ *
+ * @param evt
+ * ItemEvent to be handeled
+ */
+ private void rbSecuritySettingsItemStateChanged(ItemEvent evt) {
+ final Object source = evt.getSource();
+ if (source == rbUseNone) {
+ cbTrustAllCerts.setEnabled(false);
+ cbTrustAllCerts.setSelected(false);
+ cbEnforceStartTLS.setEnabled(false);
+ cbEnforceStartTLS.setSelected(false);
+ cbUseLocalTrustStore.setSelected(false);
+ cbUseLocalTrustStore.setEnabled(false);
+ tfTrustStoreToUse.setEditable(false);
+ } else if (source == rbUseSSL) {
+ cbTrustAllCerts.setEnabled(true);
+ cbEnforceStartTLS.setEnabled(false);
+ cbEnforceStartTLS.setSelected(false);
+ cbUseLocalTrustStore.setEnabled(true);
+ tfTrustStoreToUse.setEditable(false);
+ } else if (source == rbUseStartTLS) {
+ cbTrustAllCerts.setEnabled(false);
+ cbTrustAllCerts.setSelected(false);
+ cbEnforceStartTLS.setEnabled(true);
+ cbUseLocalTrustStore.setEnabled(true);
+ cbUseLocalTrustStore.setSelected(false);
+ tfTrustStoreToUse.setEditable(false);
+ }
+ }
+
+}
\ No newline at end of file
Propchange: jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpPanel.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpPanel.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: 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=959681&view=auto
==============================================================================
--- jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpSamplerGui.java (added)
+++ jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpSamplerGui.java Thu Jul 1 14:34:35 2010
@@ -0,0 +1,169 @@
+/*
+ * 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.smtp.sampler.gui;
+
+import java.awt.BorderLayout;
+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;
+
+/**
+ * Class to build superstructure-gui for SMTP-panel, sets/gets value for a JMeter's testElement-object (i.e. also for save/load-purposes).
+ * This class extends AbstractSamplerGui, therefor most implemented methods are defined by JMeter's structure.
+ */
+public class SmtpSamplerGui extends AbstractSamplerGui {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private SmtpPanel smtpPanel;
+
+ /**
+ * Creates new SmtpSamplerGui, standard constructer. Calls init();
+ */
+ public SmtpSamplerGui() {
+ init();
+ }
+
+ /**
+ * Method to be implemented by interface, overwritten by getStaticLabel(). Method has to be implemented by interface
+ * @return Null-String
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#getLabelResource()
+ */
+ public String getLabelResource() {
+ return "smtp_sampler_title";
+ }
+
+ /**
+ * Copy the data from the test element to the GUI, method has to be implemented by interface
+ * @param element Test-element to be used as data-input
+ * @see org.apache.jmeter.gui.AbstractJMeterGuiComponent#configure(org.apache.jmeter.testelement.TestElement)
+ */
+ @Override
+ public void configure(TestElement element) {
+ 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));
+ smtpPanel.setReceiverTo(element.getPropertyAsString(SmtpSampler.RECEIVER_TO));
+ smtpPanel.setReceiverCC(element.getPropertyAsString(SmtpSampler.RECEIVER_CC));
+ smtpPanel.setReceiverBCC(element.getPropertyAsString(SmtpSampler.RECEIVER_BCC));
+
+ smtpPanel.setBody(element.getPropertyAsString(SmtpSampler.MESSAGE));
+ smtpPanel.setSubject(element.getPropertyAsString(SmtpSampler.SUBJECT));
+ smtpPanel.setIncludeTimestamp(element.getPropertyAsBoolean(SmtpSampler.INCLUDE_TIMESTAMP));
+ smtpPanel.setAttachments(element.getPropertyAsString(SmtpSampler.ATTACH_FILE));
+
+ smtpPanel.setUseEmlMessage(element.getPropertyAsBoolean(SmtpSampler.USE_EML));
+ smtpPanel.setEmlMessage(element.getPropertyAsString(SmtpSampler.EML_MESSAGE_TO_SEND));
+
+ smtpPanel.setUseSSL(element.getPropertyAsBoolean(SmtpSampler.USE_SSL));
+ smtpPanel.setUseStartTLS(element.getPropertyAsBoolean(SmtpSampler.USE_STARTTLS));
+ if(!element.getPropertyAsBoolean(SmtpSampler.USE_STARTTLS) && !element.getPropertyAsBoolean(SmtpSampler.USE_SSL)){
+ smtpPanel.setUseNoSecurity(true);
+ }
+ smtpPanel.setTrustAllCerts(element.getPropertyAsBoolean(SmtpSampler.SSL_TRUST_ALL_CERTS));
+ smtpPanel.setEnforceStartTLS(element.getPropertyAsBoolean(SmtpSampler.ENFORCE_STARTTLS));
+ smtpPanel.setUseLocalTrustStore(element.getPropertyAsBoolean(SmtpSampler.USE_LOCAL_TRUSTSTORE));
+ smtpPanel.setTrustStoreToUse(element.getPropertyAsString(SmtpSampler.TRUSTSTORE_TO_USE));
+
+ smtpPanel.setUseAuth(element.getPropertyAsBoolean(SmtpSampler.USE_AUTH));
+ smtpPanel.setUsername(element.getPropertyAsString(SmtpSampler.USERNAME));
+ smtpPanel.setPassword(element.getPropertyAsString(SmtpSampler.PASSWORD));
+
+ smtpPanel.setMessageSizeStatistic(element.getPropertyAsBoolean(SmtpSampler.MESSAGE_SIZE_STATS));
+
+ super.configure(element);
+ }
+
+ /**
+ * Creates a new TestElement and set up its data
+ * @return Test-element for JMeter
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
+ */
+ public TestElement createTestElement() {
+ SmtpSampler sampler = new SmtpSampler();
+ modifyTestElement(sampler);
+ return sampler;
+ }
+
+ /**
+ * Modifies a given TestElement to mirror the data in the gui components
+ * @param te TestElement for JMeter
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(org.apache.jmeter.testelement.TestElement)
+ */
+ public void modifyTestElement(TestElement te) {
+ te.clear();
+ super.configureTestElement(te);
+ te.setProperty(SmtpSampler.SERVER, smtpPanel.getServer());
+ te.setProperty(SmtpSampler.SERVER_PORT, smtpPanel.getPort());
+ te.setProperty(SmtpSampler.MAIL_FROM, smtpPanel.getMailFrom());
+ te.setProperty(SmtpSampler.RECEIVER_TO, smtpPanel.getReceiverTo());
+ te.setProperty(SmtpSampler.RECEIVER_CC, smtpPanel.getReceiverCC());
+ te.setProperty(SmtpSampler.RECEIVER_BCC, smtpPanel.getReceiverBCC());
+ te.setProperty(SmtpSampler.SUBJECT, smtpPanel.getSubject());
+ te.setProperty(SmtpSampler.INCLUDE_TIMESTAMP, Boolean.toString(smtpPanel.isIncludeTimestamp()));
+ te.setProperty(SmtpSampler.MESSAGE, smtpPanel.getBody());
+ te.setProperty(SmtpSampler.ATTACH_FILE, smtpPanel.getAttachments());
+
+ te.setProperty(SmtpSampler.USE_SSL, Boolean.toString(smtpPanel.isUseSSL()));
+ te.setProperty(SmtpSampler.USE_STARTTLS, Boolean.toString(smtpPanel.isUseStartTLS()));
+ te.setProperty(SmtpSampler.SSL_TRUST_ALL_CERTS, Boolean.toString(smtpPanel.isTrustAllCerts()));
+ te.setProperty(SmtpSampler.ENFORCE_STARTTLS, Boolean.toString(smtpPanel.isEnforceStartTLS()));
+ te.setProperty(SmtpSampler.USE_LOCAL_TRUSTSTORE, Boolean.toString(smtpPanel.isUseLocalTrustStore()));
+ te.setProperty(SmtpSampler.TRUSTSTORE_TO_USE, smtpPanel.getTrustStoreToUse());
+
+ te.setProperty(SmtpSampler.USE_EML, smtpPanel.isUseEmlMessage());
+ te.setProperty(SmtpSampler.EML_MESSAGE_TO_SEND, smtpPanel.getEmlMessage());
+
+ te.setProperty(SmtpSampler.USE_AUTH, Boolean.toString(smtpPanel.isUseAuth()));
+ te.setProperty(SmtpSampler.PASSWORD, smtpPanel.getPassword());
+ te.setProperty(SmtpSampler.USERNAME, smtpPanel.getUsername());
+
+ te.setProperty(SmtpSampler.MESSAGE_SIZE_STATS, Boolean.toString(smtpPanel.isMessageSizeStatistics()));
+ }
+
+ /**
+ * Helper method to set up the GUI screen
+ */
+ private void init() {
+ // Standard setup
+ setLayout(new BorderLayout(0, 5));
+ setBorder(makeBorder());
+ add(makeTitlePanel(), BorderLayout.NORTH); // Add the standard title
+ add(makeDataPanel(), BorderLayout.CENTER);
+ }
+
+
+ /**
+ * Creates a sampler-gui-object, singleton-method
+ * @return Panel for entering the data
+ */
+ private Component makeDataPanel() {
+ if (smtpPanel == null)
+ smtpPanel = new SmtpPanel();
+ return smtpPanel;
+ }
+}
\ No newline at end of file
Propchange: jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpSamplerGui.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpSamplerGui.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/protocol/MailBodyProvider.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/protocol/MailBodyProvider.java?rev=959681&view=auto
==============================================================================
--- jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/protocol/MailBodyProvider.java (added)
+++ jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/protocol/MailBodyProvider.java Thu Jul 1 14:34:35 2010
@@ -0,0 +1,51 @@
+/*
+ * 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.smtp.sampler.protocol;
+
+/**
+ * Class to build and store message body. Does nothing more than handle the (text-)data to be included in the message body.
+ */
+public class MailBodyProvider {
+
+ private String mailBody;
+
+ /**
+ * Standard-Constructor
+ */
+ public MailBodyProvider() {
+ mailBody = ">>>This is just a blind text<<<";
+ }
+
+ /**
+ * Returns mail-body as a String
+ * @return Mail-body
+ */
+ public String getMailBody() {
+ return mailBody;
+ }
+
+ /**
+ * Sets string to be used as mailbody
+ * @param mailBodyText Text to be set as mailbody
+ */
+ public void setBody(String mailBodyText) {
+ mailBody = mailBodyText;
+ }
+}
Propchange: jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/protocol/MailBodyProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/protocol/MailBodyProvider.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@jakarta.apache.org
For additional commands, e-mail: notifications-help@jakarta.apache.org