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