use of com.icegreen.greenmail.util.Retriever in project greenmail by greenmail-mail-test.
the class ExampleDisableAuthenticationTest method testNoAuthIMAP.
@Test
public void testNoAuthIMAP() {
try (Retriever retriever = new Retriever(greenMail.getImap())) {
Message[] messages = retriever.getMessages("foo@localhost");
assertThat(messages.length).isEqualTo(0);
}
}
use of com.icegreen.greenmail.util.Retriever in project greenmail by greenmail-mail-test.
the class ExampleDisableAuthenticationTest method testExistingUserNotRecreated.
@Test
public void testExistingUserNotRecreated() {
try (Retriever retriever = new Retriever(greenMail.getImap())) {
Message[] messages = retriever.getMessages("foo@localhost");
assertThat(messages.length).isEqualTo(0);
assertThat(greenMail.getUserManager().hasUser("foo@localhost")).isTrue();
}
}
use of com.icegreen.greenmail.util.Retriever in project greenmail by greenmail-mail-test.
the class ExamplePurgeAllEmailsTest method testRemoveAllMessagesInImapMailbox.
@Test
public void testRemoveAllMessagesInImapMailbox() throws FolderException {
try (Retriever retriever = new Retriever(greenMailRule.getImap())) {
greenMailRule.setUser("foo@localhost", "pwd");
GreenMailUtil.sendTextEmail("foo@localhost", "bar@localhost", "Test subject", "Test message", ServerSetupTest.SMTP);
assertThat(greenMailRule.waitForIncomingEmail(1)).isTrue();
greenMailRule.purgeEmailFromAllMailboxes();
Message[] messages = retriever.getMessages("foo@localhost", "pwd");
assertThat(messages.length).isEqualTo(0);
}
}
use of com.icegreen.greenmail.util.Retriever in project greenmail by greenmail-mail-test.
the class AuthenticationDisabledTest method testReceiveWithAuthDisabled.
@Test
public void testReceiveWithAuthDisabled() {
final String to = "to@localhost";
greenMail.waitForIncomingEmail(500, 1);
try (Retriever retriever = new Retriever(greenMail.getImap())) {
Message[] messages = retriever.getMessages(to);
assertThat(messages.length).isEqualTo(0);
}
}
use of com.icegreen.greenmail.util.Retriever in project greenmail by greenmail-mail-test.
the class AuthenticationDisabledTest method testSendMailAndReceiveWithAuthDisabled.
@Test
public void testSendMailAndReceiveWithAuthDisabled() throws MessagingException, IOException {
final String to = "to@localhost";
final String subject = "subject";
final String body = "body";
GreenMailUtil.sendTextEmailTest(to, "from@localhost", subject, body);
MimeMessage[] emails = greenMail.getReceivedMessages();
assertThat(emails.length).isEqualTo(1);
assertThat(emails[0].getSubject()).isEqualTo(subject);
assertThat(GreenMailUtil.getBody(emails[0])).isEqualTo(body);
greenMail.waitForIncomingEmail(5000, 1);
try (Retriever retriever = new Retriever(greenMail.getImap())) {
Message[] messages = retriever.getMessages(to);
assertThat(messages.length).isEqualTo(1);
assertThat(messages[0].getSubject()).isEqualTo(subject);
assertThat(messages[0].getContent()).isEqualTo(body);
}
}
Aggregations