-
Notifications
You must be signed in to change notification settings - Fork 182
/
ExampleRuleTest.java
30 lines (24 loc) · 1.05 KB
/
ExampleRuleTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package com.icegreen.greenmail.examples;
import com.icegreen.greenmail.junit.GreenMailRule;
import com.icegreen.greenmail.util.GreenMailUtil;
import com.icegreen.greenmail.util.ServerSetupTest;
import org.junit.Rule;
import org.junit.Test;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
import java.io.IOException;
import static org.assertj.core.api.Assertions.assertThat;
public class ExampleRuleTest {
@Rule
public final GreenMailRule greenMail = new GreenMailRule(ServerSetupTest.SMTP_IMAP);
@Test
public void testSomething() throws MessagingException, IOException {
GreenMailUtil.sendTextEmailTest("to@localhost", "from@localhost", "subject", "content");
MimeMessage[] emails = greenMail.getReceivedMessages();
assertThat(emails.length).isEqualTo(1);
assertThat(emails[0].getSubject()).isEqualTo("subject");
assertThat(emails[0].getContentType()).isEqualTo("text/plain; charset=us-ascii");
assertThat(emails[0].getContent()).isEqualTo("content");
// ...
}
}