Rev 3 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3 | Rev 9 | ||
---|---|---|---|
1 | package de.viathinksoft.utils.mail.sender; |
1 | package de.viathinksoft.utils.mail.sender; |
2 | 2 | ||
3 | import static org.junit.Assert.fail; |
3 | import static org.junit.Assert.fail; |
4 | 4 | ||
5 | import java.net.ConnectException; |
5 | import java.net.ConnectException; |
6 | 6 | ||
7 | import javax.mail.AuthenticationFailedException; |
7 | import javax.mail.AuthenticationFailedException; |
8 | import javax.mail.MessagingException; |
8 | import javax.mail.MessagingException; |
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(); |
26 | } catch (AddressException e) { |
26 | } catch (AddressException e) { |
27 | } catch (MessagingException e) { |
27 | } catch (MessagingException e) { |
28 | // if ((e.getCause() != null) && (e.getCause().getNextException() == |
28 | // if ((e.getCause() != null) && (e.getCause().getNextException() == |
29 | // ConnectException)) { |
29 | // ConnectException)) { |
30 | if ((e.getCause() != null) |
30 | if ((e.getCause() != null) |
31 | && (e.getCause().getClass() == ConnectException.class)) { |
31 | && (e.getCause().getClass() == ConnectException.class)) { |
32 | // Wir erwarten eine Exception, da wir davon ausgehen, dass auf |
32 | // Wir erwarten eine Exception, da wir davon ausgehen, dass auf |
33 | // Localhost kein SMTP-Server läuft! |
33 | // Localhost kein SMTP-Server läuft! |
34 | } else { |
34 | } else { |
35 | e.printStackTrace(); |
35 | e.printStackTrace(); |
36 | fail(); |
36 | fail(); |
37 | } |
37 | } |
38 | } |
38 | } |
39 | 39 | ||
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(); |
51 | } catch (AddressException e) { |
51 | } catch (AddressException e) { |
52 | } catch (MessagingException e) { |
52 | } catch (MessagingException e) { |
53 | // if ((e.getCause() != null) && (e.getCause().getNextException() == |
53 | // if ((e.getCause() != null) && (e.getCause().getNextException() == |
54 | // ConnectException)) { |
54 | // ConnectException)) { |
55 | if ((e.getCause() != null) |
55 | if ((e.getCause() != null) |
56 | && (e.getCause().getClass() == ConnectException.class)) { |
56 | && (e.getCause().getClass() == ConnectException.class)) { |
57 | // Wir erwarten eine Exception, da wir davon ausgehen, dass auf |
57 | // Wir erwarten eine Exception, da wir davon ausgehen, dass auf |
58 | // Localhost kein SMTP-Server läuft! |
58 | // Localhost kein SMTP-Server läuft! |
59 | } else { |
59 | } else { |
60 | e.printStackTrace(); |
60 | e.printStackTrace(); |
61 | fail(); |
61 | fail(); |
62 | } |
62 | } |
63 | } |
63 | } |
64 | 64 | ||
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(); |
76 | } catch (AddressException e) { |
76 | } catch (AddressException e) { |
77 | } catch (MessagingException e) { |
77 | } catch (MessagingException e) { |
78 | // if ((e.getCause() != null) && (e.getCause().getNextException() == |
78 | // if ((e.getCause() != null) && (e.getCause().getNextException() == |
79 | // ConnectException)) { |
79 | // ConnectException)) { |
80 | if ((e.getCause() != null) |
80 | if ((e.getCause() != null) |
81 | && (e.getCause().getClass() == ConnectException.class)) { |
81 | && (e.getCause().getClass() == ConnectException.class)) { |
82 | // Wir erwarten eine Exception, da wir davon ausgehen, dass auf |
82 | // Wir erwarten eine Exception, da wir davon ausgehen, dass auf |
83 | // Localhost kein SMTP-Server läuft! |
83 | // Localhost kein SMTP-Server läuft! |
84 | } else { |
84 | } else { |
85 | e.printStackTrace(); |
85 | e.printStackTrace(); |
86 | fail(); |
86 | fail(); |
87 | } |
87 | } |
88 | } |
88 | } |
89 | 89 | ||
90 | // ----------------------------------------------------- |
90 | // ----------------------------------------------------- |
91 | 91 | ||
92 | mailsender.setRecipient(TestConfiguration.getSpamAddress()); |
92 | mailsender.setRecipient(TestConfiguration.getSpamAddress()); |
93 | 93 | ||
94 | mailsender.setSmtpHost(null); |
94 | mailsender.setSmtpHost(null); |
95 | mailsender.setSmtpUsername(null); |
95 | mailsender.setSmtpUsername(null); |
96 | mailsender.setSmtpPassword(null); |
96 | mailsender.setSmtpPassword(null); |
97 | mailsender.setSmtpPort(-1); |
97 | mailsender.setSmtpPort(-1); |
98 | 98 | ||
99 | try { |
99 | try { |
100 | mailsender.sendMail(); |
100 | mailsender.sendMail(); |
101 | fail(); |
101 | fail(); |
102 | } catch (MessagingException e) { |
102 | } catch (MessagingException e) { |
103 | // if ((e.getCause() != null) && (e.getCause().getNextException() == |
103 | // if ((e.getCause() != null) && (e.getCause().getNextException() == |
104 | // ConnectException)) { |
104 | // ConnectException)) { |
105 | if ((e.getCause() != null) |
105 | if ((e.getCause() != null) |
106 | && (e.getCause().getClass() == ConnectException.class)) { |
106 | && (e.getCause().getClass() == ConnectException.class)) { |
107 | // Wir erwarten eine Exception, da wir davon ausgehen, dass auf |
107 | // Wir erwarten eine Exception, da wir davon ausgehen, dass auf |
108 | // Localhost kein SMTP-Server läuft! |
108 | // Localhost kein SMTP-Server läuft! |
109 | } else { |
109 | } else { |
110 | e.printStackTrace(); |
110 | e.printStackTrace(); |
111 | fail(); |
111 | fail(); |
112 | } |
112 | } |
113 | } |
113 | } |
114 | 114 | ||
115 | // ----------------------------------------------------- |
115 | // ----------------------------------------------------- |
116 | 116 | ||
117 | mailsender.setSmtpHost(TestConfiguration.getSmtpHost()); |
117 | mailsender.setSmtpHost(TestConfiguration.getSmtpHost()); |
118 | mailsender.setSmtpUsername(null); |
118 | mailsender.setSmtpUsername(null); |
119 | mailsender.setSmtpPassword(null); |
119 | mailsender.setSmtpPassword(null); |
120 | mailsender.setSmtpPort(TestConfiguration.getSmtpPort()); |
120 | mailsender.setSmtpPort(TestConfiguration.getSmtpPort()); |
121 | 121 | ||
122 | mailsender.setSmtpAuth(true); |
122 | mailsender.setSmtpAuth(true); |
123 | // mailsender.setSmtpAuthUser(null); |
123 | // mailsender.setSmtpAuthUser(null); |
124 | // mailsender.setSmtpAuthPass(null); |
124 | // mailsender.setSmtpAuthPass(null); |
125 | 125 | ||
126 | try { |
126 | try { |
127 | mailsender.sendMail(); |
127 | mailsender.sendMail(); |
128 | fail(); |
128 | fail(); |
129 | } catch (AuthentificateDataIncompleteException e) { |
129 | } catch (AuthentificateDataIncompleteException e) { |
130 | } |
130 | } |
131 | 131 | ||
132 | // ----------------------------------------------------- |
132 | // ----------------------------------------------------- |
133 | 133 | ||
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 { |
145 | mailsender.sendMail(); |
145 | mailsender.sendMail(); |
146 | } catch (AuthenticationFailedException e) { |
146 | } catch (AuthenticationFailedException e) { |
147 | // Diese Fehlermeldung KANN vom SMTP geworfen werden. MUSS aber |
147 | // Diese Fehlermeldung KANN vom SMTP geworfen werden. MUSS aber |
148 | // nicht. |
148 | // nicht. |
149 | } |
149 | } |
150 | 150 | ||
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) { |
162 | // Diese Fehlermeldung KANN vom SMTP geworfen werden. MUSS aber |
162 | // Diese Fehlermeldung KANN vom SMTP geworfen werden. MUSS aber |
163 | // nicht. |
163 | // nicht. |
164 | } |
164 | } |
165 | 165 | ||
166 | // ----------------------------------------------------- |
166 | // ----------------------------------------------------- |
167 | 167 | ||
168 | mailsender.setSmtpAuth(true); |
168 | mailsender.setSmtpAuth(true); |
169 | mailsender.setSmtpUsername(TestConfiguration.getSmtpUsername()); |
169 | mailsender.setSmtpUsername(TestConfiguration.getSmtpUsername()); |
170 | mailsender.setSmtpPassword(TestConfiguration.getSmtpPassword()); |
170 | mailsender.setSmtpPassword(TestConfiguration.getSmtpPassword()); |
171 | 171 | ||
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"); |
183 | 183 | ||
184 | try { |
184 | try { |
185 | mailsender.sendMail(); |
185 | mailsender.sendMail(); |
186 | fail(); |
186 | fail(); |
187 | } catch (MessagingException e) { |
187 | } catch (MessagingException e) { |
188 | // if ((e.getCause() != null) && (e.getCause().getNextException() == |
188 | // if ((e.getCause() != null) && (e.getCause().getNextException() == |
189 | // ConnectException)) { |
189 | // ConnectException)) { |
190 | if ((e.getCause() != null) |
190 | if ((e.getCause() != null) |
191 | && (e.getCause().getClass() == ConnectException.class)) { |
191 | && (e.getCause().getClass() == ConnectException.class)) { |
192 | // Wir erwarten eine Exception, da wir davon ausgehen, dass auf |
192 | // Wir erwarten eine Exception, da wir davon ausgehen, dass auf |
193 | // Localhost kein SMTP-Server läuft! |
193 | // Localhost kein SMTP-Server läuft! |
194 | } else { |
194 | } else { |
195 | e.printStackTrace(); |
195 | e.printStackTrace(); |
196 | fail(); |
196 | fail(); |
197 | } |
197 | } |
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()); |
209 | 209 | ||
210 | mailsender.setRecipient(TestConfiguration.getSpamAddress()); |
210 | mailsender.setRecipient(TestConfiguration.getSpamAddress()); |
211 | mailsender.setSubject("JUnit-Test 2"); |
211 | mailsender.setSubject("JUnit-Test 2"); |
212 | mailsender.setMessage("JUnit-Test 2 von Compuglobal"); |
212 | mailsender.setMessage("JUnit-Test 2 von Compuglobal"); |
213 | 213 | ||
214 | try { |
214 | try { |
215 | mailsender.sendMail(); |
215 | mailsender.sendMail(); |
216 | } catch (AuthenticationFailedException e) { |
216 | } catch (AuthenticationFailedException e) { |
217 | // Diese Fehlermeldung KANN vom SMTP geworfen werden. MUSS aber |
217 | // Diese Fehlermeldung KANN vom SMTP geworfen werden. MUSS aber |
218 | // nicht. |
218 | // nicht. |
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 | ||
230 | mailsender.setMailFrom(TestConfiguration.getMailFrom()); |
230 | mailsender.setMailFrom(TestConfiguration.getMailFrom()); |
231 | 231 | ||
232 | mailsender.setRecipient(TestConfiguration.getSpamAddress()); |
232 | mailsender.setRecipient(TestConfiguration.getSpamAddress()); |
233 | mailsender.setSubject("JUnit-Test 3"); |
233 | mailsender.setSubject("JUnit-Test 3"); |
234 | mailsender.setMessage("JUnit-Test 3 von Compuglobal"); |
234 | mailsender.setMessage("JUnit-Test 3 von Compuglobal"); |
235 | 235 | ||
236 | try { |
236 | try { |
237 | mailsender.sendMail(); |
237 | mailsender.sendMail(); |
238 | } catch (AuthenticationFailedException e) { |
238 | } catch (AuthenticationFailedException e) { |
239 | // Diese Fehlermeldung KANN vom SMTP geworfen werden. MUSS aber |
239 | // Diese Fehlermeldung KANN vom SMTP geworfen werden. MUSS aber |
240 | // nicht. |
240 | // nicht. |
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()); |
252 | mailsender.setSmtpPort(TestConfiguration.getSmtpPort()); |
252 | mailsender.setSmtpPort(TestConfiguration.getSmtpPort()); |
253 | 253 | ||
254 | mailsender.setMailFrom(TestConfiguration.getMailFrom()); |
254 | mailsender.setMailFrom(TestConfiguration.getMailFrom()); |
255 | 255 | ||
256 | mailsender.setSmtpAuth(true); |
256 | mailsender.setSmtpAuth(true); |
257 | 257 | ||
258 | mailsender.setRecipient(TestConfiguration.getSpamAddress()); |
258 | mailsender.setRecipient(TestConfiguration.getSpamAddress()); |
259 | mailsender.setSubject("JUnit-Test 4a"); |
259 | mailsender.setSubject("JUnit-Test 4a"); |
260 | mailsender.setMessage("JUnit-Test 4a von Compuglobal"); |
260 | mailsender.setMessage("JUnit-Test 4a von Compuglobal"); |
261 | 261 | ||
262 | try { |
262 | try { |
263 | mailsender.sendMail(); |
263 | mailsender.sendMail(); |
264 | 264 | ||
265 | fail(); |
265 | fail(); |
266 | } catch (AuthentificateDataIncompleteException e) { |
266 | } catch (AuthentificateDataIncompleteException e) { |
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()); |
278 | mailsender.setSmtpPort(TestConfiguration.getSmtpPort()); |
278 | mailsender.setSmtpPort(TestConfiguration.getSmtpPort()); |
279 | 279 | ||
280 | mailsender.setMailFrom(TestConfiguration.getMailFrom()); |
280 | mailsender.setMailFrom(TestConfiguration.getMailFrom()); |
281 | 281 | ||
282 | mailsender.setSmtpAuth(true); |
282 | mailsender.setSmtpAuth(true); |
283 | 283 | ||
284 | mailsender.setRecipient(TestConfiguration.getSpamAddress()); |
284 | mailsender.setRecipient(TestConfiguration.getSpamAddress()); |
285 | mailsender.setSubject("JUnit-Test 4b"); |
285 | mailsender.setSubject("JUnit-Test 4b"); |
286 | mailsender.setMessage("JUnit-Test 4b von Compuglobal"); |
286 | mailsender.setMessage("JUnit-Test 4b von Compuglobal"); |
287 | 287 | ||
288 | try { |
288 | try { |
289 | mailsender.sendMail(); |
289 | mailsender.sendMail(); |
290 | 290 | ||
291 | fail(); |
291 | fail(); |
292 | } catch (AuthentificateDataIncompleteException e) { |
292 | } catch (AuthentificateDataIncompleteException e) { |
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()); |
304 | mailsender.setSmtpPort(TestConfiguration.getSmtpPort()); |
304 | mailsender.setSmtpPort(TestConfiguration.getSmtpPort()); |
305 | 305 | ||
306 | mailsender.setMailFrom(TestConfiguration.getMailFrom()); |
306 | mailsender.setMailFrom(TestConfiguration.getMailFrom()); |
307 | 307 | ||
308 | mailsender.setSmtpAuth(true); |
308 | mailsender.setSmtpAuth(true); |
309 | 309 | ||
310 | mailsender.setRecipient(TestConfiguration.getSpamAddress()); |
310 | mailsender.setRecipient(TestConfiguration.getSpamAddress()); |
311 | mailsender.setSubject("JUnit-Test 4c"); |
311 | mailsender.setSubject("JUnit-Test 4c"); |
312 | mailsender.setMessage("JUnit-Test 4c von Compuglobal"); |
312 | mailsender.setMessage("JUnit-Test 4c von Compuglobal"); |
313 | 313 | ||
314 | try { |
314 | try { |
315 | mailsender.sendMail(); |
315 | mailsender.sendMail(); |
316 | 316 | ||
317 | fail(); |
317 | fail(); |
318 | } catch (AuthentificateDataIncompleteException e) { |
318 | } catch (AuthentificateDataIncompleteException e) { |
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()); |
330 | mailsender.setSmtpPort(TestConfiguration.getSmtpPort()); |
330 | mailsender.setSmtpPort(TestConfiguration.getSmtpPort()); |
331 | 331 | ||
332 | mailsender.setMailFrom(TestConfiguration.getMailFrom()); |
332 | mailsender.setMailFrom(TestConfiguration.getMailFrom()); |
333 | 333 | ||
334 | mailsender.setSmtpAuth(true); |
334 | mailsender.setSmtpAuth(true); |
335 | 335 | ||
336 | mailsender.setRecipient(TestConfiguration.getSpamAddress()); |
336 | mailsender.setRecipient(TestConfiguration.getSpamAddress()); |
337 | mailsender.setSubject("JUnit-Test 4d"); |
337 | mailsender.setSubject("JUnit-Test 4d"); |
338 | mailsender.setMessage("JUnit-Test 4d von Compuglobal"); |
338 | mailsender.setMessage("JUnit-Test 4d von Compuglobal"); |
339 | 339 | ||
340 | mailsender.sendMail(); |
340 | mailsender.sendMail(); |
341 | } |
341 | } |
342 | } |
342 | } |
343 | 343 |