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