View Javadoc

1   /*
2    * Copyright 2010 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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  	/* (non-Javadoc)
43  	 * @see org.kuali.rice.kew.mail.Mailer#sendMessage(java.lang.String, javax.mail.Address[], java.lang.String, java.lang.String, javax.mail.Address[], javax.mail.Address[], boolean)
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  		//String toValue = (recipients == null) ? "" : recipients.toString();
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  	/* (non-Javadoc)
63  	 * @see org.kuali.rice.kew.mail.Mailer#sendMessage(java.lang.String, java.lang.String, java.lang.String, java.lang.String, boolean)
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  	/* (non-Javadoc)
73  	 * @see org.kuali.rice.kew.mail.Mailer#getAuthenticator()
74  	 */
75  	@Override
76  	public Authenticator getAuthenticator() {
77  		// TODO Auto-generated method stub
78  		return null;
79  	}
80  
81  	/* (non-Javadoc)
82  	 * @see org.kuali.rice.kew.mail.Mailer#getConfig()
83  	 */
84  	@Override
85  	public Properties getConfig() {
86  
87  		return null;
88  	}
89  
90  	/* (non-Javadoc)
91  	 * @see org.kuali.rice.kew.mail.Mailer#getCurrentSession()
92  	 */
93  	@Override
94  	public Session getCurrentSession() throws NoSuchProviderException {
95  		// TODO Auto-generated method stub
96  		return null;
97  	}	
98  
99  	/* (non-Javadoc)
100 	 * @see org.kuali.rice.kew.mail.Mailer#setConfig(java.util.Properties)
101 	 */
102 	@Override
103 	public void setConfig(Properties configProperties) {
104 		// TODO Auto-generated method stub
105 		super.setConfig(configProperties);
106 	}
107 
108 }