Rev 3 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3 | Rev 9 | ||
---|---|---|---|
Line 9... | Line 9... | ||
9 | import javax.mail.internet.AddressException; |
9 | import javax.mail.internet.AddressException; |
10 | 10 | ||
11 | import org.junit.Test; |
11 | import org.junit.Test; |
12 | 12 | ||
13 | import de.viathinksoft.utils.mail.EMailAddress; |
13 | import de.viathinksoft.utils.mail.EMailAddress; |
14 | import de.viathinksoft.utils.mail.InvalidMailAddressException; |
- | |
15 | import de.viathinksoft.utils.mail.sender.PlainTextMailSender; |
14 | import de.viathinksoft.utils.mail.sender.PlainTextMailSender; |
- | 15 | import eMailTests.TestConfiguration; |
|
16 | 16 | ||
17 | public class RawMailSenderPlainTextTest { |
17 | public class RawMailSenderPlainTextTest { |
18 | @Test |
18 | @Test |
19 | public void testPostMailNullPointer() throws MessagingException, |
19 | public void testPostMailNullPointer() throws MessagingException, |
20 | AuthentificateDataIncompleteException, InvalidMailAddressException { |
20 | AuthentificateDataIncompleteException { |
21 | PlainTextMailSender mailsender = new PlainTextMailSender(); |
21 | PlainTextMailSender mailsender = new PlainTextMailSender(); |
22 | 22 | ||
23 | try { |
23 | try { |
24 | mailsender.sendMail(); |
24 | mailsender.sendMail(); |
25 | fail(); |
25 | fail(); |
Line 40... | Line 40... | ||
40 | // ----------------------------------------------------- |
40 | // ----------------------------------------------------- |
41 | 41 | ||
42 | try { |
42 | try { |
43 | mailsender.setRecipient((EMailAddress)null); |
43 | mailsender.setRecipient((EMailAddress)null); |
44 | fail(); |
44 | fail(); |
45 | } catch (InvalidMailAddressException e1) { |
45 | } catch (NullPointerException e1) { |
46 | } |
46 | } |
47 | 47 | ||
48 | try { |
48 | try { |
49 | mailsender.sendMail(); |
49 | mailsender.sendMail(); |
50 | fail(); |
50 | fail(); |
Line 65... | Line 65... | ||
65 | // ----------------------------------------------------- |
65 | // ----------------------------------------------------- |
66 | 66 | ||
67 | try { |
67 | try { |
68 | mailsender.setRecipient((String)null); |
68 | mailsender.setRecipient((String)null); |
69 | fail(); |
69 | fail(); |
70 | } catch (InvalidMailAddressException e1) { |
70 | } catch (NullPointerException e1) { |
71 | } |
71 | } |
72 | 72 | ||
73 | try { |
73 | try { |
74 | mailsender.sendMail(); |
74 | mailsender.sendMail(); |
75 | fail(); |
75 | fail(); |
Line 134... | Line 134... | ||
134 | mailsender.setSmtpAuth(false); |
134 | mailsender.setSmtpAuth(false); |
135 | 135 | ||
136 | try { |
136 | try { |
137 | mailsender.setMailFrom((EMailAddress)null); |
137 | mailsender.setMailFrom((EMailAddress)null); |
138 | fail(); |
138 | fail(); |
139 | } catch (InvalidMailAddressException e1) { |
139 | } catch (NullPointerException e1) { |
140 | } |
140 | } |
141 | mailsender.setSubject(null); |
141 | mailsender.setSubject(null); |
142 | mailsender.setMessage(null); |
142 | mailsender.setMessage(null); |
143 | 143 | ||
144 | try { |
144 | try { |
Line 151... | Line 151... | ||
151 | // ----------------------------------------------------- |
151 | // ----------------------------------------------------- |
152 | 152 | ||
153 | try { |
153 | try { |
154 | mailsender.setMailFrom((String)null); |
154 | mailsender.setMailFrom((String)null); |
155 | fail(); |
155 | fail(); |
156 | } catch (InvalidMailAddressException e1) { |
156 | } catch (NullPointerException e1) { |
157 | } |
157 | } |
158 | 158 | ||
159 | try { |
159 | try { |
160 | mailsender.sendMail(); |
160 | mailsender.sendMail(); |
161 | } catch (AuthenticationFailedException e) { |
161 | } catch (AuthenticationFailedException e) { |
Line 172... | Line 172... | ||
172 | mailsender.sendMail(); |
172 | mailsender.sendMail(); |
173 | } |
173 | } |
174 | 174 | ||
175 | @Test |
175 | @Test |
176 | public void testPostMailBlank() |
176 | public void testPostMailBlank() |
177 | throws AuthentificateDataIncompleteException, InvalidMailAddressException { |
177 | throws AuthentificateDataIncompleteException { |
178 | PlainTextMailSender mailsender = new PlainTextMailSender(); |
178 | PlainTextMailSender mailsender = new PlainTextMailSender(); |
179 | 179 | ||
180 | mailsender.setRecipient(TestConfiguration.getSpamAddress()); |
180 | mailsender.setRecipient(TestConfiguration.getSpamAddress()); |
181 | mailsender.setSubject("JUnit-Test 1"); |
181 | mailsender.setSubject("JUnit-Test 1"); |
182 | mailsender.setMessage("JUnit-Test 1 von Compuglobal"); |
182 | mailsender.setMessage("JUnit-Test 1 von Compuglobal"); |
Line 198... | Line 198... | ||
198 | } |
198 | } |
199 | } |
199 | } |
200 | 200 | ||
201 | @Test |
201 | @Test |
202 | public void testPostMailWithData() throws MessagingException, |
202 | public void testPostMailWithData() throws MessagingException, |
203 | AuthentificateDataIncompleteException, InvalidMailAddressException |
203 | AuthentificateDataIncompleteException |
204 | { |
204 | { |
205 | PlainTextMailSender mailsender = new PlainTextMailSender(); |
205 | PlainTextMailSender mailsender = new PlainTextMailSender(); |
206 | 206 | ||
207 | mailsender.setSmtpHost(TestConfiguration.getSmtpHost()); |
207 | mailsender.setSmtpHost(TestConfiguration.getSmtpHost()); |
208 | mailsender.setSmtpPort(TestConfiguration.getSmtpPort()); |
208 | mailsender.setSmtpPort(TestConfiguration.getSmtpPort()); |
Line 219... | Line 219... | ||
219 | } |
219 | } |
220 | } |
220 | } |
221 | 221 | ||
222 | @Test |
222 | @Test |
223 | public void testPostMailWithDataAndOrigin() throws MessagingException, |
223 | public void testPostMailWithDataAndOrigin() throws MessagingException, |
224 | AuthentificateDataIncompleteException, InvalidMailAddressException { |
224 | AuthentificateDataIncompleteException { |
225 | PlainTextMailSender mailsender = new PlainTextMailSender(); |
225 | PlainTextMailSender mailsender = new PlainTextMailSender(); |
226 | 226 | ||
227 | mailsender.setSmtpHost(TestConfiguration.getSmtpHost()); |
227 | mailsender.setSmtpHost(TestConfiguration.getSmtpHost()); |
228 | mailsender.setSmtpPort(TestConfiguration.getSmtpPort()); |
228 | mailsender.setSmtpPort(TestConfiguration.getSmtpPort()); |
229 | 229 | ||
Line 241... | Line 241... | ||
241 | } |
241 | } |
242 | } |
242 | } |
243 | 243 | ||
244 | @Test |
244 | @Test |
245 | public void testPostMailWithDataAndOriginAndSmtpAuthIncompleteUserAndPwd() |
245 | public void testPostMailWithDataAndOriginAndSmtpAuthIncompleteUserAndPwd() |
246 | throws MessagingException, InvalidMailAddressException { |
246 | throws MessagingException { |
247 | PlainTextMailSender mailsender = new PlainTextMailSender(); |
247 | PlainTextMailSender mailsender = new PlainTextMailSender(); |
248 | 248 | ||
249 | mailsender.setSmtpHost(TestConfiguration.getSmtpHost()); |
249 | mailsender.setSmtpHost(TestConfiguration.getSmtpHost()); |
250 | // mailsender.setSmtpUsername(TestConfiguration.getSmtpUsername()); |
250 | // mailsender.setSmtpUsername(TestConfiguration.getSmtpUsername()); |
251 | // mailsender.setSmtpPassword(TestConfiguration.getSmtpPassword()); |
251 | // mailsender.setSmtpPassword(TestConfiguration.getSmtpPassword()); |
Line 267... | Line 267... | ||
267 | } |
267 | } |
268 | } |
268 | } |
269 | 269 | ||
270 | @Test |
270 | @Test |
271 | public void testPostMailWithDataAndOriginAndSmtpAuthIncompleteUser() |
271 | public void testPostMailWithDataAndOriginAndSmtpAuthIncompleteUser() |
272 | throws MessagingException, InvalidMailAddressException { |
272 | throws MessagingException { |
273 | PlainTextMailSender mailsender = new PlainTextMailSender(); |
273 | PlainTextMailSender mailsender = new PlainTextMailSender(); |
274 | 274 | ||
275 | mailsender.setSmtpHost(TestConfiguration.getSmtpHost()); |
275 | mailsender.setSmtpHost(TestConfiguration.getSmtpHost()); |
276 | // mailsender.setSmtpUsername(TestConfiguration.getSmtpUsername()); |
276 | // mailsender.setSmtpUsername(TestConfiguration.getSmtpUsername()); |
277 | mailsender.setSmtpPassword(TestConfiguration.getSmtpPassword()); |
277 | mailsender.setSmtpPassword(TestConfiguration.getSmtpPassword()); |
Line 293... | Line 293... | ||
293 | } |
293 | } |
294 | } |
294 | } |
295 | 295 | ||
296 | @Test |
296 | @Test |
297 | public void testPostMailWithDataAndOriginAndSmtpAuthIncompletePwd() |
297 | public void testPostMailWithDataAndOriginAndSmtpAuthIncompletePwd() |
298 | throws MessagingException, InvalidMailAddressException { |
298 | throws MessagingException { |
299 | PlainTextMailSender mailsender = new PlainTextMailSender(); |
299 | PlainTextMailSender mailsender = new PlainTextMailSender(); |
300 | 300 | ||
301 | mailsender.setSmtpHost(TestConfiguration.getSmtpHost()); |
301 | mailsender.setSmtpHost(TestConfiguration.getSmtpHost()); |
302 | mailsender.setSmtpUsername(TestConfiguration.getSmtpUsername()); |
302 | mailsender.setSmtpUsername(TestConfiguration.getSmtpUsername()); |
303 | // mailsender.setSmtpPassword(TestConfiguration.getSmtpPassword()); |
303 | // mailsender.setSmtpPassword(TestConfiguration.getSmtpPassword()); |
Line 319... | Line 319... | ||
319 | } |
319 | } |
320 | } |
320 | } |
321 | 321 | ||
322 | @Test |
322 | @Test |
323 | public void testPostMailWithDataAndOriginAndSmtpAuthComplete() |
323 | public void testPostMailWithDataAndOriginAndSmtpAuthComplete() |
324 | throws MessagingException, AuthentificateDataIncompleteException, InvalidMailAddressException { |
324 | throws MessagingException, AuthentificateDataIncompleteException { |
325 | PlainTextMailSender mailsender = new PlainTextMailSender(); |
325 | PlainTextMailSender mailsender = new PlainTextMailSender(); |
326 | 326 | ||
327 | mailsender.setSmtpHost(TestConfiguration.getSmtpHost()); |
327 | mailsender.setSmtpHost(TestConfiguration.getSmtpHost()); |
328 | mailsender.setSmtpUsername(TestConfiguration.getSmtpUsername()); |
328 | mailsender.setSmtpUsername(TestConfiguration.getSmtpUsername()); |
329 | mailsender.setSmtpPassword(TestConfiguration.getSmtpPassword()); |
329 | mailsender.setSmtpPassword(TestConfiguration.getSmtpPassword()); |