1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.mail;
17
18 import static org.junit.Assert.assertNotNull;
19 import junit.framework.Assert;
20
21 import org.junit.Test;
22 import org.kuali.rice.core.mail.EmailBody;
23 import org.kuali.rice.core.mail.EmailFrom;
24 import org.kuali.rice.core.mail.EmailSubject;
25 import org.kuali.rice.core.mail.EmailTo;
26 import org.kuali.rice.core.mail.Mailer;
27 import org.kuali.rice.kew.service.KEWServiceLocator;
28 import org.kuali.rice.kew.test.KEWTestCase;
29 import org.subethamail.wiser.Wiser;
30
31
32
33
34
35 public class MailerTest extends KEWTestCase {
36
37 private String sender = "testSender@test.kuali.org";
38 private String recipient = "testRecipient@test.kuali.org";
39 private String subject = "Test Subject";
40 private String messageBody = "Test Message Body";
41
42
43
44
45
46 @Test
47 public void testSendMessage() {
48
49 Wiser smtpServer = new Wiser();
50 smtpServer.setPort(55000);
51 smtpServer.start();
52
53
54 Mailer mailer = null;
55 mailer = KEWServiceLocator.getMailer();
56 assertNotNull(mailer);
57
58
59 mailer.sendEmail(new EmailFrom(sender), new EmailTo(recipient), new EmailSubject(subject), new EmailBody(messageBody), false);
60 Assert.assertEquals(1, smtpServer.getMessages().size());
61
62
63 smtpServer.stop();
64 }
65
66 }