1 19 20 21 package org.apache.james.test.mock.mailet; 22 23 import java.io.Serializable ; 24 import java.util.ArrayList ; 25 import java.util.Collection ; 26 import java.util.Date ; 27 import java.util.HashMap ; 28 import java.util.Iterator ; 29 30 import javax.mail.MessagingException ; 31 import javax.mail.internet.MimeMessage ; 32 33 import org.apache.mailet.Mail; 34 import org.apache.mailet.MailAddress; 35 36 public class MockMail implements Mail { 37 38 private MimeMessage msg = null; 39 40 private Collection recipients = new ArrayList (); 41 42 private String name = null; 43 44 private MailAddress sender = null; 45 46 private String state = null; 47 48 private String errorMessage; 49 50 private Date lastUpdated; 51 52 private HashMap attributes = new HashMap (); 53 54 private static final long serialVersionUID = 1L; 55 56 private long size = 0; 57 58 private String remoteAddr ="127.0.0.1"; 59 60 public String getName() { 61 return name; 62 } 63 64 public void setName(String newName) { 65 this.name = newName; 66 } 67 68 public MimeMessage getMessage() throws MessagingException { 69 return msg; 70 } 71 72 public Collection getRecipients() { 73 return recipients; 74 } 75 76 public void setRecipients(Collection recipients) { 77 this.recipients = recipients; 78 } 79 80 public MailAddress getSender() { 81 return sender; 82 } 83 84 public String getState() { 85 return state; 86 } 87 88 public String getRemoteHost() { 89 return "111.222.333.444"; 90 } 91 92 public String getRemoteAddr() { 93 return remoteAddr; 94 } 95 96 public String getErrorMessage() { 97 return errorMessage; 98 } 99 100 public void setErrorMessage(String msg) { 101 this.errorMessage = msg; 102 } 103 104 public void setMessage(MimeMessage message) { 105 this.msg = message; 106 } 107 108 public void setState(String state) { 109 this.state = state; 110 } 111 112 public Serializable getAttribute(String name) { 113 return (Serializable ) attributes.get(name); 114 } 115 116 public Iterator getAttributeNames() { 117 return attributes.keySet().iterator(); 118 } 119 120 public boolean hasAttributes() { 121 return !attributes.isEmpty(); 122 } 123 124 public Serializable removeAttribute(String name) { 125 return (Serializable ) attributes.remove(name); 126 127 } 128 129 public void removeAllAttributes() { 130 attributes.clear(); 131 } 132 133 public Serializable setAttribute(String name, Serializable object) { 134 135 return (Serializable ) attributes.put(name, object); 136 } 137 138 public long getMessageSize() throws MessagingException { 139 return size; 140 } 141 142 public Date getLastUpdated() { 143 return lastUpdated; 144 } 145 146 public void setLastUpdated(Date lastUpdated) { 147 this.lastUpdated = lastUpdated; 148 } 149 150 public void setMessageSize(long size) { 151 this.size = size; 152 } 153 154 public void setRemoteAddr(String remoteAddr) { 155 this.remoteAddr = remoteAddr; 156 } 157 } 158 | Popular Tags |