1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package mocks;
17
18 import java.util.Properties;
19
20 import javax.mail.Address;
21 import javax.mail.Authenticator;
22 import javax.mail.MessagingException;
23 import javax.mail.NoSuchProviderException;
24 import javax.mail.Session;
25 import javax.mail.internet.AddressException;
26 import javax.mail.internet.InternetAddress;
27
28 import org.kuali.rice.kew.mail.Mailer;
29
30 public class MockMailer extends Mailer{
31
32 public MockMailer(Properties configProperties) {
33 super(null);
34 }
35 public MockMailer(Properties configProperties, Authenticator authenticator) {
36 super(null,null);
37 }
38 public MockMailer(Properties configProperties, String username, String password) {
39 super(null,null,null);
40 }
41
42
43
44
45 @Override
46 public void sendMessage(String sender, Address[] recipients,
47 String subject, String messageBody, Address[] ccRecipients,
48 Address[] bccRecipients, boolean htmlMessage)
49 throws AddressException, MessagingException {
50
51 String toValue = "";
52 for(Address a: recipients){
53 toValue += a.toString();
54 }
55
56 String fromValue = (sender == null) ? "" : sender;
57 String subjectValue = (subject == null) ? "" : subject;
58 String bodyValue = (messageBody == null) ? "" : messageBody;
59 LOG.info("\nWILL NOT send e-mail message with to '" + toValue + "'... \nfrom '" + fromValue + "'... \nsubject '" + subjectValue + "'... and \nbody '" + bodyValue);
60 }
61
62
63
64
65 @Override
66 public void sendMessage(String sender, String recipient, String subject, String messageBody, boolean htmlMessage) throws AddressException, MessagingException {
67 final Address[] NO_RECIPIENTS = null;
68 Address[] recipients = { new InternetAddress(recipient) };
69 sendMessage(sender, recipients, subject, messageBody, NO_RECIPIENTS, NO_RECIPIENTS, htmlMessage);
70 }
71
72
73
74
75 @Override
76 public Authenticator getAuthenticator() {
77
78 return null;
79 }
80
81
82
83
84 @Override
85 public Properties getConfig() {
86
87 return null;
88 }
89
90
91
92
93 @Override
94 public Session getCurrentSession() throws NoSuchProviderException {
95
96 return null;
97 }
98
99
100
101
102 @Override
103 public void setConfig(Properties configProperties) {
104
105 super.setConfig(configProperties);
106 }
107
108 }