KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > james > test > mock > mailet > MockMailContext


1 /****************************************************************
2  * Licensed to the Apache Software Foundation (ASF) under one *
3  * or more contributor license agreements. See the NOTICE file *
4  * distributed with this work for additional information *
5  * regarding copyright ownership. The ASF licenses this file *
6  * to you under the Apache License, Version 2.0 (the *
7  * "License"); you may not use this file except in compliance *
8  * with the License. You may obtain a copy of the License at *
9  * *
10  * http://www.apache.org/licenses/LICENSE-2.0 *
11  * *
12  * Unless required by applicable law or agreed to in writing, *
13  * software distributed under the License is distributed on an *
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
15  * KIND, either express or implied. See the License for the *
16  * specific language governing permissions and limitations *
17  * under the License. *
18  ****************************************************************/

19
20 package org.apache.james.test.mock.mailet;
21
22 import org.apache.mailet.MailetContext;
23 import org.apache.mailet.Mail;
24 import org.apache.mailet.MailAddress;
25
26 import javax.mail.MessagingException JavaDoc;
27 import javax.mail.internet.MimeMessage JavaDoc;
28 import java.util.Collection JavaDoc;
29 import java.util.HashMap JavaDoc;
30 import java.util.Iterator JavaDoc;
31
32 public class MockMailContext implements MailetContext {
33     
34     HashMap JavaDoc attributes = new HashMap JavaDoc();
35
36     public void bounce(Mail mail, String JavaDoc message) throws MessagingException JavaDoc {
37         // trivial implementation
38
}
39
40     public void bounce(Mail mail, String JavaDoc message, MailAddress bouncer) throws MessagingException JavaDoc {
41         // trivial implementation
42
}
43
44     public Collection JavaDoc getMailServers(String JavaDoc host) {
45         return null; // trivial implementation
46
}
47
48     public MailAddress getPostmaster() {
49         return null; // trivial implementation
50
}
51
52     public Object JavaDoc getAttribute(String JavaDoc name) {
53         return attributes.get(name);
54     }
55
56     public Iterator JavaDoc getAttributeNames() {
57         return attributes.keySet().iterator();
58     }
59
60     public int getMajorVersion() {
61         return 0; // trivial implementation
62
}
63
64     public int getMinorVersion() {
65         return 0; // trivial implementation
66
}
67
68     public String JavaDoc getServerInfo() {
69         return "Mock Server";
70     }
71
72     public boolean isLocalServer(String JavaDoc serverName) {
73         return false; // trivial implementation
74
}
75
76     public boolean isLocalUser(String JavaDoc userAccount) {
77         return false; // trivial implementation
78
}
79
80     public boolean isLocalEmail(MailAddress mailAddress) {
81         return false; // trivial implementation
82
}
83
84     public void log(String JavaDoc message) {
85         System.out.println(message);
86     }
87
88     public void log(String JavaDoc message, Throwable JavaDoc t) {
89         System.out.println(message);
90         t.printStackTrace(System.out);
91     }
92
93     public void removeAttribute(String JavaDoc name) {
94         // trivial implementation
95
}
96
97     public void sendMail(MimeMessage JavaDoc msg) throws MessagingException JavaDoc {
98         throw new UnsupportedOperationException JavaDoc("MOCKed method");
99     }
100
101     public void sendMail(MailAddress sender, Collection JavaDoc recipients, MimeMessage JavaDoc msg) throws MessagingException JavaDoc {
102         throw new UnsupportedOperationException JavaDoc("MOCKed method");
103     }
104
105     public void sendMail(MailAddress sender, Collection JavaDoc recipients, MimeMessage JavaDoc msg, String JavaDoc state) throws MessagingException JavaDoc {
106         throw new UnsupportedOperationException JavaDoc("MOCKed method");
107     }
108
109     public void sendMail(Mail mail) throws MessagingException JavaDoc {
110         throw new UnsupportedOperationException JavaDoc("MOCKed method");
111     }
112
113     public void setAttribute(String JavaDoc name, Object JavaDoc object) {
114         attributes.put(name,object);
115     }
116
117     public void storeMail(MailAddress sender, MailAddress recipient, MimeMessage JavaDoc msg) throws MessagingException JavaDoc {
118         // trivial implementation
119
}
120
121     public Iterator JavaDoc getSMTPHostAddresses(String JavaDoc domainName) {
122         return null; // trivial implementation
123
}
124 }
125
Popular Tags