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