001: // Copyright © 2006-2007 ASERT. Released under the Canoo Webtest license.
002: package com.canoo.webtest.plugins.emailtest;
003:
004: import java.util.Map;
005:
006: import com.canoo.webtest.steps.Step;
007:
008: /**
009: * Sets Email Configuration information.
010: *
011: * @author Paul King
012: * @webtest.step
013: * category="Email"
014: * name="emailSetConfig"
015: * description="Sets Email Configuration information."
016: */
017: public class EmailSetConfig extends Step {
018: private String fServer;
019: private String fUsername;
020: private String fPassword;
021: private String fDelay;
022: private String fType = "pop3";
023:
024: public String getServer() {
025: return fServer;
026: }
027:
028: /**
029: * Sets the email server.
030: *
031: * @param server The Server domain name (and optional port)
032: * @webtest.parameter
033: * required="yes"
034: * description="The email server (including port if required)."
035: */
036: public void setServer(final String server) {
037: fServer = server;
038: }
039:
040: public String getType() {
041: return fType;
042: }
043:
044: /**
045: * Sets the email server type.
046: *
047: * @param type The server type
048: * @webtest.parameter
049: * required="no"
050: * default="pop3"
051: * description="The email server type (only 'pop3' has been tested)."
052: */
053: public void setType(final String type) {
054: fType = type;
055: }
056:
057: public String getUsername() {
058: return fUsername;
059: }
060:
061: /**
062: * Sets the delay to use between email steps.
063: *
064: * @param delay The delay between operaitons in seconds
065: * @webtest.parameter
066: * required="no"
067: * default="0"
068: * description="The delay between email steps in seconds - sometimes helps with email servers which are fussy about multiple logins."
069: */
070: public void setDelay(final String delay) {
071: fDelay = delay;
072: }
073:
074: public String getDelay() {
075: return fDelay;
076: }
077:
078: /**
079: * Sets the email account username.
080: *
081: * @param username
082: * @webtest.parameter
083: * required="yes/no"
084: * description="The email account username. Probably required for your steps to work. Might be set using a system property."
085: */
086: public void setUsername(final String username) {
087: fUsername = username;
088: }
089:
090: public String getPassword() {
091: return fPassword;
092: }
093:
094: /**
095: * Sets the email account password.
096: *
097: * @param password
098: * @webtest.parameter
099: * required="yes/no"
100: * description="The email account password. Probably required for your steps to work."
101: */
102: public void setPassword(final String password) {
103: fPassword = password;
104: }
105:
106: public void doExecute() throws Exception {
107: getContext().put(
108: "EmailConfigInfo",
109: new EmailConfigInfo(getServer(), getType(),
110: getUsername(), getPassword(), getDelay()));
111: }
112:
113: protected void verifyParameters() {
114: super .verifyParameters();
115: optionalIntegerParamCheck(getDelay(), "delay", true);
116: }
117:
118: public Map getParameterDictionary() {
119: final Map map = super .getParameterDictionary();
120: map.put("password", "******"); // don't report password
121: return map;
122: }
123: }
|