001    /*
002     * Copyright 2007-2008 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 org.apache.log4j.Logger;
019    import org.kuali.rice.kew.mail.EmailBody;
020    import org.kuali.rice.kew.mail.EmailFrom;
021    import org.kuali.rice.kew.mail.EmailSubject;
022    import org.kuali.rice.kew.mail.EmailTo;
023    import org.kuali.rice.kew.mail.service.impl.DefaultEmailService;
024    
025    
026    /**
027     * This class is used to disallow email sending for KEW tests 
028     * 
029     * @author Kuali Rice Team (rice.collab@kuali.org)
030     *
031     */
032    public class MockDefaultEmailServiceImpl extends DefaultEmailService {
033        private static final Logger LOG = Logger.getLogger(MockDefaultEmailServiceImpl.class);
034    
035        /**
036         * MOCK METHOD USED TO OVERRIDE EMAIL DELIVERY
037         */
038        @Override
039        public void sendEmail(EmailFrom from, EmailTo to, EmailSubject subject, EmailBody body, boolean htmlMessage) {
040            String toValue = (to == null) ? "" : to.getToAddress();
041            String fromValue = (from == null) ? "" : from.getFromAddress();
042            String subjectValue = (subject == null) ? "" : subject.getSubject();
043            String bodyValue = (body == null) ? "" : body.getBody();
044            LOG.debug("WILL NOT send e-mail message with to '" + toValue + "'... from '" + fromValue + "'... subject '" + subjectValue + "'... and body '" + bodyValue);
045        }
046    }