1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package org.apache.commons.mail.mocks;
18
19 import java.io.IOException;
20 import java.util.List;
21 import java.util.Map;
22
23 import javax.mail.MessagingException;
24 import javax.mail.internet.InternetAddress;
25
26 import org.apache.commons.mail.HtmlEmail;
27
28 /**
29 * Extension of the HtmlEmail Class
30 * (used to allow testing only)
31 *
32 * @since 1.0
33 * @author <a href="mailto:corey.scott@gmail.com">Corey Scott</a>
34 * @version $Id: MockHtmlEmailConcrete.java 1420381 2012-12-11 20:18:05Z tn $
35 */
36 public class MockHtmlEmailConcrete extends HtmlEmail
37 {
38 /**
39 * Retrieve the message content
40 * @return Message Content
41 */
42 public String getMsg()
43 {
44 try
45 {
46 return this.getPrimaryBodyPart().getContent().toString();
47 }
48 catch (IOException ioE)
49 {
50 return null;
51 }
52 catch (MessagingException msgE)
53 {
54 return null;
55 }
56 }
57
58 /**
59 * Retrieve the text msg
60 * @return Message Content
61 */
62 public String getTextMsg()
63 {
64 return this.text;
65 }
66
67 /**
68 * Retrieve the html msg
69 * @return Message Content
70 */
71 public String getHtmlMsg()
72 {
73 return this.html;
74 }
75
76 /**
77 * @deprecated as of commons-email 1.1, replaced by {@link #getInlineEmbeds}.
78 */
79 @Deprecated
80 public List getInlineImages()
81 {
82 return inlineImages;
83 }
84
85 /**
86 * @return inlineEmbeds
87 */
88 public Map getInlineEmbeds()
89 {
90 return inlineEmbeds;
91 }
92
93 /**
94 * @return fromAddress
95 */
96 @Override
97 public InternetAddress getFromAddress()
98 {
99 return this.fromAddress;
100 }
101
102 }