001 /*
002 * Copyright 2010 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package mocks;
017
018 import java.util.Properties;
019
020 import javax.mail.Address;
021 import javax.mail.Authenticator;
022 import javax.mail.MessagingException;
023 import javax.mail.NoSuchProviderException;
024 import javax.mail.Session;
025 import javax.mail.internet.AddressException;
026 import javax.mail.internet.InternetAddress;
027
028 import org.kuali.rice.kew.mail.Mailer;
029
030 public class MockMailer extends Mailer{
031
032 public MockMailer(Properties configProperties) {
033 super(null);
034 }
035 public MockMailer(Properties configProperties, Authenticator authenticator) {
036 super(null,null);
037 }
038 public MockMailer(Properties configProperties, String username, String password) {
039 super(null,null,null);
040 }
041
042 /* (non-Javadoc)
043 * @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)
044 */
045 @Override
046 public void sendMessage(String sender, Address[] recipients,
047 String subject, String messageBody, Address[] ccRecipients,
048 Address[] bccRecipients, boolean htmlMessage)
049 throws AddressException, MessagingException {
050
051 String toValue = "";
052 for(Address a: recipients){
053 toValue += a.toString();
054 }
055 //String toValue = (recipients == null) ? "" : recipients.toString();
056 String fromValue = (sender == null) ? "" : sender;
057 String subjectValue = (subject == null) ? "" : subject;
058 String bodyValue = (messageBody == null) ? "" : messageBody;
059 LOG.info("\nWILL NOT send e-mail message with to '" + toValue + "'... \nfrom '" + fromValue + "'... \nsubject '" + subjectValue + "'... and \nbody '" + bodyValue);
060 }
061
062 /* (non-Javadoc)
063 * @see org.kuali.rice.kew.mail.Mailer#sendMessage(java.lang.String, java.lang.String, java.lang.String, java.lang.String, boolean)
064 */
065 @Override
066 public void sendMessage(String sender, String recipient, String subject, String messageBody, boolean htmlMessage) throws AddressException, MessagingException {
067 final Address[] NO_RECIPIENTS = null;
068 Address[] recipients = { new InternetAddress(recipient) };
069 sendMessage(sender, recipients, subject, messageBody, NO_RECIPIENTS, NO_RECIPIENTS, htmlMessage);
070 }
071
072 /* (non-Javadoc)
073 * @see org.kuali.rice.kew.mail.Mailer#getAuthenticator()
074 */
075 @Override
076 public Authenticator getAuthenticator() {
077 // TODO Auto-generated method stub
078 return null;
079 }
080
081 /* (non-Javadoc)
082 * @see org.kuali.rice.kew.mail.Mailer#getConfig()
083 */
084 @Override
085 public Properties getConfig() {
086
087 return null;
088 }
089
090 /* (non-Javadoc)
091 * @see org.kuali.rice.kew.mail.Mailer#getCurrentSession()
092 */
093 @Override
094 public Session getCurrentSession() throws NoSuchProviderException {
095 // TODO Auto-generated method stub
096 return null;
097 }
098
099 /* (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 }