1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.apache.mailet.base.test;
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 FakeMail 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 FakeMail() {
61 super();
62 }
63
64 public FakeMail(MimeMessage msg) {
65 this();
66 this.msg = msg;
67 }
68
69 public String getName() {
70 return name;
71 }
72
73 public void setName(String newName) {
74 this.name = newName;
75 }
76
77 public MimeMessage getMessage() throws MessagingException {
78 return msg;
79 }
80
81 public Collection getRecipients() {
82 return recipients;
83 }
84
85 public void setRecipients(Collection recipients) {
86 this.recipients = recipients;
87 }
88
89 public MailAddress getSender() {
90 return sender;
91 }
92
93 public String getState() {
94 return state;
95 }
96
97 public String getRemoteHost() {
98 return "111.222.333.444";
99 }
100
101 public String getRemoteAddr() {
102 return remoteAddr;
103 }
104
105 public String getErrorMessage() {
106 return errorMessage;
107 }
108
109 public void setErrorMessage(String msg) {
110 this.errorMessage = msg;
111 }
112
113 public void setMessage(MimeMessage message) {
114 this.msg = message;
115 }
116
117 public void setState(String state) {
118 this.state = state;
119 }
120
121 public Serializable getAttribute(String name) {
122 return (Serializable) attributes.get(name);
123 }
124
125 public Iterator getAttributeNames() {
126 return attributes.keySet().iterator();
127 }
128
129 public boolean hasAttributes() {
130 return !attributes.isEmpty();
131 }
132
133 public Serializable removeAttribute(String name) {
134 return (Serializable) attributes.remove(name);
135
136 }
137
138 public void removeAllAttributes() {
139 attributes.clear();
140 }
141
142 public Serializable setAttribute(String name, Serializable object) {
143
144 return (Serializable) attributes.put(name, object);
145 }
146
147 public long getMessageSize() throws MessagingException {
148 return size;
149 }
150
151 public Date getLastUpdated() {
152 return lastUpdated;
153 }
154
155 public void setLastUpdated(Date lastUpdated) {
156 this.lastUpdated = lastUpdated;
157 }
158
159 public void setMessageSize(long size) {
160 this.size = size;
161 }
162
163 public void setRemoteAddr(String remoteAddr) {
164 this.remoteAddr = remoteAddr;
165 }
166 }