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 javax.mail.Address;
19  import javax.mail.MessagingException;
20  import javax.mail.internet.AddressException;
21  
22  import org.kuali.rice.core.mail.Mailer;
23  
24  public class MockMailer extends Mailer{
25  
26  	/* (non-Javadoc)
27  	 * @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)
28  	 */
29  	@Override
30  	public void sendMessage(String sender, Address[] recipients,
31  			String subject, String messageBody, Address[] ccRecipients,
32  			Address[] bccRecipients, boolean htmlMessage)
33  			throws AddressException, MessagingException {
34  		
35  		String toValue = "";
36  		for(Address a: recipients){
37  			toValue += a.toString();
38  		}
39  		//String toValue = (recipients == null) ? "" : recipients.toString();
40          String fromValue = (sender == null) ? "" : sender;
41          String subjectValue = (subject == null) ? "" : subject;
42          String bodyValue = (messageBody == null) ? "" : messageBody;
43          LOG.info("\nWILL NOT send e-mail message with to '" + toValue + "'... \nfrom '" + fromValue + "'... \nsubject '" + subjectValue + "'... and \nbody '" + bodyValue);
44  	}
45  }