View Javadoc

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.util.Map;
20  
21  import javax.mail.Authenticator;
22  import javax.mail.Session;
23  import javax.mail.internet.InternetAddress;
24  import javax.mail.internet.MimeMessage;
25  import javax.mail.internet.MimeMultipart;
26  
27  import org.apache.commons.mail.Email;
28  import org.apache.commons.mail.EmailException;
29  
30  /**
31   * Concrete Implementation on the Abstract Email
32   * Class (used to allow testing only).  Supplies
33   * getters for methods that normally only have setters.
34   *
35   * @since 1.0
36   * @author <a href="mailto:corey.scott@gmail.com">Corey Scott</a>
37   * @version $Id: MockEmailConcrete.java 1429382 2013-01-05 20:39:12Z tn $
38   */
39  public class MockEmailConcrete extends Email
40  {
41  
42      /**
43       * Not Implemented, should be implemented in subclasses of Email
44       * @param msg The email message
45       * @return Email msg.
46       */
47      @Override
48      public Email setMsg(String msg)
49      {
50          // This abstract method should be tested in the concrete
51          // implementation classes only.
52          return null;
53      }
54  
55      /**
56       * Retrieve the current debug setting
57       * @return debug
58       */
59      public boolean isDebug()
60      {
61          return this.debug;
62      }
63  
64      /**
65       * Retrieve the current authentication setting
66       * @return Authenticator Authenticator
67       */
68      public Authenticator getAuthenticator()
69      {
70          return this.authenticator;
71      }
72  
73      /**
74       * @return charset
75       */
76      public String getCharset()
77      {
78          return this.charset;
79      }
80  
81      /**
82       * @return content
83       */
84      public Object getContentObject()
85      {
86          return this.content;
87      }
88  
89      /**
90       * @return content
91       */
92      public MimeMultipart getContentMimeMultipart()
93      {
94          return this.emailBody;
95      }
96  
97      /**
98       * @return emailBody
99       */
100     public MimeMultipart getEmailBody()
101     {
102         return this.emailBody;
103     }
104 
105     /**
106      * @return fromAddress
107      */
108     @Override
109     public InternetAddress getFromAddress()
110     {
111         return this.fromAddress;
112     }
113 
114     /**
115      * @return headers
116      */
117     public Map<String, String> getHeaders()
118     {
119         return this.headers;
120     }
121 
122     /**
123      * @return hostName
124      */
125     @Override
126     public String getHostName()
127     {
128         return this.hostName;
129     }
130 
131     /**
132      * @return message
133      */
134     public MimeMessage getMessage()
135     {
136         return this.message;
137     }
138 
139     /**
140      * @return popHost
141      */
142     public String getPopHost()
143     {
144         return this.popHost;
145     }
146 
147     /**
148      * @return popPassword
149      */
150     public String getPopPassword()
151     {
152         return this.popPassword;
153     }
154 
155     /**
156      * @return popUsername
157      */
158     public String getPopUsername()
159     {
160         return this.popUsername;
161     }
162 
163     /**
164      * @return contentType
165      */
166     public String getContentType()
167     {
168         return contentType;
169     }
170 
171     /**
172      * @return popBeforeSmtp
173      */
174     public boolean isPopBeforeSmtp()
175     {
176         return popBeforeSmtp;
177     }
178 
179     /**
180      * @return Session
181      * @throws EmailException EmailException
182      */
183     public Session getSession()
184         throws EmailException
185     {
186         return this.getMailSession();
187     }
188 
189 }