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.api.CoreApiServiceLocator;
23 import org.kuali.rice.core.api.mail.EmailBody;
24 import org.kuali.rice.core.api.mail.EmailFrom;
25 import org.kuali.rice.core.api.mail.EmailSubject;
26 import org.kuali.rice.core.api.mail.EmailTo;
27 import org.kuali.rice.core.api.mail.Mailer;
28 import org.kuali.rice.kew.service.KEWServiceLocator;
29 import org.kuali.rice.kew.test.KEWTestCase;
30 import org.subethamail.wiser.Wiser;
31
32
33
34
35
36 public class MailerTest extends KEWTestCase {
37
38 private String sender = "testSender@test.kuali.org";
39 private String recipient = "testRecipient@test.kuali.org";
40 private String subject = "Test Subject";
41 private String messageBody = "Test Message Body";
42
43
44
45
46
47 @Test
48 public void testSendMessage() {
49
50 Wiser smtpServer = new Wiser();
51 smtpServer.setPort(55000);
52 smtpServer.start();
53
54
55 Mailer mailer = null;
56 mailer = CoreApiServiceLocator.getMailer();
57 assertNotNull(mailer);
58
59
60 mailer.sendEmail(new EmailFrom(sender), new EmailTo(recipient), new EmailSubject(subject), new EmailBody(messageBody), false);
61 Assert.assertEquals(1, smtpServer.getMessages().size());
62
63
64 smtpServer.stop();
65 }
66
67 }