1818
1919package org .suren .autotest .web .framework .mail ;
2020
21+ import org .junit .Ignore ;
2122import org .junit .Test ;
2223import org .junit .runner .RunWith ;
2324import org .springframework .beans .factory .annotation .Autowired ;
24- import org .springframework .context . annotation . Configuration ;
25+ import org .springframework .core . io . ByteArrayResource ;
2526import org .springframework .mail .MailSender ;
2627import org .springframework .mail .SimpleMailMessage ;
28+ import org .springframework .mail .javamail .JavaMailSenderImpl ;
29+ import org .springframework .mail .javamail .MimeMessageHelper ;
2730import org .springframework .test .context .ContextConfiguration ;
2831import org .springframework .test .context .junit4 .SpringJUnit4ClassRunner ;
2932import org .suren .autotest .web .framework .AutoApplicationConfig ;
3033import org .suren .autotest .web .framework .AutoTestConfig ;
31- import org .suren .autotest .web .framework .util .EncryptorUtil ;
34+
35+ import javax .mail .MessagingException ;
36+ import javax .mail .internet .MimeMessage ;
37+
3238
3339/**
3440 * @author suren
@@ -41,7 +47,8 @@ public class MailTest
4147 private MailSender mailSender ;
4248
4349 @ Test
44- public void mailSend ()
50+ @ Ignore
51+ public void simpleMail ()
4552 {
4653 SimpleMailMessage msg = new SimpleMailMessage ();
4754@@ -50,4 +57,20 @@ public void mailSend()
5057 msg .setSubject ("subject" );
5158 mailSender .send (msg );
5259 }
60+
61+ @ Test
62+ @ Ignore
63+ public void mimeMail () throws MessagingException
64+ {
65+ MimeMessage msg = ((JavaMailSenderImpl ) mailSender ).createMimeMessage ();
66+ MimeMessageHelper mail = new MimeMessageHelper (msg , true );
67+ mail .addAttachment ("attach_for_test" ,
68+ new ByteArrayResource ("attach_for_test" .getBytes ()));
69+ mail .
setFrom (
"[email protected] " );
70+ 71+ mail .setText ("context" );
72+ mail .setSubject ("subject" );
73+
74+ ((JavaMailSenderImpl ) mailSender ).send (msg );
75+ }
5376}
0 commit comments