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